package com.facetec.sdk; import com.facetec.sdk.jv; import com.google.common.primitives.UnsignedBytes; import java.io.Closeable; import java.io.IOException; import java.io.InterruptedIOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.IDN; import java.net.InetAddress; import java.net.Socket; import java.nio.charset.Charset; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import org.bouncycastle.i18n.LocalizedMessage; /* loaded from: classes.dex */ public final class km { public static final String[] a = new String[0]; public static final byte[] b; public static final Charset c; public static final kf d; public static final TimeZone e; private static final mt f; public static final Comparator g; private static final mt h; private static final mt i; private static final mt j; private static final Charset k; private static final Charset l; private static final mt m; private static final Charset n; /* renamed from: o, reason: collision with root package name */ private static final Charset f6448o; private static final Method s; private static final Pattern t; public static int d(char c2) { if (c2 >= '0' && c2 <= '9') { return c2 - '0'; } if (c2 >= 'a' && c2 <= 'f') { return c2 - 'W'; } if (c2 < 'A' || c2 > 'F') { return -1; } return c2 - '7'; } public static void d(Throwable th, Throwable th2) { Method method = s; if (method != null) { try { method.invoke(th, th2); } catch (IllegalAccessException | InvocationTargetException unused) { } } } public static void e(long j2, long j3) { if (j3 < 0 || 0 > j2 || j2 < j3) { throw new ArrayIndexOutOfBoundsException(); } } public static boolean b(Object obj, Object obj2) { if (obj != obj2) { return obj != null && obj.equals(obj2); } return true; } public static void a(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (RuntimeException e2) { throw e2; } catch (Exception unused) { } } } public static void b(Socket socket) { if (socket != null) { try { socket.close(); } catch (AssertionError e2) { if (!c(e2)) { throw e2; } } catch (RuntimeException e3) { throw e3; } catch (Exception unused) { } } } public static boolean e(nk nkVar, TimeUnit timeUnit) { try { return a(nkVar, 100, timeUnit); } catch (IOException unused) { return false; } } public static boolean a(nk nkVar, int i2, TimeUnit timeUnit) throws IOException { long nanoTime = System.nanoTime(); long c_ = nkVar.b().b_() ? nkVar.b().c_() - nanoTime : Long.MAX_VALUE; nkVar.b().e(Math.min(c_, timeUnit.toNanos(i2)) + nanoTime); try { ms msVar = new ms(); while (nkVar.b(msVar, 8192L) != -1) { msVar.t(); } if (c_ == Long.MAX_VALUE) { nkVar.b().d_(); return true; } nkVar.b().e(nanoTime + c_); return true; } catch (InterruptedIOException unused) { if (c_ == Long.MAX_VALUE) { nkVar.b().d_(); return false; } nkVar.b().e(nanoTime + c_); return false; } catch (Throwable th) { if (c_ == Long.MAX_VALUE) { nkVar.b().d_(); } else { nkVar.b().e(nanoTime + c_); } throw th; } } public static List e(List list) { return Collections.unmodifiableList(new ArrayList(list)); } public static Map e(Map map) { if (map.isEmpty()) { return Collections.emptyMap(); } return Collections.unmodifiableMap(new LinkedHashMap(map)); } public static List d(T... tArr) { return Collections.unmodifiableList(Arrays.asList((Object[]) tArr.clone())); } public static ThreadFactory d(String str, boolean z) { return new ThreadFactory(str, z) { // from class: com.facetec.sdk.km.3 private String a; private boolean d; { this.a = str; this.d = z; } @Override // java.util.concurrent.ThreadFactory public final Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable, this.a); thread.setDaemon(this.d); return thread; } }; } public static String[] b(Comparator comparator, String[] strArr, String[] strArr2) { ArrayList arrayList = new ArrayList(); for (String str : strArr) { int length = strArr2.length; int i2 = 0; while (true) { if (i2 >= length) { break; } if (comparator.compare(str, strArr2[i2]) == 0) { arrayList.add(str); break; } i2++; } } return (String[]) arrayList.toArray(new String[arrayList.size()]); } public static boolean d(Comparator comparator, String[] strArr, String[] strArr2) { if (strArr != null && strArr2 != null && strArr.length != 0 && strArr2.length != 0) { for (String str : strArr) { for (String str2 : strArr2) { if (comparator.compare(str, str2) == 0) { return true; } } } } return false; } public static String b(kc kcVar, boolean z) { String i2; if (kcVar.i().contains(":")) { StringBuilder sb = new StringBuilder("["); sb.append(kcVar.i()); sb.append("]"); i2 = sb.toString(); } else { i2 = kcVar.i(); } if (!z && kcVar.j() == kc.c(kcVar.b())) { return i2; } StringBuilder sb2 = new StringBuilder(); sb2.append(i2); sb2.append(":"); sb2.append(kcVar.j()); return sb2.toString(); } public static boolean c(AssertionError assertionError) { return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true; } public static int b(Comparator comparator, String[] strArr, String str) { int length = strArr.length; for (int i2 = 0; i2 < length; i2++) { if (comparator.compare(strArr[i2], str) == 0) { return i2; } } return -1; } public static String[] c(String[] strArr, String str) { int length = strArr.length; String[] strArr2 = new String[length + 1]; System.arraycopy(strArr, 0, strArr2, 0, strArr.length); strArr2[length] = str; return strArr2; } public static int d(String str, int i2, int i3) { while (i2 < i3) { char charAt = str.charAt(i2); if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') { return i2; } i2++; } return i3; } public static int e(String str, int i2, int i3) { while (true) { int i4 = i3 - 1; if (i4 < i2) { return i2; } char charAt = str.charAt(i4); if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') { return i3; } i3 = i4; } } public static String a(String str, int i2, int i3) { int d2 = d(str, i2, i3); return str.substring(d2, e(str, d2, i3)); } public static int b(String str, int i2, int i3, String str2) { while (i2 < i3) { if (str2.indexOf(str.charAt(i2)) != -1) { return i2; } i2++; } return i3; } public static int d(String str, int i2, int i3, char c2) { while (i2 < i3) { if (str.charAt(i2) == c2) { return i2; } i2++; } return i3; } public static String c(String str) { InetAddress b2; if (str.contains(":")) { int i2 = 0; if (str.startsWith("[") && str.endsWith("]")) { b2 = b(str, 1, str.length() - 1); } else { b2 = b(str, 0, str.length()); } if (b2 == null) { return null; } byte[] address = b2.getAddress(); if (address.length != 16) { StringBuilder sb = new StringBuilder("Invalid IPv6 address: '"); sb.append(str); sb.append("'"); throw new AssertionError(sb.toString()); } int i3 = -1; int i4 = 0; int i5 = 0; while (i4 < address.length) { int i6 = i4; while (i6 < 16 && address[i6] == 0 && address[i6 + 1] == 0) { i6 += 2; } int i7 = i6 - i4; if (i7 > i5 && i7 >= 4) { i3 = i4; i5 = i7; } i4 = i6 + 2; } ms msVar = new ms(); while (i2 < address.length) { if (i2 == i3) { msVar.h(58); i2 += i5; if (i2 == 16) { msVar.h(58); } } else { if (i2 > 0) { msVar.h(58); } msVar.h(((address[i2] & UnsignedBytes.MAX_VALUE) << 8) | (address[i2 + 1] & UnsignedBytes.MAX_VALUE)); i2 += 2; } } return msVar.k(); } try { String lowerCase = IDN.toASCII(str).toLowerCase(Locale.US); if (lowerCase.isEmpty()) { return null; } if (d(lowerCase)) { return null; } return lowerCase; } catch (IllegalArgumentException unused) { return null; } } private static boolean d(String str) { for (int i2 = 0; i2 < str.length(); i2++) { char charAt = str.charAt(i2); if (charAt <= 31 || charAt >= 127 || " #%/:?@[\\]".indexOf(charAt) != -1) { return true; } } return false; } public static int e(String str) { int length = str.length(); for (int i2 = 0; i2 < length; i2++) { char charAt = str.charAt(i2); if (charAt <= 31 || charAt >= 127) { return i2; } } return -1; } public static boolean b(String str) { return t.matcher(str).matches(); } public static String a(String str, Object... objArr) { return String.format(Locale.US, str, objArr); } public static Charset a(mr mrVar, Charset charset) throws IOException { if (mrVar.e(i)) { mrVar.f(r0.i()); return c; } if (mrVar.e(f)) { mrVar.f(r0.i()); return k; } if (mrVar.e(h)) { mrVar.f(r0.i()); return f6448o; } if (mrVar.e(j)) { mrVar.f(r0.i()); return l; } if (!mrVar.e(m)) { return charset; } mrVar.f(r0.i()); return n; } public static int e(String str, TimeUnit timeUnit) { if (timeUnit == null) { throw new NullPointerException("unit == null"); } long millis = timeUnit.toMillis(60L); if (millis > 2147483647L) { StringBuilder sb = new StringBuilder(); sb.append(str); sb.append(" too large."); throw new IllegalArgumentException(sb.toString()); } if (millis != 0) { return (int) millis; } StringBuilder sb2 = new StringBuilder(); sb2.append(str); sb2.append(" too small."); throw new IllegalArgumentException(sb2.toString()); } public static AssertionError e(String str, Exception exc) { AssertionError assertionError = new AssertionError(str); try { assertionError.initCause(exc); } catch (IllegalStateException unused) { } return assertionError; } /* JADX WARN: Code restructure failed: missing block: B:25:0x0073, code lost: return null; */ /* JADX WARN: Removed duplicated region for block: B:15:0x004f */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static java.net.InetAddress b(java.lang.String r12, int r13, int r14) { /* r0 = 16 byte[] r1 = new byte[r0] r2 = 0 r3 = -1 r4 = r2 r5 = r3 r6 = r5 L9: r7 = 0 if (r13 >= r14) goto L74 if (r4 != r0) goto Lf return r7 Lf: int r8 = r13 + 2 r9 = 1 if (r8 > r14) goto L28 java.lang.String r10 = "::" r11 = 2 boolean r10 = r12.regionMatches(r13, r10, r2, r11) if (r10 == 0) goto L28 if (r5 == r3) goto L20 return r7 L20: int r4 = r4 + 2 r5 = r4 if (r8 != r14) goto L26 goto L74 L26: r6 = r8 goto L4b L28: if (r4 == 0) goto L4a java.lang.String r8 = ":" boolean r8 = r12.regionMatches(r13, r8, r2, r9) if (r8 == 0) goto L35 int r13 = r13 + 1 goto L4a L35: java.lang.String r8 = "." boolean r13 = r12.regionMatches(r13, r8, r2, r9) if (r13 == 0) goto L49 int r13 = r4 + (-2) boolean r12 = b(r12, r6, r14, r1, r13) if (r12 != 0) goto L46 return r7 L46: int r4 = r4 + 2 goto L74 L49: return r7 L4a: r6 = r13 L4b: r8 = r2 r13 = r6 L4d: if (r13 >= r14) goto L5f char r10 = r12.charAt(r13) int r10 = d(r10) if (r10 == r3) goto L5f int r8 = r8 << 4 int r8 = r8 + r10 int r13 = r13 + 1 goto L4d L5f: int r10 = r13 - r6 if (r10 == 0) goto L73 r11 = 4 if (r10 > r11) goto L73 int r7 = r8 >>> 8 byte r7 = (byte) r7 r1[r4] = r7 int r7 = r4 + 2 byte r8 = (byte) r8 int r4 = r4 + r9 r1[r4] = r8 r4 = r7 goto L9 L73: return r7 L74: if (r4 == r0) goto L85 if (r5 != r3) goto L79 return r7 L79: int r12 = r4 - r5 int r13 = 16 - r12 java.lang.System.arraycopy(r1, r5, r1, r13, r12) int r0 = r0 - r4 int r0 = r0 + r5 java.util.Arrays.fill(r1, r5, r0, r2) L85: java.net.InetAddress r12 = java.net.InetAddress.getByAddress(r1) // Catch: java.net.UnknownHostException -> L8a return r12 L8a: java.lang.AssertionError r12 = new java.lang.AssertionError r12.() throw r12 */ throw new UnsupportedOperationException("Method not decompiled: com.facetec.sdk.km.b(java.lang.String, int, int):java.net.InetAddress"); } private static boolean b(String str, int i2, int i3, byte[] bArr, int i4) { int i5 = i4; while (i2 < i3) { if (i5 == bArr.length) { return false; } if (i5 != i4) { if (str.charAt(i2) != '.') { return false; } i2++; } int i6 = i2; int i7 = 0; while (i6 < i3) { char charAt = str.charAt(i6); if (charAt < '0' || charAt > '9') { break; } if ((i7 == 0 && i2 != i6) || (i7 = ((i7 * 10) + charAt) - 48) > 255) { return false; } i6++; } if (i6 - i2 == 0) { return false; } bArr[i5] = (byte) i7; i5++; i2 = i6; } return i5 == i4 + 4; } public static X509TrustManager a() { try { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init((KeyStore) null); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); if (trustManagers.length == 1) { TrustManager trustManager = trustManagers[0]; if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } StringBuilder sb = new StringBuilder("Unexpected default trust managers:"); sb.append(Arrays.toString(trustManagers)); throw new IllegalStateException(sb.toString()); } catch (GeneralSecurityException e2) { throw e("No System TLS", e2); } } public static jv b(List list) { jv.a aVar = new jv.a(); for (ln lnVar : list) { kn.a.c(aVar, lnVar.h.b(), lnVar.j.b()); } return aVar.e(); } static { byte[] bArr = new byte[0]; b = bArr; final ms e2 = new ms().e(bArr); if (e2 == null) { throw new NullPointerException("source == null"); } final long j2 = 0; d = new kf(j2, e2) { // from class: com.facetec.sdk.kf.3 private long a; private mr b; private jz d = null; public AnonymousClass3(final long j22, final mr e22) { this.a = j22; this.b = e22; } @Override // com.facetec.sdk.kf public final long e() { return this.a; } @Override // com.facetec.sdk.kf public final mr d() { return this.b; } @Override // com.facetec.sdk.kf public final jz b() { return this.d; } }; Method method = null; ki.a(null, bArr); i = mt.d("efbbbf"); f = mt.d("feff"); h = mt.d("fffe"); j = mt.d("0000ffff"); m = mt.d("ffff0000"); c = Charset.forName("UTF-8"); Charset.forName(LocalizedMessage.DEFAULT_ENCODING); k = Charset.forName("UTF-16BE"); f6448o = Charset.forName("UTF-16LE"); l = Charset.forName("UTF-32BE"); n = Charset.forName("UTF-32LE"); e = TimeZone.getTimeZone("GMT"); g = new Comparator() { // from class: com.facetec.sdk.km.1 @Override // java.util.Comparator public final /* synthetic */ int compare(String str, String str2) { return str.compareTo(str2); } }; try { method = Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class); } catch (Exception unused) { } s = method; t = Pattern.compile("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)"); } }