322 lines
15 KiB
Java
322 lines
15 KiB
Java
|
package io.beid.beidk.services;
|
||
|
|
||
|
import com.google.common.net.HttpHeaders;
|
||
|
import com.google.firebase.crashlytics.internal.common.AbstractSpiCall;
|
||
|
import com.google.gson.reflect.TypeToken;
|
||
|
import io.beid.beidk.BEIDConfigurationFactory;
|
||
|
import io.beid.beidk.a.b;
|
||
|
import io.beid.beidk.definitions.BeIDParams;
|
||
|
import io.beid.beidk.definitions.LivenessStatus;
|
||
|
import io.beid.beidk.definitions.SCBHeader;
|
||
|
import io.beid.beidk.definitions.TransactionUploadFileType;
|
||
|
import io.beid.beidk.messages.transaction.MatchingForm;
|
||
|
import io.beid.beidk.messages.transaction.MatchingResult;
|
||
|
import io.beid.beidk.messages.transaction.PassportVerifyForm;
|
||
|
import io.beid.beidk.messages.transaction.PassportVerifyResult;
|
||
|
import io.beid.beidk.messages.transaction.TransactionBeginForm;
|
||
|
import io.beid.beidk.messages.transaction.TransactionBeginResult;
|
||
|
import io.grpc.internal.GrpcUtil;
|
||
|
import io.reactivex.Single;
|
||
|
import java.io.File;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.math.BigDecimal;
|
||
|
import java.security.KeyManagementException;
|
||
|
import java.security.KeyStoreException;
|
||
|
import java.security.NoSuchAlgorithmException;
|
||
|
import java.security.cert.CertificateException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.UUID;
|
||
|
import java.util.concurrent.Callable;
|
||
|
import o.ApplicationC13088fQb;
|
||
|
import o.C13089fQc;
|
||
|
import o.C13093fQg;
|
||
|
import o.C13094fQh;
|
||
|
import o.C13095fQi;
|
||
|
import o.C13097fQk;
|
||
|
import o.C13098fQl;
|
||
|
import o.C13101fQo;
|
||
|
import o.C15554gto;
|
||
|
|
||
|
/* loaded from: classes5.dex */
|
||
|
public class TransactionService {
|
||
|
private final C15554gto b;
|
||
|
private final String c;
|
||
|
private BEIDConfigurationFactory d;
|
||
|
|
||
|
private C13089fQc a(BEIDConfigurationFactory bEIDConfigurationFactory, Map<String, String> map) throws BEIDConfigurationFactory.MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, KeyManagementException {
|
||
|
C13093fQg c13093fQg = new C13093fQg();
|
||
|
c13093fQg.b = bEIDConfigurationFactory.getHttpClient();
|
||
|
c13093fQg.d.put("User-Agent", bEIDConfigurationFactory.getUserAgent());
|
||
|
return e(c13093fQg, map);
|
||
|
}
|
||
|
|
||
|
private C13089fQc e(C13093fQg c13093fQg, Map<String, String> map) {
|
||
|
try {
|
||
|
c13093fQg.e = this.c;
|
||
|
c13093fQg.d.put(SCBHeader.SCB_REQ_HEADER_REQUEST_ID, UUID.randomUUID().toString());
|
||
|
for (String str : map.keySet()) {
|
||
|
c13093fQg.d.put(str, map.get(str));
|
||
|
}
|
||
|
C13089fQc c13089fQc = new C13089fQc();
|
||
|
c13089fQc.b = c13093fQg;
|
||
|
return c13089fQc;
|
||
|
} catch (Exception unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static PassportVerifyResult b(C13097fQk c13097fQk) {
|
||
|
PassportVerifyResult passportVerifyResult = new PassportVerifyResult();
|
||
|
passportVerifyResult.result = c13097fQk.b();
|
||
|
C13097fQk.IeS d = c13097fQk.d();
|
||
|
passportVerifyResult.errorCode = d == null ? "" : d.h.toString();
|
||
|
Object[] objArr = {c13097fQk};
|
||
|
System.identityHashCode(c13097fQk);
|
||
|
String str = (String) C13097fQk.c(objArr);
|
||
|
passportVerifyResult.error = str != null ? str : "";
|
||
|
return passportVerifyResult;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public TransactionBeginResult beginSync(TransactionBeginForm transactionBeginForm, Map<String, String> map) throws IOException, BEIDConfigurationFactory.MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, KeyManagementException {
|
||
|
try {
|
||
|
C13089fQc a = a(this.d, map);
|
||
|
C13094fQh d = new C13094fQh().a(transactionBeginForm.applicationName).b(transactionBeginForm.deviceId).d(transactionBeginForm.platformId);
|
||
|
C13094fQh c13094fQh = (C13094fQh) C13094fQh.e(new Object[]{d, "c0436fa"}, 1866519271, -1866519271, System.identityHashCode(d));
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
HashMap hashMap = new HashMap();
|
||
|
HashMap hashMap2 = new HashMap();
|
||
|
C13093fQg c13093fQg = a.b;
|
||
|
String[] strArr = {AbstractSpiCall.ACCEPT_JSON_VALUE};
|
||
|
C13093fQg c13093fQg2 = a.b;
|
||
|
hashMap.put(HttpHeaders.CONTENT_TYPE, C13093fQg.b(strArr));
|
||
|
C13101fQo c13101fQo = (C13101fQo) a.b.d(a.b.b("/transaction/begin", GrpcUtil.HTTP_METHOD, arrayList, arrayList2, c13094fQh, hashMap, hashMap2, new String[0]), new TypeToken<C13101fQo>(a) { // from class: o.fQc.3
|
||
|
private C13089fQc d;
|
||
|
|
||
|
public AnonymousClass3(C13089fQc a2) {
|
||
|
this.d = a2;
|
||
|
}
|
||
|
}.getType()).a;
|
||
|
TransactionBeginResult transactionBeginResult = new TransactionBeginResult();
|
||
|
System.identityHashCode(c13101fQo);
|
||
|
transactionBeginResult.transactionId = (String) C13101fQo.b(new Object[]{c13101fQo});
|
||
|
List<BigDecimal> c = c13101fQo.c();
|
||
|
ArrayList arrayList3 = new ArrayList();
|
||
|
Iterator<BigDecimal> it = c.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
arrayList3.add(Integer.valueOf(it.next().intValueExact()));
|
||
|
}
|
||
|
transactionBeginResult.livenessActivity = arrayList3;
|
||
|
transactionBeginResult.livenessAcceptance = c13101fQo.d();
|
||
|
transactionBeginResult.serverTimestamp = c13101fQo.b().format(this.b);
|
||
|
transactionBeginResult.timeout = c13101fQo.e().format(this.b);
|
||
|
return transactionBeginResult;
|
||
|
} catch (b e) {
|
||
|
TransactionBeginResult transactionBeginResult2 = new TransactionBeginResult();
|
||
|
transactionBeginResult2.transactionId = "-1";
|
||
|
transactionBeginResult2.error = e.getMessage();
|
||
|
return transactionBeginResult2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public MatchingResult matchSync(MatchingForm matchingForm, Map<String, String> map) throws IOException, BEIDConfigurationFactory.MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, KeyManagementException {
|
||
|
C13089fQc a = a(this.d, map);
|
||
|
C13098fQl d = new C13098fQl().b(matchingForm.transactionId).d(matchingForm.faceSelfie);
|
||
|
try {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
HashMap hashMap = new HashMap();
|
||
|
HashMap hashMap2 = new HashMap();
|
||
|
C13093fQg c13093fQg = a.b;
|
||
|
C13093fQg c13093fQg2 = a.b;
|
||
|
hashMap.put(HttpHeaders.CONTENT_TYPE, C13093fQg.b(new String[0]));
|
||
|
return new MatchingResult();
|
||
|
} catch (b e) {
|
||
|
MatchingResult matchingResult = new MatchingResult();
|
||
|
matchingResult.error = e.c == 403 ? LivenessStatus.ERROR_MATCHING_FAIL : e.getMessage();
|
||
|
return matchingResult;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public boolean uploadDocumentSync(String str, TransactionUploadFileType transactionUploadFileType, InputStream inputStream, String str2, Map<String, String> map) throws IOException, BEIDConfigurationFactory.MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, KeyManagementException {
|
||
|
C13089fQc a = a(this.d, map);
|
||
|
try {
|
||
|
String obj = transactionUploadFileType.getValue().toString();
|
||
|
byte[] bArr = new byte[inputStream.available()];
|
||
|
inputStream.read(bArr);
|
||
|
StringBuilder sb = new StringBuilder("upload_");
|
||
|
sb.append(UUID.randomUUID());
|
||
|
File createTempFile = File.createTempFile(sb.toString(), null, ApplicationC13088fQb.d == null ? null : ApplicationC13088fQb.d.getCacheDir());
|
||
|
new FileOutputStream(createTempFile).write(bArr);
|
||
|
if (str == null) {
|
||
|
throw new b("Missing the required parameter 'transactionId' when calling upload(Async)");
|
||
|
}
|
||
|
if (obj == null) {
|
||
|
throw new b("Missing the required parameter 'fileType' when calling upload(Async)");
|
||
|
}
|
||
|
if (str2 == null) {
|
||
|
throw new b("Missing the required parameter 'meta' when calling upload(Async)");
|
||
|
}
|
||
|
if (createTempFile == null) {
|
||
|
throw new b("Missing the required parameter 'file' when calling upload(Async)");
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
HashMap hashMap = new HashMap();
|
||
|
HashMap hashMap2 = new HashMap();
|
||
|
if (str != null) {
|
||
|
hashMap2.put(BeIDParams.BEID_TRANSACTION_ID, str);
|
||
|
}
|
||
|
if (obj != null) {
|
||
|
hashMap2.put("fileType", obj);
|
||
|
}
|
||
|
if (str2 != null) {
|
||
|
hashMap2.put("meta", str2);
|
||
|
}
|
||
|
if (createTempFile != null) {
|
||
|
hashMap2.put("file", createTempFile);
|
||
|
}
|
||
|
C13093fQg c13093fQg = a.b;
|
||
|
C13093fQg c13093fQg2 = a.b;
|
||
|
hashMap.put(HttpHeaders.CONTENT_TYPE, C13093fQg.b(new String[]{"multipart/form-data"}));
|
||
|
return true;
|
||
|
} catch (b unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public PassportVerifyResult verifyPassportSync(PassportVerifyForm passportVerifyForm, Map<String, String> map) throws IOException, BEIDConfigurationFactory.MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, KeyManagementException {
|
||
|
C13089fQc a = a(this.d, map);
|
||
|
C13095fQi c = new C13095fQi().c(passportVerifyForm.transactionId);
|
||
|
Object[] objArr = {c, passportVerifyForm.DG1};
|
||
|
System.identityHashCode(c);
|
||
|
C13095fQi a2 = ((C13095fQi) C13095fQi.c(objArr)).b(passportVerifyForm.DG2).a(passportVerifyForm.DG13);
|
||
|
a2.e(passportVerifyForm.SOD);
|
||
|
try {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
HashMap hashMap = new HashMap();
|
||
|
HashMap hashMap2 = new HashMap();
|
||
|
C13093fQg c13093fQg = a.b;
|
||
|
C13093fQg c13093fQg2 = a.b;
|
||
|
hashMap.put(HttpHeaders.CONTENT_TYPE, C13093fQg.b(new String[0]));
|
||
|
return b((C13097fQk) a.b.d(a.b.b("/transaction/passport/verify", GrpcUtil.HTTP_METHOD, arrayList, arrayList2, a2, hashMap, hashMap2, new String[0]), new TypeToken<C13097fQk>(a) { // from class: o.fQc.4
|
||
|
private C13089fQc e;
|
||
|
|
||
|
public AnonymousClass4(C13089fQc a3) {
|
||
|
this.e = a3;
|
||
|
}
|
||
|
}.getType()).a);
|
||
|
} catch (b unused) {
|
||
|
return b(new C13097fQk().e("fail").d("invalid payload").d(C13097fQk.IeS._400));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Single<PassportVerifyResult> verifyPassport(PassportVerifyForm passportVerifyForm, Map<String, String> map) {
|
||
|
return Single.fromCallable(new Callable<PassportVerifyResult>(this, passportVerifyForm, map) { // from class: io.beid.beidk.services.TransactionService.1
|
||
|
private PassportVerifyForm b;
|
||
|
private Map c;
|
||
|
private TransactionService d;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final /* synthetic */ PassportVerifyResult call() throws Exception {
|
||
|
return this.d.verifyPassportSync(this.b, this.c);
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.d = this;
|
||
|
this.b = passportVerifyForm;
|
||
|
this.c = map;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public Single<Boolean> uploadDocument(String str, TransactionUploadFileType transactionUploadFileType, InputStream inputStream, String str2, Map<String, String> map) {
|
||
|
return Single.fromCallable(new Callable<Boolean>(this, str, transactionUploadFileType, inputStream, str2, map) { // from class: io.beid.beidk.services.TransactionService.5
|
||
|
private Map a;
|
||
|
private TransactionUploadFileType b;
|
||
|
private InputStream c;
|
||
|
private String d;
|
||
|
private String e;
|
||
|
private TransactionService f;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final /* synthetic */ Boolean call() throws Exception {
|
||
|
return Boolean.valueOf(this.f.uploadDocumentSync(this.e, this.b, this.c, this.d, this.a));
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.f = this;
|
||
|
this.e = str;
|
||
|
this.b = transactionUploadFileType;
|
||
|
this.c = inputStream;
|
||
|
this.d = str2;
|
||
|
this.a = map;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public Single<MatchingResult> match(MatchingForm matchingForm, Map<String, String> map) {
|
||
|
return Single.fromCallable(new Callable<MatchingResult>(this, matchingForm, map) { // from class: io.beid.beidk.services.TransactionService.3
|
||
|
private MatchingForm a;
|
||
|
private TransactionService b;
|
||
|
private Map c;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final /* synthetic */ MatchingResult call() throws Exception {
|
||
|
return this.b.matchSync(this.a, this.c);
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
this.a = matchingForm;
|
||
|
this.c = map;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public Single<TransactionBeginResult> begin(TransactionBeginForm transactionBeginForm, Map<String, String> map) {
|
||
|
return Single.fromCallable(new Callable<TransactionBeginResult>(this, transactionBeginForm, map) { // from class: io.beid.beidk.services.TransactionService.2
|
||
|
private TransactionService a;
|
||
|
private TransactionBeginForm b;
|
||
|
private Map c;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final /* synthetic */ TransactionBeginResult call() throws Exception {
|
||
|
return this.a.beginSync(this.b, this.c);
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.a = this;
|
||
|
this.b = transactionBeginForm;
|
||
|
this.c = map;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public TransactionService(String str) {
|
||
|
this.d = new BEIDConfigurationFactory("http://api.beid.io", "", "", Boolean.FALSE, 30, null, "");
|
||
|
this.c = (str == null ? "" : str).replaceAll("/*$", "");
|
||
|
this.b = C15554gto.ofPattern("yyyy-MM-dd HH:mm:ss.S");
|
||
|
}
|
||
|
|
||
|
public TransactionService(BEIDConfigurationFactory bEIDConfigurationFactory) {
|
||
|
this(bEIDConfigurationFactory.getBaseUrl());
|
||
|
this.d = bEIDConfigurationFactory;
|
||
|
}
|
||
|
|
||
|
public TransactionService(BEIDConfigurationFactory.Builder builder) {
|
||
|
this(builder.Build());
|
||
|
}
|
||
|
}
|