what-the-bank/sources/com/facetec/sdk/jk.java

194 lines
6.4 KiB
Java

package com.facetec.sdk;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.net.ssl.SSLPeerUnverifiedException;
/* loaded from: classes.dex */
public final class jk {
public static final jk e = new a().e();
final mm c;
final Set<e> d;
/* JADX INFO: Access modifiers changed from: package-private */
public jk(Set<e> set, mm mmVar) {
this.d = set;
this.c = mmVar;
}
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof jk)) {
return false;
}
jk jkVar = (jk) obj;
return km.b(this.c, jkVar.c) && this.d.equals(jkVar.d);
}
public final int hashCode() {
mm mmVar = this.c;
return ((mmVar != null ? mmVar.hashCode() : 0) * 31) + this.d.hashCode();
}
public static String d(Certificate certificate) {
if (!(certificate instanceof X509Certificate)) {
throw new IllegalArgumentException("Certificate pinning requires X509 certificates");
}
StringBuilder sb = new StringBuilder("sha256/");
sb.append(a((X509Certificate) certificate).e());
return sb.toString();
}
private static mt a(X509Certificate x509Certificate) {
return mt.d(x509Certificate.getPublicKey().getEncoded()).a();
}
/* loaded from: classes.dex */
public static final class e {
private String a;
final mt c;
private String d;
final String e;
public e(String str, String str2) {
String i;
this.a = str;
if (str.startsWith("*.")) {
StringBuilder sb = new StringBuilder("http://");
sb.append(str.substring(2));
i = kc.b(sb.toString()).i();
} else {
i = kc.b("http://".concat(String.valueOf(str))).i();
}
this.d = i;
if (str2.startsWith("sha1/")) {
this.e = "sha1/";
this.c = mt.e(str2.substring(5));
} else if (str2.startsWith("sha256/")) {
this.e = "sha256/";
this.c = mt.e(str2.substring(7));
} else {
throw new IllegalArgumentException("pins must start with 'sha256/' or 'sha1/': ".concat(String.valueOf(str2)));
}
if (this.c == null) {
throw new IllegalArgumentException("pins must be base64: ".concat(String.valueOf(str2)));
}
}
final boolean a(String str) {
if (this.a.startsWith("*.")) {
int indexOf = str.indexOf(46);
if ((str.length() - indexOf) - 1 != this.d.length()) {
return false;
}
String str2 = this.d;
return str.regionMatches(false, indexOf + 1, str2, 0, str2.length());
}
return str.equals(this.d);
}
public final boolean equals(Object obj) {
if (!(obj instanceof e)) {
return false;
}
e eVar = (e) obj;
return this.a.equals(eVar.a) && this.e.equals(eVar.e) && this.c.equals(eVar.c);
}
public final int hashCode() {
int hashCode = this.a.hashCode();
return ((((hashCode + 527) * 31) + this.e.hashCode()) * 31) + this.c.hashCode();
}
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.e);
sb.append(this.c.e());
return sb.toString();
}
}
/* loaded from: classes.dex */
public static final class a {
public final List<e> b = new ArrayList();
public final jk e() {
return new jk(new LinkedHashSet(this.b), null);
}
}
public final void c(String str, List<Certificate> list) throws SSLPeerUnverifiedException {
List emptyList = Collections.emptyList();
for (e eVar : this.d) {
if (eVar.a(str)) {
if (emptyList.isEmpty()) {
emptyList = new ArrayList();
}
emptyList.add(eVar);
}
}
if (emptyList.isEmpty()) {
return;
}
mm mmVar = this.c;
if (mmVar != null) {
list = mmVar.a(list, str);
}
int size = list.size();
for (int i = 0; i < size; i++) {
X509Certificate x509Certificate = (X509Certificate) list.get(i);
int size2 = emptyList.size();
mt mtVar = null;
mt mtVar2 = null;
for (int i2 = 0; i2 < size2; i2++) {
e eVar2 = (e) emptyList.get(i2);
if (eVar2.e.equals("sha256/")) {
if (mtVar == null) {
mtVar = a(x509Certificate);
}
if (eVar2.c.equals(mtVar)) {
return;
}
} else if (eVar2.e.equals("sha1/")) {
if (mtVar2 == null) {
mtVar2 = mt.d(x509Certificate.getPublicKey().getEncoded()).d();
}
if (eVar2.c.equals(mtVar2)) {
return;
}
} else {
StringBuilder sb = new StringBuilder("unsupported hashAlgorithm: ");
sb.append(eVar2.e);
throw new AssertionError(sb.toString());
}
}
}
StringBuilder sb2 = new StringBuilder("Certificate pinning failure!\n Peer certificate chain:");
int size3 = list.size();
for (int i3 = 0; i3 < size3; i3++) {
X509Certificate x509Certificate2 = (X509Certificate) list.get(i3);
sb2.append("\n ");
sb2.append(d(x509Certificate2));
sb2.append(": ");
sb2.append(x509Certificate2.getSubjectDN().getName());
}
sb2.append("\n Pinned certificates for ");
sb2.append(str);
sb2.append(":");
int size4 = emptyList.size();
for (int i4 = 0; i4 < size4; i4++) {
e eVar3 = (e) emptyList.get(i4);
sb2.append("\n ");
sb2.append(eVar3);
}
throw new SSLPeerUnverifiedException(sb2.toString());
}
}