347 lines
12 KiB
Java
347 lines
12 KiB
Java
|
package com.facetec.sdk;
|
||
|
|
||
|
import android.os.Build;
|
||
|
import java.io.IOException;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.lang.reflect.Method;
|
||
|
import java.net.InetSocketAddress;
|
||
|
import java.net.Socket;
|
||
|
import java.security.NoSuchAlgorithmException;
|
||
|
import java.security.Security;
|
||
|
import java.security.cert.Certificate;
|
||
|
import java.security.cert.TrustAnchor;
|
||
|
import java.security.cert.X509Certificate;
|
||
|
import java.util.List;
|
||
|
import javax.net.ssl.SSLContext;
|
||
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
||
|
import javax.net.ssl.SSLSocket;
|
||
|
import javax.net.ssl.SSLSocketFactory;
|
||
|
import javax.net.ssl.X509TrustManager;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
final class mg extends mi {
|
||
|
private final mj<Socket> a;
|
||
|
private final mj<Socket> b;
|
||
|
private final Class<?> c;
|
||
|
private final mj<Socket> d;
|
||
|
private final mj<Socket> e;
|
||
|
private final e f = e.a();
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final void d(int i, String str, Throwable th) {
|
||
|
}
|
||
|
|
||
|
private mg(Class<?> cls, mj<Socket> mjVar, mj<Socket> mjVar2, mj<Socket> mjVar3, mj<Socket> mjVar4) {
|
||
|
this.c = cls;
|
||
|
this.a = mjVar;
|
||
|
this.e = mjVar2;
|
||
|
this.d = mjVar3;
|
||
|
this.b = mjVar4;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final void c(Socket socket, InetSocketAddress inetSocketAddress, int i) throws IOException {
|
||
|
try {
|
||
|
socket.connect(inetSocketAddress, i);
|
||
|
} catch (AssertionError e2) {
|
||
|
if (!km.c(e2)) {
|
||
|
throw e2;
|
||
|
}
|
||
|
throw new IOException(e2);
|
||
|
} catch (ClassCastException e3) {
|
||
|
if (Build.VERSION.SDK_INT == 26) {
|
||
|
IOException iOException = new IOException("Exception in connect");
|
||
|
iOException.initCause(e3);
|
||
|
throw iOException;
|
||
|
}
|
||
|
throw e3;
|
||
|
} catch (SecurityException e4) {
|
||
|
IOException iOException2 = new IOException("Exception in connect");
|
||
|
iOException2.initCause(e4);
|
||
|
throw iOException2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
protected final X509TrustManager c(SSLSocketFactory sSLSocketFactory) {
|
||
|
Object b2 = b(sSLSocketFactory, this.c, "sslParameters");
|
||
|
if (b2 == null) {
|
||
|
try {
|
||
|
b2 = b(sSLSocketFactory, Class.forName("com.google.android.gms.org.conscrypt.SSLParametersImpl", false, sSLSocketFactory.getClass().getClassLoader()), "sslParameters");
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
return super.c(sSLSocketFactory);
|
||
|
}
|
||
|
}
|
||
|
X509TrustManager x509TrustManager = (X509TrustManager) b(b2, X509TrustManager.class, "x509TrustManager");
|
||
|
return x509TrustManager != null ? x509TrustManager : (X509TrustManager) b(b2, X509TrustManager.class, "trustManager");
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final void e(SSLSocket sSLSocket, String str, List<kd> list) {
|
||
|
if (str != null) {
|
||
|
this.a.e(sSLSocket, Boolean.TRUE);
|
||
|
this.e.e(sSLSocket, str);
|
||
|
}
|
||
|
mj<Socket> mjVar = this.b;
|
||
|
if (mjVar == null || !mjVar.c(sSLSocket)) {
|
||
|
return;
|
||
|
}
|
||
|
this.b.a(sSLSocket, d(list));
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final String c(SSLSocket sSLSocket) {
|
||
|
byte[] bArr;
|
||
|
mj<Socket> mjVar = this.d;
|
||
|
if (mjVar == null || !mjVar.c(sSLSocket) || (bArr = (byte[]) this.d.a(sSLSocket, new Object[0])) == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return new String(bArr, km.c);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final Object a(String str) {
|
||
|
return this.f.c(str);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final void c(String str, Object obj) {
|
||
|
if (this.f.d(obj)) {
|
||
|
return;
|
||
|
}
|
||
|
d(5, str, null);
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final boolean c(String str) {
|
||
|
try {
|
||
|
Class<?> cls = Class.forName("android.security.NetworkSecurityPolicy");
|
||
|
return c(str, cls, cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]));
|
||
|
} catch (ClassNotFoundException | NoSuchMethodException unused) {
|
||
|
return super.c(str);
|
||
|
} catch (IllegalAccessException e2) {
|
||
|
e = e2;
|
||
|
throw km.e("unable to determine cleartext support", e);
|
||
|
} catch (IllegalArgumentException e3) {
|
||
|
e = e3;
|
||
|
throw km.e("unable to determine cleartext support", e);
|
||
|
} catch (InvocationTargetException e4) {
|
||
|
e = e4;
|
||
|
throw km.e("unable to determine cleartext support", e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean c(String str, Class<?> cls, Object obj) throws InvocationTargetException, IllegalAccessException {
|
||
|
try {
|
||
|
return ((Boolean) cls.getMethod("isCleartextTrafficPermitted", String.class).invoke(obj, str)).booleanValue();
|
||
|
} catch (NoSuchMethodException unused) {
|
||
|
return b(str, cls, obj);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean b(String str, Class<?> cls, Object obj) throws InvocationTargetException, IllegalAccessException {
|
||
|
try {
|
||
|
return ((Boolean) cls.getMethod("isCleartextTrafficPermitted", new Class[0]).invoke(obj, new Object[0])).booleanValue();
|
||
|
} catch (NoSuchMethodException unused) {
|
||
|
return super.c(str);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static boolean b() {
|
||
|
if (Security.getProvider("GMSCore_OpenSSL") != null) {
|
||
|
return true;
|
||
|
}
|
||
|
try {
|
||
|
Class.forName("android.net.Network");
|
||
|
return true;
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final mm a(X509TrustManager x509TrustManager) {
|
||
|
try {
|
||
|
Class<?> cls = Class.forName("android.net.http.X509TrustManagerExtensions");
|
||
|
return new a(cls.getConstructor(X509TrustManager.class).newInstance(x509TrustManager), cls.getMethod("checkServerTrusted", X509Certificate[].class, String.class, String.class));
|
||
|
} catch (Exception unused) {
|
||
|
return super.a(x509TrustManager);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static mi e() {
|
||
|
Class<?> cls;
|
||
|
mj mjVar;
|
||
|
mj mjVar2;
|
||
|
try {
|
||
|
try {
|
||
|
cls = Class.forName("com.android.org.conscrypt.SSLParametersImpl");
|
||
|
} catch (ClassNotFoundException unused) {
|
||
|
cls = Class.forName("org.apache.harmony.xnet.provider.jsse.SSLParametersImpl");
|
||
|
}
|
||
|
Class<?> cls2 = cls;
|
||
|
mj mjVar3 = new mj(null, "setUseSessionTickets", Boolean.TYPE);
|
||
|
mj mjVar4 = new mj(null, "setHostname", String.class);
|
||
|
if (b()) {
|
||
|
mj mjVar5 = new mj(byte[].class, "getAlpnSelectedProtocol", new Class[0]);
|
||
|
mjVar2 = new mj(null, "setAlpnProtocols", byte[].class);
|
||
|
mjVar = mjVar5;
|
||
|
} else {
|
||
|
mjVar = null;
|
||
|
mjVar2 = null;
|
||
|
}
|
||
|
return new mg(cls2, mjVar3, mjVar4, mjVar, mjVar2);
|
||
|
} catch (ClassNotFoundException unused2) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final mq b(X509TrustManager x509TrustManager) {
|
||
|
try {
|
||
|
Method declaredMethod = x509TrustManager.getClass().getDeclaredMethod("findTrustAnchorByIssuerAndSignature", X509Certificate.class);
|
||
|
declaredMethod.setAccessible(true);
|
||
|
return new b(x509TrustManager, declaredMethod);
|
||
|
} catch (NoSuchMethodException unused) {
|
||
|
return super.b(x509TrustManager);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class a extends mm {
|
||
|
private final Object a;
|
||
|
private final Method c;
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
a(Object obj, Method method) {
|
||
|
this.a = obj;
|
||
|
this.c = method;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mm
|
||
|
public final List<Certificate> a(List<Certificate> list, String str) throws SSLPeerUnverifiedException {
|
||
|
try {
|
||
|
return (List) this.c.invoke(this.a, (X509Certificate[]) list.toArray(new X509Certificate[list.size()]), "RSA", str);
|
||
|
} catch (IllegalAccessException e) {
|
||
|
throw new AssertionError(e);
|
||
|
} catch (InvocationTargetException e2) {
|
||
|
SSLPeerUnverifiedException sSLPeerUnverifiedException = new SSLPeerUnverifiedException(e2.getMessage());
|
||
|
sSLPeerUnverifiedException.initCause(e2);
|
||
|
throw sSLPeerUnverifiedException;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
return obj instanceof a;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class e {
|
||
|
private final Method a;
|
||
|
private final Method b;
|
||
|
private final Method e;
|
||
|
|
||
|
private e(Method method, Method method2, Method method3) {
|
||
|
this.a = method;
|
||
|
this.b = method2;
|
||
|
this.e = method3;
|
||
|
}
|
||
|
|
||
|
final Object c(String str) {
|
||
|
Method method = this.a;
|
||
|
if (method != null) {
|
||
|
try {
|
||
|
Object invoke = method.invoke(null, new Object[0]);
|
||
|
this.b.invoke(invoke, str);
|
||
|
return invoke;
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
final boolean d(Object obj) {
|
||
|
if (obj == null) {
|
||
|
return false;
|
||
|
}
|
||
|
try {
|
||
|
this.e.invoke(obj, new Object[0]);
|
||
|
return true;
|
||
|
} catch (Exception unused) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static e a() {
|
||
|
Method method;
|
||
|
Method method2;
|
||
|
Method method3;
|
||
|
try {
|
||
|
Class<?> cls = Class.forName("dalvik.system.CloseGuard");
|
||
|
method = cls.getMethod("get", new Class[0]);
|
||
|
method3 = cls.getMethod("open", String.class);
|
||
|
method2 = cls.getMethod("warnIfOpen", new Class[0]);
|
||
|
} catch (Exception unused) {
|
||
|
method = null;
|
||
|
method2 = null;
|
||
|
method3 = null;
|
||
|
}
|
||
|
return new e(method, method3, method2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class b implements mq {
|
||
|
private final Method a;
|
||
|
private final X509TrustManager d;
|
||
|
|
||
|
b(X509TrustManager x509TrustManager, Method method) {
|
||
|
this.a = method;
|
||
|
this.d = x509TrustManager;
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mq
|
||
|
public final X509Certificate a(X509Certificate x509Certificate) {
|
||
|
try {
|
||
|
TrustAnchor trustAnchor = (TrustAnchor) this.a.invoke(this.d, x509Certificate);
|
||
|
if (trustAnchor != null) {
|
||
|
return trustAnchor.getTrustedCert();
|
||
|
}
|
||
|
return null;
|
||
|
} catch (IllegalAccessException e) {
|
||
|
throw km.e("unable to get issues and signature", e);
|
||
|
} catch (InvocationTargetException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (obj == this) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof b)) {
|
||
|
return false;
|
||
|
}
|
||
|
b bVar = (b) obj;
|
||
|
return this.d.equals(bVar.d) && this.a.equals(bVar.a);
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return this.d.hashCode() + (this.a.hashCode() * 31);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.facetec.sdk.mi
|
||
|
public final SSLContext d() {
|
||
|
try {
|
||
|
return SSLContext.getInstance(org.apache.http.conn.ssl.SSLSocketFactory.TLS);
|
||
|
} catch (NoSuchAlgorithmException e2) {
|
||
|
throw new IllegalStateException("No TLS provider", e2);
|
||
|
}
|
||
|
}
|
||
|
}
|