149 lines
5.3 KiB
Java
149 lines
5.3 KiB
Java
|
package okhttp3.internal.platform;
|
||
|
|
||
|
import android.os.Build;
|
||
|
import android.security.NetworkSecurityPolicy;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import javax.net.ssl.SSLSocket;
|
||
|
import javax.net.ssl.SSLSocketFactory;
|
||
|
import javax.net.ssl.X509TrustManager;
|
||
|
import o.C14875gap;
|
||
|
import o.C14953gcr;
|
||
|
import o.C14957gcv;
|
||
|
import okhttp3.Protocol;
|
||
|
import okhttp3.internal.platform.android.Android10SocketAdapter;
|
||
|
import okhttp3.internal.platform.android.AndroidCertificateChainCleaner;
|
||
|
import okhttp3.internal.platform.android.AndroidSocketAdapter;
|
||
|
import okhttp3.internal.platform.android.BouncyCastleSocketAdapter;
|
||
|
import okhttp3.internal.platform.android.ConscryptSocketAdapter;
|
||
|
import okhttp3.internal.platform.android.DeferredSocketAdapter;
|
||
|
import okhttp3.internal.platform.android.SocketAdapter;
|
||
|
import okhttp3.internal.tls.CertificateChainCleaner;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class Android10Platform extends Platform {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final boolean isSupported;
|
||
|
private final List<SocketAdapter> socketAdapters;
|
||
|
|
||
|
public Android10Platform() {
|
||
|
SocketAdapter[] socketAdapterArr = {Android10SocketAdapter.Companion.buildIfSupported(), new DeferredSocketAdapter(AndroidSocketAdapter.Companion.getPlayProviderFactory()), new DeferredSocketAdapter(ConscryptSocketAdapter.Companion.getFactory()), new DeferredSocketAdapter(BouncyCastleSocketAdapter.Companion.getFactory())};
|
||
|
C14957gcv.e(socketAdapterArr, "");
|
||
|
C14957gcv.e(socketAdapterArr, "");
|
||
|
List list = (List) C14875gap.d((Object[]) socketAdapterArr, new ArrayList());
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (Object obj : list) {
|
||
|
if (((SocketAdapter) obj).isSupported()) {
|
||
|
arrayList.add(obj);
|
||
|
}
|
||
|
}
|
||
|
this.socketAdapters = arrayList;
|
||
|
}
|
||
|
|
||
|
@Override // okhttp3.internal.platform.Platform
|
||
|
public final X509TrustManager trustManager(SSLSocketFactory sSLSocketFactory) {
|
||
|
Object obj;
|
||
|
C14957gcv.e(sSLSocketFactory, "");
|
||
|
Iterator<T> it = this.socketAdapters.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
}
|
||
|
obj = it.next();
|
||
|
if (((SocketAdapter) obj).matchesSocketFactory(sSLSocketFactory)) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
SocketAdapter socketAdapter = (SocketAdapter) obj;
|
||
|
if (socketAdapter == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return socketAdapter.trustManager(sSLSocketFactory);
|
||
|
}
|
||
|
|
||
|
@Override // okhttp3.internal.platform.Platform
|
||
|
public final void configureTlsExtensions(SSLSocket sSLSocket, String str, List<? extends Protocol> list) {
|
||
|
Object obj;
|
||
|
C14957gcv.e(sSLSocket, "");
|
||
|
C14957gcv.e(list, "");
|
||
|
Iterator<T> it = this.socketAdapters.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
} else {
|
||
|
obj = it.next();
|
||
|
if (((SocketAdapter) obj).matchesSocket(sSLSocket)) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
SocketAdapter socketAdapter = (SocketAdapter) obj;
|
||
|
if (socketAdapter != null) {
|
||
|
socketAdapter.configureTlsExtensions(sSLSocket, str, list);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // okhttp3.internal.platform.Platform
|
||
|
public final String getSelectedProtocol(SSLSocket sSLSocket) {
|
||
|
Object obj;
|
||
|
C14957gcv.e(sSLSocket, "");
|
||
|
Iterator<T> it = this.socketAdapters.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
}
|
||
|
obj = it.next();
|
||
|
if (((SocketAdapter) obj).matchesSocket(sSLSocket)) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
SocketAdapter socketAdapter = (SocketAdapter) obj;
|
||
|
if (socketAdapter == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return socketAdapter.getSelectedProtocol(sSLSocket);
|
||
|
}
|
||
|
|
||
|
@Override // okhttp3.internal.platform.Platform
|
||
|
public final boolean isCleartextTrafficPermitted(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
return NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(str);
|
||
|
}
|
||
|
|
||
|
@Override // okhttp3.internal.platform.Platform
|
||
|
public final CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager x509TrustManager) {
|
||
|
C14957gcv.e(x509TrustManager, "");
|
||
|
AndroidCertificateChainCleaner buildIfSupported = AndroidCertificateChainCleaner.Companion.buildIfSupported(x509TrustManager);
|
||
|
return buildIfSupported == null ? super.buildCertificateChainCleaner(x509TrustManager) : buildIfSupported;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public final boolean isSupported() {
|
||
|
return Android10Platform.isSupported;
|
||
|
}
|
||
|
|
||
|
public final Platform buildIfSupported() {
|
||
|
if (isSupported()) {
|
||
|
return new Android10Platform();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(C14953gcr c14953gcr) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
isSupported = Platform.Companion.isAndroid() && Build.VERSION.SDK_INT >= 29;
|
||
|
}
|
||
|
}
|