mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
142 lines
7.9 KiB
Java
142 lines
7.9 KiB
Java
package okhttp3.internal.platform;
|
|
|
|
import java.security.KeyStore;
|
|
import java.security.Provider;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import javax.net.ssl.SSLContext;
|
|
import javax.net.ssl.SSLSocket;
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
import javax.net.ssl.TrustManager;
|
|
import javax.net.ssl.TrustManagerFactory;
|
|
import javax.net.ssl.X509TrustManager;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import okhttp3.Protocol;
|
|
import org.openjsse.javax.net.ssl.SSLParameters;
|
|
import org.openjsse.net.ssl.OpenJSSE;
|
|
|
|
/* compiled from: OpenJSSEPlatform.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u0000 \u00172\u00020\u0001:\u0001\u0017B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J-\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\b\u0010\t\u001a\u0004\u0018\u00010\n2\u0011\u0010\u000b\u001a\r\u0012\t\u0012\u00070\r¢\u0006\u0002\b\u000e0\fH\u0016J\u0012\u0010\u000f\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0007\u001a\u00020\bH\u0016J\b\u0010\u0010\u001a\u00020\u0011H\u0016J\b\u0010\u0012\u001a\u00020\u0013H\u0016J\u0012\u0010\u0014\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0015\u001a\u00020\u0016H\u0016R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lokhttp3/internal/platform/OpenJSSEPlatform;", "Lokhttp3/internal/platform/Platform;", "()V", "provider", "Ljava/security/Provider;", "configureTlsExtensions", "", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "hostname", "", "protocols", "", "Lokhttp3/Protocol;", "Lkotlin/jvm/JvmSuppressWildcards;", "getSelectedProtocol", "newSSLContext", "Ljavax/net/ssl/SSLContext;", "platformTrustManager", "Ljavax/net/ssl/X509TrustManager;", "trustManager", "sslSocketFactory", "Ljavax/net/ssl/SSLSocketFactory;", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public final class OpenJSSEPlatform extends Platform {
|
|
|
|
/* renamed from: Companion, reason: from kotlin metadata */
|
|
public static final Companion INSTANCE;
|
|
private static final boolean isSupported;
|
|
private final Provider provider;
|
|
|
|
private OpenJSSEPlatform() {
|
|
this.provider = new OpenJSSE();
|
|
}
|
|
|
|
public /* synthetic */ OpenJSSEPlatform(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
@Override // okhttp3.internal.platform.Platform
|
|
public SSLContext newSSLContext() {
|
|
SSLContext sSLContext = SSLContext.getInstance("TLSv1.3", this.provider);
|
|
Intrinsics.checkNotNullExpressionValue(sSLContext, "SSLContext.getInstance(\"TLSv1.3\", provider)");
|
|
return sSLContext;
|
|
}
|
|
|
|
@Override // okhttp3.internal.platform.Platform
|
|
public X509TrustManager platformTrustManager() {
|
|
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm(), this.provider);
|
|
factory.init((KeyStore) null);
|
|
Intrinsics.checkNotNullExpressionValue(factory, "factory");
|
|
TrustManager[] trustManagers = factory.getTrustManagers();
|
|
Intrinsics.checkNotNull(trustManagers);
|
|
if (!(trustManagers.length == 1 && (trustManagers[0] instanceof X509TrustManager))) {
|
|
StringBuilder sb = new StringBuilder("Unexpected default trust managers: ");
|
|
String arrays = Arrays.toString(trustManagers);
|
|
Intrinsics.checkNotNullExpressionValue(arrays, "java.util.Arrays.toString(this)");
|
|
throw new IllegalStateException(sb.append(arrays).toString().toString());
|
|
}
|
|
TrustManager trustManager = trustManagers[0];
|
|
if (trustManager != null) {
|
|
return (X509TrustManager) trustManager;
|
|
}
|
|
throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.X509TrustManager");
|
|
}
|
|
|
|
@Override // okhttp3.internal.platform.Platform
|
|
public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
|
|
Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
|
|
throw new UnsupportedOperationException("clientBuilder.sslSocketFactory(SSLSocketFactory) not supported with OpenJSSE");
|
|
}
|
|
|
|
@Override // okhttp3.internal.platform.Platform
|
|
public void configureTlsExtensions(SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
|
|
Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
|
|
Intrinsics.checkNotNullParameter(protocols, "protocols");
|
|
if (sslSocket instanceof org.openjsse.javax.net.ssl.SSLSocket) {
|
|
org.openjsse.javax.net.ssl.SSLSocket sSLSocket = (org.openjsse.javax.net.ssl.SSLSocket) sslSocket;
|
|
SSLParameters sSLParameters = sSLSocket.getSSLParameters();
|
|
if (sSLParameters instanceof SSLParameters) {
|
|
List<String> alpnProtocolNames = Platform.INSTANCE.alpnProtocolNames(protocols);
|
|
SSLParameters sSLParameters2 = sSLParameters;
|
|
Object[] array = alpnProtocolNames.toArray(new String[0]);
|
|
if (array != null) {
|
|
sSLParameters2.setApplicationProtocols((String[]) array);
|
|
sSLSocket.setSSLParameters(sSLParameters);
|
|
return;
|
|
}
|
|
throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
|
|
}
|
|
return;
|
|
}
|
|
super.configureTlsExtensions(sslSocket, hostname, protocols);
|
|
}
|
|
|
|
@Override // okhttp3.internal.platform.Platform
|
|
public String getSelectedProtocol(SSLSocket sslSocket) {
|
|
Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
|
|
if (sslSocket instanceof org.openjsse.javax.net.ssl.SSLSocket) {
|
|
String applicationProtocol = ((org.openjsse.javax.net.ssl.SSLSocket) sslSocket).getApplicationProtocol();
|
|
if (applicationProtocol == null || (applicationProtocol.hashCode() == 0 && applicationProtocol.equals(""))) {
|
|
return null;
|
|
}
|
|
return applicationProtocol;
|
|
}
|
|
return super.getSelectedProtocol(sslSocket);
|
|
}
|
|
|
|
/* compiled from: OpenJSSEPlatform.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007R\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0003\u0010\u0005¨\u0006\b"}, d2 = {"Lokhttp3/internal/platform/OpenJSSEPlatform$Companion;", "", "()V", "isSupported", "", "()Z", "buildIfSupported", "Lokhttp3/internal/platform/OpenJSSEPlatform;", "okhttp"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final boolean isSupported() {
|
|
return OpenJSSEPlatform.isSupported;
|
|
}
|
|
|
|
public final OpenJSSEPlatform buildIfSupported() {
|
|
DefaultConstructorMarker defaultConstructorMarker = null;
|
|
if (isSupported()) {
|
|
return new OpenJSSEPlatform(defaultConstructorMarker);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static {
|
|
Companion companion = new Companion(null);
|
|
INSTANCE = companion;
|
|
boolean z = false;
|
|
try {
|
|
Class.forName("org.openjsse.net.ssl.OpenJSSE", false, companion.getClass().getClassLoader());
|
|
z = true;
|
|
} catch (ClassNotFoundException unused) {
|
|
}
|
|
isSupported = z;
|
|
}
|
|
}
|