content: 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 mt.Log1F380D;
  import okhttp3.HttpUrl;
  import okhttp3.Protocol;
  import org.openjsse.javax.net.ssl.SSLParameters;
  import org.openjsse.net.ssl.OpenJSSE;
  
  @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\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})
  /* compiled from: 01DC */
  public final class OpenJSSEPlatform extends Platform {
      public static final Companion Companion;
      /* access modifiers changed from: private */
      public static final boolean isSupported;
      private final Provider provider;
  
      @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\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})
      /* compiled from: OpenJSSEPlatform.kt */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
  
          public final OpenJSSEPlatform buildIfSupported() {
              if (isSupported()) {
                  return new OpenJSSEPlatform((DefaultConstructorMarker) null);
              }
              return null;
          }
  
          public final boolean isSupported() {
              return OpenJSSEPlatform.isSupported;
          }
      }
  
      static {
          Companion companion = new Companion((DefaultConstructorMarker) null);
          Companion = companion;
          boolean z = false;
          try {
              Class.forName("org.openjsse.net.ssl.OpenJSSE", false, companion.getClass().getClassLoader());
              z = true;
          } catch (ClassNotFoundException e) {
          }
          isSupported = z;
      }
  
      private OpenJSSEPlatform() {
          this.provider = new OpenJSSE();
      }
  
      public /* synthetic */ OpenJSSEPlatform(DefaultConstructorMarker $constructor_marker) {
          this();
      }
  
      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) {
              SSLParameters sSLParameters = ((org.openjsse.javax.net.ssl.SSLSocket) sslSocket).getSSLParameters();
              if (sSLParameters instanceof SSLParameters) {
                  SSLParameters sSLParameters2 = sSLParameters;
                  Object[] array = Platform.Companion.alpnProtocolNames(protocols).toArray(new String[0]);
                  if (array != null) {
                      sSLParameters2.setApplicationProtocols((String[]) array);
                      ((org.openjsse.javax.net.ssl.SSLSocket) sslSocket).setSSLParameters(sSLParameters);
                      return;
                  }
                  throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
              }
              return;
          }
          super.configureTlsExtensions(sslSocket, hostname, protocols);
      }
  
      public String getSelectedProtocol(SSLSocket sslSocket) {
          Intrinsics.checkNotNullParameter(sslSocket, "sslSocket");
          if (!(sslSocket instanceof org.openjsse.javax.net.ssl.SSLSocket)) {
              return super.getSelectedProtocol(sslSocket);
          }
          String applicationProtocol = ((org.openjsse.javax.net.ssl.SSLSocket) sslSocket).getApplicationProtocol();
          if (applicationProtocol != null) {
              String str = applicationProtocol;
              switch (applicationProtocol.hashCode()) {
                  case 0:
                      if (applicationProtocol.equals(HttpUrl.FRAGMENT_ENCODE_SET)) {
                          String str2 = str;
                          break;
                      } else {
                          return str;
                      }
                  default:
                      return str;
              }
          }
          return null;
      }
  
      public SSLContext newSSLContext() {
          SSLContext instance = SSLContext.getInstance("TLSv1.3", this.provider);
          Intrinsics.checkNotNullExpressionValue(instance, "SSLContext.getInstance(\"TLSv1.3\", provider)");
          return instance;
      }
  
      public X509TrustManager platformTrustManager() {
          String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
          Log1F380D.a((Object) defaultAlgorithm);
          TrustManagerFactory instance = TrustManagerFactory.getInstance(defaultAlgorithm, this.provider);
          KeyStore keyStore = null;
          instance.init((KeyStore) null);
          Intrinsics.checkNotNullExpressionValue(instance, "factory");
          TrustManager[] trustManagers = instance.getTrustManagers();
          Intrinsics.checkNotNull(trustManagers);
          boolean z = true;
          if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
              z = false;
          }
          if (z) {
              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");
          }
          StringBuilder append = new StringBuilder().append("Unexpected default trust managers: ");
          String arrays = Arrays.toString(trustManagers);
          Log1F380D.a((Object) arrays);
          Intrinsics.checkNotNullExpressionValue(arrays, "java.util.Arrays.toString(this)");
          throw new IllegalStateException(append.append(arrays).toString().toString());
      }
  
      public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
          Intrinsics.checkNotNullParameter(sslSocketFactory, "sslSocketFactory");
          throw new UnsupportedOperationException("clientBuilder.sslSocketFactory(SSLSocketFactory) not supported with OpenJSSE");
      }
  }
  