what-the-bank/sources/okhttp3/internal/platform/android/BouncyCastleSocketAdapter.java

96 lines
3.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.internal.platform.android;
import java.util.List;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import o.C14953gcr;
import o.C14957gcv;
import okhttp3.Protocol;
import okhttp3.internal.platform.BouncyCastlePlatform;
import okhttp3.internal.platform.Platform;
import okhttp3.internal.platform.android.DeferredSocketAdapter;
import okhttp3.internal.platform.android.SocketAdapter;
import org.bouncycastle.jsse.BCSSLParameters;
import org.bouncycastle.jsse.BCSSLSocket;
/* loaded from: classes.dex */
public final class BouncyCastleSocketAdapter implements SocketAdapter {
public static final Companion Companion = new Companion(null);
private static final DeferredSocketAdapter.Factory factory = new DeferredSocketAdapter.Factory() { // from class: okhttp3.internal.platform.android.BouncyCastleSocketAdapter$Companion$factory$1
@Override // okhttp3.internal.platform.android.DeferredSocketAdapter.Factory
public final boolean matchesSocket(SSLSocket sSLSocket) {
C14957gcv.e(sSLSocket, "");
return BouncyCastlePlatform.Companion.isSupported() && (sSLSocket instanceof BCSSLSocket);
}
@Override // okhttp3.internal.platform.android.DeferredSocketAdapter.Factory
public final SocketAdapter create(SSLSocket sSLSocket) {
C14957gcv.e(sSLSocket, "");
return new BouncyCastleSocketAdapter();
}
};
@Override // okhttp3.internal.platform.android.SocketAdapter
public final boolean matchesSocketFactory(SSLSocketFactory sSLSocketFactory) {
return SocketAdapter.DefaultImpls.matchesSocketFactory(this, sSLSocketFactory);
}
@Override // okhttp3.internal.platform.android.SocketAdapter
public final X509TrustManager trustManager(SSLSocketFactory sSLSocketFactory) {
return SocketAdapter.DefaultImpls.trustManager(this, sSLSocketFactory);
}
@Override // okhttp3.internal.platform.android.SocketAdapter
public final boolean matchesSocket(SSLSocket sSLSocket) {
C14957gcv.e(sSLSocket, "");
return sSLSocket instanceof BCSSLSocket;
}
@Override // okhttp3.internal.platform.android.SocketAdapter
public final boolean isSupported() {
return BouncyCastlePlatform.Companion.isSupported();
}
@Override // okhttp3.internal.platform.android.SocketAdapter
public final String getSelectedProtocol(SSLSocket sSLSocket) {
C14957gcv.e(sSLSocket, "");
String applicationProtocol = ((BCSSLSocket) sSLSocket).getApplicationProtocol();
if (applicationProtocol == null || C14957gcv.b((Object) applicationProtocol, (Object) "")) {
return null;
}
return applicationProtocol;
}
@Override // okhttp3.internal.platform.android.SocketAdapter
public final void configureTlsExtensions(SSLSocket sSLSocket, String str, List<? extends Protocol> list) {
C14957gcv.e(sSLSocket, "");
C14957gcv.e(list, "");
if (matchesSocket(sSLSocket)) {
BCSSLSocket bCSSLSocket = (BCSSLSocket) sSLSocket;
BCSSLParameters parameters = bCSSLSocket.getParameters();
Object[] array = Platform.Companion.alpnProtocolNames(list).toArray(new String[0]);
if (array != null) {
parameters.setApplicationProtocols((String[]) array);
bCSSLSocket.setParameters(parameters);
return;
}
throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
}
}
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public final DeferredSocketAdapter.Factory getFactory() {
return BouncyCastleSocketAdapter.factory;
}
public /* synthetic */ Companion(C14953gcr c14953gcr) {
this();
}
}
}