what-the-bank/sources/o/gkD.java

117 lines
4.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.ssl.SSLSocketFactory;
@Deprecated
/* loaded from: classes6.dex */
public final class gkD {
public String c;
public SecureRandom d;
private final Set<KeyManager> e = new LinkedHashSet();
private final Set<TrustManager> a = new LinkedHashSet();
public final gkD e(KeyStore keyStore, gkL gkl) throws NoSuchAlgorithmException, KeyStoreException {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStore);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers != null) {
if (gkl != null) {
for (int i = 0; i < trustManagers.length; i++) {
TrustManager trustManager = trustManagers[i];
if (trustManager instanceof X509TrustManager) {
trustManagers[i] = new Sts((X509TrustManager) trustManager, gkl);
}
}
}
for (TrustManager trustManager2 : trustManagers) {
this.a.add(trustManager2);
}
}
return this;
}
public final gkD a(KeyStore keyStore) throws NoSuchAlgorithmException, KeyStoreException {
return e(keyStore, (gkL) null);
}
public final SSLContext b() throws NoSuchAlgorithmException, KeyManagementException {
KeyManager[] keyManagerArr;
String str = this.c;
if (str == null) {
str = SSLSocketFactory.TLS;
}
SSLContext sSLContext = SSLContext.getInstance(str);
TrustManager[] trustManagerArr = null;
if (this.e.isEmpty()) {
keyManagerArr = null;
} else {
Set<KeyManager> set = this.e;
keyManagerArr = (KeyManager[]) set.toArray(new KeyManager[set.size()]);
}
if (!this.a.isEmpty()) {
Set<TrustManager> set2 = this.a;
trustManagerArr = (TrustManager[]) set2.toArray(new TrustManager[set2.size()]);
}
sSLContext.init(keyManagerArr, trustManagerArr, this.d);
return sSLContext;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class Sts implements X509TrustManager {
private final gkL b;
private final X509TrustManager e;
Sts(X509TrustManager x509TrustManager, gkL gkl) {
this.e = x509TrustManager;
this.b = gkl;
}
@Override // javax.net.ssl.X509TrustManager
public final void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
this.e.checkClientTrusted(x509CertificateArr, str);
}
@Override // javax.net.ssl.X509TrustManager
public final void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
if (this.b.a()) {
return;
}
this.e.checkServerTrusted(x509CertificateArr, str);
}
@Override // javax.net.ssl.X509TrustManager
public final X509Certificate[] getAcceptedIssuers() {
return this.e.getAcceptedIssuers();
}
}
public final gkD e(KeyStore keyStore, char[] cArr) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, cArr);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
if (keyManagers != null) {
for (KeyManager keyManager : keyManagers) {
this.e.add(keyManager);
}
}
return this;
}
}