what-the-bank/sources/com/kofax/mobile/sdk/_internal/impl/b.java

42 lines
1.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk._internal.impl;
import android.util.Base64;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import o.InterfaceC13391fZD;
import o.gjJ;
import org.bouncycastle.i18n.LocalizedMessage;
/* loaded from: classes3.dex */
public class b implements com.kofax.mobile.sdk._internal.b {
private static final Charset[] vP = {Charset.forName("UTF-8"), Charset.forName(LocalizedMessage.DEFAULT_ENCODING)};
@InterfaceC13391fZD
public b() {
}
@Override // com.kofax.mobile.sdk._internal.b
public String decode(String str) {
return d(Base64.decode(str, 0));
}
@Override // com.kofax.mobile.sdk._internal.b
public boolean v(String str) {
return gjJ.d(str).matches("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$");
}
private static String d(byte[] bArr) {
for (Charset charset : vP) {
try {
return charset.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT).decode(ByteBuffer.wrap(bArr)).toString();
} catch (CharacterCodingException unused) {
}
}
throw new KmcRuntimeException(ErrorInfo.KMC_GN_ILLEGAL_ARGUMENT_EXCEPTION);
}
}