mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
315 lines
18 KiB
Java
315 lines
18 KiB
Java
package okhttp3.internal.platform;
|
|
|
|
import io.sentry.SentryEvent;
|
|
import io.sentry.SentryLockReason;
|
|
import java.io.IOException;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.Socket;
|
|
import java.security.GeneralSecurityException;
|
|
import java.security.KeyStore;
|
|
import java.security.Provider;
|
|
import java.security.Security;
|
|
import java.security.cert.X509Certificate;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
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.collections.CollectionsKt;
|
|
import kotlin.jvm.JvmStatic;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import okhttp3.OkHttpClient;
|
|
import okhttp3.Protocol;
|
|
import okhttp3.internal.Util;
|
|
import okhttp3.internal.platform.android.AndroidLog;
|
|
import okhttp3.internal.tls.BasicCertificateChainCleaner;
|
|
import okhttp3.internal.tls.BasicTrustRootIndex;
|
|
import okhttp3.internal.tls.CertificateChainCleaner;
|
|
import okhttp3.internal.tls.TrustRootIndex;
|
|
import okio.Buffer;
|
|
|
|
/* compiled from: Platform.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000t\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\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\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0016\u0018\u0000 /2\u00020\u0001:\u0001/B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0016J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\t\u001a\u00020\nH\u0016J-\u0010\r\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\b\u0010\u000e\u001a\u0004\u0018\u00010\u000f2\u0011\u0010\u0010\u001a\r\u0012\t\u0012\u00070\u0012¢\u0006\u0002\b\u00130\u0011H\u0016J \u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001aH\u0016J\u0006\u0010\u001b\u001a\u00020\u000fJ\u0012\u0010\u001c\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0012\u0010\u001d\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u001e\u001a\u00020\u000fH\u0016J\u0010\u0010\u001f\u001a\u00020 2\u0006\u0010\u000e\u001a\u00020\u000fH\u0016J&\u0010!\u001a\u00020\u00042\u0006\u0010\"\u001a\u00020\u000f2\b\b\u0002\u0010#\u001a\u00020\u001a2\n\b\u0002\u0010$\u001a\u0004\u0018\u00010%H\u0016J\u001a\u0010&\u001a\u00020\u00042\u0006\u0010\"\u001a\u00020\u000f2\b\u0010'\u001a\u0004\u0018\u00010\u0001H\u0016J\b\u0010(\u001a\u00020)H\u0016J\u0010\u0010*\u001a\u00020+2\u0006\u0010\t\u001a\u00020\nH\u0016J\b\u0010,\u001a\u00020\nH\u0016J\b\u0010-\u001a\u00020\u000fH\u0016J\u0012\u0010\t\u001a\u0004\u0018\u00010\n2\u0006\u0010.\u001a\u00020+H\u0016¨\u00060"}, d2 = {"Lokhttp3/internal/platform/Platform;", "", "()V", "afterHandshake", "", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "buildCertificateChainCleaner", "Lokhttp3/internal/tls/CertificateChainCleaner;", "trustManager", "Ljavax/net/ssl/X509TrustManager;", "buildTrustRootIndex", "Lokhttp3/internal/tls/TrustRootIndex;", "configureTlsExtensions", "hostname", "", "protocols", "", "Lokhttp3/Protocol;", "Lkotlin/jvm/JvmSuppressWildcards;", "connectSocket", "socket", "Ljava/net/Socket;", SentryLockReason.JsonKeys.ADDRESS, "Ljava/net/InetSocketAddress;", "connectTimeout", "", "getPrefix", "getSelectedProtocol", "getStackTraceForCloseable", "closer", "isCleartextTrafficPermitted", "", "log", "message", "level", "t", "", "logCloseableLeak", "stackTrace", "newSSLContext", "Ljavax/net/ssl/SSLContext;", "newSslSocketFactory", "Ljavax/net/ssl/SSLSocketFactory;", "platformTrustManager", "toString", "sslSocketFactory", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public class Platform {
|
|
|
|
/* renamed from: Companion, reason: from kotlin metadata */
|
|
public static final Companion INSTANCE;
|
|
public static final int INFO = 4;
|
|
public static final int WARN = 5;
|
|
private static final Logger logger;
|
|
private static volatile Platform platform;
|
|
|
|
@JvmStatic
|
|
public static final Platform get() {
|
|
return INSTANCE.get();
|
|
}
|
|
|
|
public void afterHandshake(SSLSocket sslSocket) {
|
|
Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
|
|
}
|
|
|
|
public void configureTlsExtensions(SSLSocket sslSocket, String hostname, List<Protocol> protocols) {
|
|
Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
|
|
Intrinsics.checkNotNullParameter(protocols, "protocols");
|
|
}
|
|
|
|
public final String getPrefix() {
|
|
return "OkHttp";
|
|
}
|
|
|
|
public String getSelectedProtocol(SSLSocket sslSocket) {
|
|
Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
|
|
return null;
|
|
}
|
|
|
|
public boolean isCleartextTrafficPermitted(String hostname) {
|
|
Intrinsics.checkNotNullParameter(hostname, "hostname");
|
|
return true;
|
|
}
|
|
|
|
public SSLContext newSSLContext() {
|
|
SSLContext sSLContext = SSLContext.getInstance("TLS");
|
|
Intrinsics.checkNotNullExpressionValue(sSLContext, "SSLContext.getInstance(\"TLS\")");
|
|
return sSLContext;
|
|
}
|
|
|
|
public X509TrustManager platformTrustManager() {
|
|
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
|
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");
|
|
}
|
|
|
|
public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
|
|
Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
|
|
try {
|
|
Class<?> sslContextClass = Class.forName("sun.security.ssl.SSLContextImpl");
|
|
Intrinsics.checkNotNullExpressionValue(sslContextClass, "sslContextClass");
|
|
Object readFieldOrNull = Util.readFieldOrNull(sslSocketFactory, sslContextClass, "context");
|
|
if (readFieldOrNull != null) {
|
|
return (X509TrustManager) Util.readFieldOrNull(readFieldOrNull, X509TrustManager.class, "trustManager");
|
|
}
|
|
return null;
|
|
} catch (ClassNotFoundException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void connectSocket(Socket socket, InetSocketAddress address, int connectTimeout) throws IOException {
|
|
Intrinsics.checkNotNullParameter(socket, "socket");
|
|
Intrinsics.checkNotNullParameter(address, "address");
|
|
socket.connect(address, connectTimeout);
|
|
}
|
|
|
|
public static /* synthetic */ void log$default(Platform platform2, String str, int i, Throwable th, int i2, Object obj) {
|
|
if (obj != null) {
|
|
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: log");
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
i = 4;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
th = null;
|
|
}
|
|
platform2.log(str, i, th);
|
|
}
|
|
|
|
public void log(String message, int level, Throwable t) {
|
|
Intrinsics.checkNotNullParameter(message, "message");
|
|
logger.log(level == 5 ? Level.WARNING : Level.INFO, message, t);
|
|
}
|
|
|
|
public Object getStackTraceForCloseable(String closer) {
|
|
Intrinsics.checkNotNullParameter(closer, "closer");
|
|
if (logger.isLoggable(Level.FINE)) {
|
|
return new Throwable(closer);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void logCloseableLeak(String message, Object stackTrace) {
|
|
Intrinsics.checkNotNullParameter(message, "message");
|
|
if (stackTrace == null) {
|
|
message = message + " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);";
|
|
}
|
|
log(message, 5, (Throwable) stackTrace);
|
|
}
|
|
|
|
public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager trustManager) {
|
|
Intrinsics.checkNotNullParameter(trustManager, "trustManager");
|
|
return new BasicCertificateChainCleaner(buildTrustRootIndex(trustManager));
|
|
}
|
|
|
|
public TrustRootIndex buildTrustRootIndex(X509TrustManager trustManager) {
|
|
Intrinsics.checkNotNullParameter(trustManager, "trustManager");
|
|
X509Certificate[] acceptedIssuers = trustManager.getAcceptedIssuers();
|
|
Intrinsics.checkNotNullExpressionValue(acceptedIssuers, "trustManager.acceptedIssuers");
|
|
return new BasicTrustRootIndex((X509Certificate[]) Arrays.copyOf(acceptedIssuers, acceptedIssuers.length));
|
|
}
|
|
|
|
public SSLSocketFactory newSslSocketFactory(X509TrustManager trustManager) {
|
|
Intrinsics.checkNotNullParameter(trustManager, "trustManager");
|
|
try {
|
|
SSLContext newSSLContext = newSSLContext();
|
|
newSSLContext.init(null, new TrustManager[]{trustManager}, null);
|
|
SSLSocketFactory socketFactory = newSSLContext.getSocketFactory();
|
|
Intrinsics.checkNotNullExpressionValue(socketFactory, "newSSLContext().apply {\n…ll)\n }.socketFactory");
|
|
return socketFactory;
|
|
} catch (GeneralSecurityException e) {
|
|
throw new AssertionError("No System TLS: " + e, e);
|
|
}
|
|
}
|
|
|
|
public String toString() {
|
|
String simpleName = getClass().getSimpleName();
|
|
Intrinsics.checkNotNullExpressionValue(simpleName, "javaClass.simpleName");
|
|
return simpleName;
|
|
}
|
|
|
|
/* compiled from: Platform.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00130\u00122\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00150\u0012J\u0014\u0010\u0016\u001a\u00020\u00172\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00150\u0012J\b\u0010\u0018\u001a\u00020\u0010H\u0002J\b\u0010\u0019\u001a\u00020\u0010H\u0002J\b\u0010\u001a\u001a\u00020\u0010H\u0002J\b\u0010\u001b\u001a\u00020\u0010H\u0007J\u0010\u0010\u001c\u001a\u00020\u001d2\b\b\u0002\u0010\u000f\u001a\u00020\u0010R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u0011\u0010\u0006\u001a\u00020\u00078F¢\u0006\u0006\u001a\u0004\b\u0006\u0010\bR\u0014\u0010\t\u001a\u00020\u00078BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\bR\u0014\u0010\n\u001a\u00020\u00078BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\n\u0010\bR\u0014\u0010\u000b\u001a\u00020\u00078BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u000b\u0010\bR\u0016\u0010\f\u001a\n \u000e*\u0004\u0018\u00010\r0\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u001e"}, d2 = {"Lokhttp3/internal/platform/Platform$Companion;", "", "()V", "INFO", "", "WARN", "isAndroid", "", "()Z", "isBouncyCastlePreferred", "isConscryptPreferred", "isOpenJSSEPreferred", SentryEvent.JsonKeys.LOGGER, "Ljava/util/logging/Logger;", "kotlin.jvm.PlatformType", "platform", "Lokhttp3/internal/platform/Platform;", "alpnProtocolNames", "", "", "protocols", "Lokhttp3/Protocol;", "concatLengthPrefixed", "", "findAndroidPlatform", "findJvmPlatform", "findPlatform", "get", "resetForTests", "", "okhttp"}, k = 1, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
@JvmStatic
|
|
public final Platform get() {
|
|
return Platform.platform;
|
|
}
|
|
|
|
public static /* synthetic */ void resetForTests$default(Companion companion, Platform platform, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
platform = companion.findPlatform();
|
|
}
|
|
companion.resetForTests(platform);
|
|
}
|
|
|
|
public final void resetForTests(Platform platform) {
|
|
Intrinsics.checkNotNullParameter(platform, "platform");
|
|
Platform.platform = platform;
|
|
}
|
|
|
|
public final List<String> alpnProtocolNames(List<? extends Protocol> protocols) {
|
|
Intrinsics.checkNotNullParameter(protocols, "protocols");
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : protocols) {
|
|
if (((Protocol) obj) != Protocol.HTTP_1_0) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
ArrayList arrayList2 = arrayList;
|
|
ArrayList arrayList3 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList2, 10));
|
|
Iterator it = arrayList2.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList3.add(((Protocol) it.next()).getProtocol());
|
|
}
|
|
return arrayList3;
|
|
}
|
|
|
|
public final boolean isAndroid() {
|
|
return Intrinsics.areEqual("Dalvik", System.getProperty("java.vm.name"));
|
|
}
|
|
|
|
private final boolean isConscryptPreferred() {
|
|
Provider provider = Security.getProviders()[0];
|
|
Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
|
|
return Intrinsics.areEqual("Conscrypt", provider.getName());
|
|
}
|
|
|
|
private final boolean isOpenJSSEPreferred() {
|
|
Provider provider = Security.getProviders()[0];
|
|
Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
|
|
return Intrinsics.areEqual("OpenJSSE", provider.getName());
|
|
}
|
|
|
|
private final boolean isBouncyCastlePreferred() {
|
|
Provider provider = Security.getProviders()[0];
|
|
Intrinsics.checkNotNullExpressionValue(provider, "Security.getProviders()[0]");
|
|
return Intrinsics.areEqual("BC", provider.getName());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final Platform findPlatform() {
|
|
if (isAndroid()) {
|
|
return findAndroidPlatform();
|
|
}
|
|
return findJvmPlatform();
|
|
}
|
|
|
|
private final Platform findAndroidPlatform() {
|
|
AndroidLog.INSTANCE.enable();
|
|
Platform buildIfSupported = Android10Platform.INSTANCE.buildIfSupported();
|
|
if (buildIfSupported != null) {
|
|
return buildIfSupported;
|
|
}
|
|
Platform buildIfSupported2 = AndroidPlatform.Companion.buildIfSupported();
|
|
Intrinsics.checkNotNull(buildIfSupported2);
|
|
return buildIfSupported2;
|
|
}
|
|
|
|
private final Platform findJvmPlatform() {
|
|
OpenJSSEPlatform buildIfSupported;
|
|
BouncyCastlePlatform buildIfSupported2;
|
|
ConscryptPlatform buildIfSupported3;
|
|
if (isConscryptPreferred() && (buildIfSupported3 = ConscryptPlatform.INSTANCE.buildIfSupported()) != null) {
|
|
return buildIfSupported3;
|
|
}
|
|
if (isBouncyCastlePreferred() && (buildIfSupported2 = BouncyCastlePlatform.INSTANCE.buildIfSupported()) != null) {
|
|
return buildIfSupported2;
|
|
}
|
|
if (isOpenJSSEPreferred() && (buildIfSupported = OpenJSSEPlatform.INSTANCE.buildIfSupported()) != null) {
|
|
return buildIfSupported;
|
|
}
|
|
Jdk9Platform buildIfSupported4 = Jdk9Platform.INSTANCE.buildIfSupported();
|
|
if (buildIfSupported4 != null) {
|
|
return buildIfSupported4;
|
|
}
|
|
Platform buildIfSupported5 = Jdk8WithJettyBootPlatform.INSTANCE.buildIfSupported();
|
|
return buildIfSupported5 != null ? buildIfSupported5 : new Platform();
|
|
}
|
|
|
|
public final byte[] concatLengthPrefixed(List<? extends Protocol> protocols) {
|
|
Intrinsics.checkNotNullParameter(protocols, "protocols");
|
|
Buffer buffer = new Buffer();
|
|
for (String str : alpnProtocolNames(protocols)) {
|
|
buffer.writeByte(str.length());
|
|
buffer.writeUtf8(str);
|
|
}
|
|
return buffer.readByteArray();
|
|
}
|
|
}
|
|
|
|
static {
|
|
Companion companion = new Companion(null);
|
|
INSTANCE = companion;
|
|
platform = companion.findPlatform();
|
|
logger = Logger.getLogger(OkHttpClient.class.getName());
|
|
}
|
|
}
|