package com.l7tech.server.globalresources;

import com.l7tech.common.http.GenericHttpRequestParams;
import com.l7tech.common.io.SingleCertX509KeyManager;
import com.l7tech.common.io.SslSocketUtil;
import com.l7tech.gateway.common.resources.HttpConfiguration;
import com.l7tech.gateway.common.security.keystore.SsgKeyEntry;
import com.l7tech.gateway.common.security.password.SecurePassword;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.policy.assertion.HttpRoutingAssertion;
import com.l7tech.server.DefaultKey;
import com.l7tech.server.event.EntityClassEvent;
import com.l7tech.server.security.keystore.KeystoreFile;
import com.l7tech.server.security.keystore.SsgKeyStoreManager;
import com.l7tech.server.security.password.SecurePasswordManager;
import com.l7tech.server.transport.http.DefaultHttpCiphers;
import com.l7tech.server.util.PostStartupApplicationListener;
import com.l7tech.util.Config;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.Functions;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.Authenticator;
import java.net.ProxySelector;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.X509Certificate;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationEvent;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(description = "HTTP Configuration Cache", objectName = "l7tech:type=HttpConfigurationCache")
public class HttpConfigurationCache implements PostStartupApplicationListener, InitializingBean, PropertyChangeListener {
   private static final Logger a;
   private final Config b;
   private final DefaultHttpProxyManager c;
   private final HttpConfigurationManager d;
   private final SecurePasswordManager e;
   private final HostnameVerifier f;
   private final SsgKeyStoreManager g;
   private final DefaultKey h;
   private final X509TrustManager i;
   private final AtomicReference<SSLContext> j = new AtomicReference<>();
   private final AtomicReference<SSLContext> k = new AtomicReference<>();
   private final Map<m, SSLContext> l = new ConcurrentHashMap<>();
   private final AtomicReference<i> m = new AtomicReference<>();
   private static final Pattern n;
   private static final String[] o;

   public HttpConfigurationCache(
      Config var1,
      DefaultHttpProxyManager var2,
      HttpConfigurationManager var3,
      SecurePasswordManager var4,
      HostnameVerifier var5,
      SsgKeyStoreManager var6,
      DefaultKey var7,
      X509TrustManager var8
   ) {
      this.b = var1;
      this.c = var2;
      this.d = var3;
      this.e = var4;
      this.f = var5;
      this.g = var6;
      this.h = var7;
      this.i = var8;
   }

   public void configure(GenericHttpRequestParams param1, boolean param2) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 000: aload 1
      // 001: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.getTargetUrl ()Ljava/net/URL;
      // 004: astore 3
      // 005: aload 0
      // 006: getfield com/l7tech/server/globalresources/HttpConfigurationCache.m Ljava/util/concurrent/atomic/AtomicReference;
      // 009: invokevirtual java/util/concurrent/atomic/AtomicReference.get ()Ljava/lang/Object;
      // 00c: checkcast com/l7tech/server/globalresources/i
      // 00f: astore 4
      // 011: aconst_null
      // 012: astore 5
      // 014: bipush 0
      // 015: istore 6
      // 017: aload 3
      // 018: ifnull 145
      // 01b: aload 4
      // 01d: ifnull 145
      // 020: goto 027
      // 023: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 026: athrow
      // 027: aload 4
      // 029: aload 3
      // 02a: invokevirtual com/l7tech/server/globalresources/i.getHttpConfiguration (Ljava/net/URL;)Lcom/l7tech/gateway/common/resources/HttpConfiguration;
      // 02d: astore 7
      // 02f: aload 7
      // 031: ifnull 145
      // 034: bipush 1
      // 035: istore 6
      // 037: aload 7
      // 039: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getUsername ()Ljava/lang/String;
      // 03c: ifnull 0ba
      // 03f: aload 7
      // 041: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getNtlmDomain ()Ljava/lang/String;
      // 044: ifnull 0a0
      // 047: goto 04e
      // 04a: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 04d: athrow
      // 04e: aload 1
      // 04f: new com/l7tech/common/http/NtlmAuthentication
      // 052: dup
      // 053: aload 7
      // 055: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getUsername ()Ljava/lang/String;
      // 058: aload 4
      // 05a: aload 7
      // 05c: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getPasswordGoid ()Lcom/l7tech/objectmodel/Goid;
      // 05f: invokevirtual com/l7tech/server/globalresources/i.getPassword (Lcom/l7tech/objectmodel/Goid;)[C
      // 062: aload 7
      // 064: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getNtlmDomain ()Ljava/lang/String;
      // 067: aload 7
      // 069: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getNtlmHost ()Ljava/lang/String;
      // 06c: ifnonnull 092
      // 06f: goto 076
      // 072: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 075: athrow
      // 076: aload 0
      // 077: getfield com/l7tech/server/globalresources/HttpConfigurationCache.b Lcom/l7tech/util/Config;
      // 07a: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 07d: bipush 7
      // 07f: aaload
      // 080: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 083: bipush 8
      // 085: aaload
      // 086: invokeinterface com/l7tech/util/Config.getProperty (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; 3
      // 08b: goto 097
      // 08e: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 091: athrow
      // 092: aload 7
      // 094: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getNtlmHost ()Ljava/lang/String;
      // 097: invokespecial com/l7tech/common/http/NtlmAuthentication.<init> (Ljava/lang/String;[CLjava/lang/String;Ljava/lang/String;)V
      // 09a: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setNtlmAuthentication (Lcom/l7tech/common/http/NtlmAuthentication;)V
      // 09d: goto 0ba
      // 0a0: aload 1
      // 0a1: new java/net/PasswordAuthentication
      // 0a4: dup
      // 0a5: aload 7
      // 0a7: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getUsername ()Ljava/lang/String;
      // 0aa: aload 4
      // 0ac: aload 7
      // 0ae: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getPasswordGoid ()Lcom/l7tech/objectmodel/Goid;
      // 0b1: invokevirtual com/l7tech/server/globalresources/i.getPassword (Lcom/l7tech/objectmodel/Goid;)[C
      // 0b4: invokespecial java/net/PasswordAuthentication.<init> (Ljava/lang/String;[C)V
      // 0b7: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setPasswordAuthentication (Ljava/net/PasswordAuthentication;)V
      // 0ba: aload 0
      // 0bb: aload 7
      // 0bd: aload 1
      // 0be: invokevirtual com/l7tech/server/globalresources/HttpConfigurationCache.a (Lcom/l7tech/gateway/common/resources/HttpConfiguration;Lcom/l7tech/common/http/GenericHttpRequestParams;)V
      // 0c1: goto 0f4
      // 0c4: astore 8
      // 0c6: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.a Ljava/util/logging/Logger;
      // 0c9: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 0cc: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 0cf: astore 9
      // 0d1: aload 9
      // 0d3: bipush 0
      // 0d4: aaload
      // 0d5: aload 8
      // 0d7: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 0da: goto 0f4
      // 0dd: astore 8
      // 0df: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.a Ljava/util/logging/Logger;
      // 0e2: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 0e5: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 0e8: astore 9
      // 0ea: aload 9
      // 0ec: bipush 11
      // 0ee: aaload
      // 0ef: aload 8
      // 0f1: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 0f4: aload 1
      // 0f5: aload 7
      // 0f7: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getConnectTimeout ()I
      // 0fa: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setConnectionTimeout (I)V
      // 0fd: aload 1
      // 0fe: aload 7
      // 100: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getReadTimeout ()I
      // 103: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setReadTimeout (I)V
      // 106: aload 1
      // 107: aload 7
      // 109: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.isFollowRedirects ()Z
      // 10c: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setFollowRedirects (Z)V
      // 10f: getstatic com/l7tech/server/globalresources/h.a [I
      // 112: aload 7
      // 114: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getProxyUse ()Lcom/l7tech/gateway/common/resources/HttpConfiguration$Option;
      // 117: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration$Option.ordinal ()I
      // 11a: iaload
      // 11b: lookupswitch 42 2 1 25 2 35
      // 134: aload 4
      // 136: getfield com/l7tech/server/globalresources/i.a Lcom/l7tech/gateway/common/resources/HttpProxyConfiguration;
      // 139: astore 5
      // 13b: goto 145
      // 13e: aload 7
      // 140: invokevirtual com/l7tech/gateway/common/resources/HttpConfiguration.getProxyConfiguration ()Lcom/l7tech/gateway/common/resources/HttpProxyConfiguration;
      // 143: astore 5
      // 145: iload 6
      // 147: ifne 1af
      // 14a: aload 0
      // 14b: iload 2
      // 14c: aload 1
      // 14d: invokevirtual com/l7tech/server/globalresources/HttpConfigurationCache.a (ZLcom/l7tech/common/http/GenericHttpRequestParams;)Ljavax/net/ssl/SSLContext;
      // 150: pop
      // 151: goto 19b
      // 154: astore 7
      // 156: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.a Ljava/util/logging/Logger;
      // 159: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 15c: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 15f: astore 9
      // 161: aload 9
      // 163: bipush 11
      // 165: aaload
      // 166: aload 7
      // 168: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 16b: goto 19b
      // 16e: astore 7
      // 170: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.a Ljava/util/logging/Logger;
      // 173: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 176: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 179: astore 9
      // 17b: aload 9
      // 17d: bipush 11
      // 17f: aaload
      // 180: aload 7
      // 182: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 185: goto 19b
      // 188: astore 7
      // 18a: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.a Ljava/util/logging/Logger;
      // 18d: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 190: getstatic com/l7tech/server/globalresources/HttpConfigurationCache.o [Ljava/lang/String;
      // 193: bipush 11
      // 195: aaload
      // 196: aload 7
      // 198: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 19b: aload 4
      // 19d: ifnull 1ac
      // 1a0: aload 4
      // 1a2: getfield com/l7tech/server/globalresources/i.a Lcom/l7tech/gateway/common/resources/HttpProxyConfiguration;
      // 1a5: goto 1ad
      // 1a8: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 1ab: athrow
      // 1ac: aconst_null
      // 1ad: astore 5
      // 1af: aload 1
      // 1b0: aload 0
      // 1b1: getfield com/l7tech/server/globalresources/HttpConfigurationCache.f Ljavax/net/ssl/HostnameVerifier;
      // 1b4: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setHostnameVerifier (Ljavax/net/ssl/HostnameVerifier;)V
      // 1b7: aload 5
      // 1b9: ifnull 221
      // 1bc: aload 5
      // 1be: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getHost ()Ljava/lang/String;
      // 1c1: ifnull 221
      // 1c4: goto 1cb
      // 1c7: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 1ca: athrow
      // 1cb: aload 1
      // 1cc: aload 5
      // 1ce: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getHost ()Ljava/lang/String;
      // 1d1: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setProxyHost (Ljava/lang/String;)V
      // 1d4: aload 1
      // 1d5: aload 5
      // 1d7: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getPort ()I
      // 1da: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setProxyPort (I)V
      // 1dd: aload 5
      // 1df: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getUsername ()Ljava/lang/String;
      // 1e2: ifnull 21c
      // 1e5: goto 1ec
      // 1e8: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 1eb: athrow
      // 1ec: aload 5
      // 1ee: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getPasswordGoid ()Lcom/l7tech/objectmodel/Goid;
      // 1f1: ifnull 21c
      // 1f4: goto 1fb
      // 1f7: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 1fa: athrow
      // 1fb: aload 1
      // 1fc: new java/net/PasswordAuthentication
      // 1ff: dup
      // 200: aload 5
      // 202: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getUsername ()Ljava/lang/String;
      // 205: aload 4
      // 207: aload 5
      // 209: invokevirtual com/l7tech/gateway/common/resources/HttpProxyConfiguration.getPasswordGoid ()Lcom/l7tech/objectmodel/Goid;
      // 20c: invokevirtual com/l7tech/server/globalresources/i.getPassword (Lcom/l7tech/objectmodel/Goid;)[C
      // 20f: invokespecial java/net/PasswordAuthentication.<init> (Ljava/lang/String;[C)V
      // 212: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setProxyAuthentication (Ljava/net/PasswordAuthentication;)V
      // 215: goto 221
      // 218: invokestatic com/l7tech/server/globalresources/HttpConfigurationCache.a (Ljava/security/GeneralSecurityException;)Ljava/security/GeneralSecurityException;
      // 21b: athrow
      // 21c: aload 1
      // 21d: aconst_null
      // 21e: invokevirtual com/l7tech/common/http/GenericHttpRequestParams.setProxyAuthentication (Ljava/net/PasswordAuthentication;)V
      // 221: return
      // try (36 -> 63): 63 java/security/NoSuchAlgorithmException
      // try (30 -> 50): 51 java/security/NoSuchAlgorithmException
      // try (27 -> 33): 34 java/security/NoSuchAlgorithmException
      // try (12 -> 16): 17 java/security/NoSuchAlgorithmException
      // try (81 -> 85): 86 java/security/NoSuchAlgorithmException
      // try (81 -> 85): 97 java/security/KeyManagementException
      // try (134 -> 139): 140 java/security/NoSuchAlgorithmException
      // try (134 -> 139): 151 java/security/KeyManagementException
      // try (134 -> 139): 162 java/io/IOException
      // try (170 -> 175): 175 java/security/NoSuchAlgorithmException
      // try (179 -> 188): 189 java/security/NoSuchAlgorithmException
      // try (185 -> 202): 203 java/security/NoSuchAlgorithmException
      // try (191 -> 208): 209 java/security/NoSuchAlgorithmException
      // try (205 -> 223): 223 java/security/NoSuchAlgorithmException
   }

   @Override
   public void propertyChange(PropertyChangeEvent var1) {
      String var10000 = var1.getPropertyName();
      String[] var2 = o;
      if (var10000.startsWith(var2[5])) {
         a.config(var2[10]);
         this.k.set(null);
      } else {
         this.a();
      }
   }

   @Override
   public void onApplicationEvent(ApplicationEvent var1) {
      if (var1 instanceof EntityClassEvent var2) {
         if (HttpConfiguration.class.isAssignableFrom(var2.getEntityClass()) || SecurePassword.class.isAssignableFrom(var2.getEntityClass())) {
            this.a();
         } else if (KeystoreFile.class.isAssignableFrom(var2.getEntityClass())) {
            this.k.set(null);
            this.l.clear();
         }
      }
   }

   public void afterPropertiesSet() {
      this.a();
      this.installProxySelector(new t(this.m));
      this.installAuthenticator(new s(this.m));
   }

   @ManagedOperation(description = "Rebuild HTTP Configuration Cache")
   public void resetCache() {
      this.a();
      this.j.set(null);
      this.k.set(null);
      this.l.clear();
   }

   @ManagedAttribute(description = "HTTP Configuration Cache Size", currencyTimeLimit = 5)
   public int getHttpConfigurationCacheSize() {
      i var1 = this.m.get();
      return var1 == null ? 0 : (Integer)Functions.reduce(var1.b.values(), 0, new f(this));
   }

   @ManagedAttribute(description = "SSL Socket Factory Cache Size", currencyTimeLimit = 5)
   public int getSSLSocketFactoryCacheSize() {
      return this.l.size();
   }

   @ManagedAttribute(description = "Password Cache Size", currencyTimeLimit = 5)
   public int getPasswordCacheSize() {
      i var1 = this.m.get();
      return var1 == null ? 0 : var1.c.size();
   }

   protected void installProxySelector(ProxySelector var1) {
      ProxySelector.setDefault(var1);
   }

   protected void installAuthenticator(Authenticator var1) {
      Authenticator.setDefault(var1);
   }

   private void a() {
      String[] var2 = o;
      a.config(var2[6]);

      try {
         this.m.set(new i(this.c.getDefaultHttpProxyConfiguration(), this.d.findAll(), this.e.findAll(), new g(this)));
      } catch (FindException var3) {
         a.log(Level.WARNING, o[4], var3);
      }
   }

   private void a(HttpConfiguration var1, GenericHttpRequestParams var2) throws NoSuchAlgorithmException, KeyManagementException {
      m var3 = new m(var1.getTlsKeyUse(), var1.getTlsVersion(), var1.getTlsKeystoreGoid(), var1.getTlsKeystoreAlias(), var1.getTlsCipherSuites());
      SSLContext var4 = this.l.get(var3);
      if (var4 == null) {
         try {
            switch (com.l7tech.server.globalresources.h.a[var1.getTlsKeyUse().ordinal()]) {
               case 2:
                  m var5 = new m(var1.getTlsKeyUse(), null, var1.getTlsKeystoreGoid(), var1.getTlsKeystoreAlias(), null);
                  Goid var6 = var1.getTlsKeystoreGoid();

                  String var10000;
                  label46: {
                     try {
                        if (var1.getTlsKeystoreAlias() == null) {
                           var10000 = "";
                           break label46;
                        }
                     } catch (KeyStoreException var15) {
                        throw a(var15);
                     }

                     var10000 = var1.getTlsKeystoreAlias();
                  }

                  String var7 = var10000;
                  var4 = this.l.get(var5);
                  if (var4 == null) {
                     String[] var25 = o;
                     var4 = SSLContext.getInstance(var25[9]);
                     int var8 = ConfigFactory.getIntProperty(HttpRoutingAssertion.PROP_SSL_SESSION_TIMEOUT, 600);
                     var4.getClientSessionContext().setSessionTimeout(var8);
                     SsgKeyEntry var9 = this.g.lookupKeyByKeyAlias(var7, var6);
                     X509Certificate[] var10 = var9.getCertificateChain();
                     PrivateKey var11 = var9.getPrivateKey();
                     KeyManager[] var12 = new KeyManager[]{new SingleCertX509KeyManager(var10, var11)};
                     var4.init(var12, new TrustManager[]{this.i}, null);
                     this.l.put(var5, var4);
                  }
                  break;
               case 3:
                  var4 = this.a(false, var2);
            }
         } catch (KeyStoreException var16) {
            String[] var24 = o;
            a.log(Level.WARNING, var24[1], var16);
         } catch (FindException var17) {
            String[] var23 = o;
            a.log(Level.WARNING, var23[3], var17);
         } catch (UnrecoverableKeyException var18) {
            String[] var22 = o;
            a.log(Level.WARNING, var22[3], var18);
         } catch (IOException var19) {
            String[] var13 = o;
            a.log(Level.WARNING, var13[3], var19);
         }

         if (var4 == null) {
            try {
               var4 = this.a(true, var2);
            } catch (IOException var14) {
               a.log(Level.WARNING, o[3], var14);
            }
         }

         this.l.put(var3, var4);
      }

      String[] var20 = SslSocketUtil.filterSelectedTLSVersion(var1.getTlsVersion(), SslSocketUtil.DEFAULT_SUPPORTED_TLS_VERSIONS);
      if (var20.length == 0) {
         var20 = SslSocketUtil.DEFAULT_SUPPORTED_TLS_VERSIONS_ARRAY;
      }

      var2.setSupportedProtocols(var20);
      String[] var21 = this.a(var1.getTlsCipherSuites());
      var2.setSupportedCiphers(var21);
      var2.setSslContext(var4);
   }

   private String[] a(String var1) {
      if (var1 == null) {
         var1 = DefaultHttpCiphers.getDefaultEnabledOutboundCipherSuites();
      }

      return n.split(var1.trim() + "," + SslSocketUtil.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
   }

   private SSLContext a(boolean var1, GenericHttpRequestParams var2) throws NoSuchAlgorithmException, KeyManagementException, IOException {
      AtomicReference var10000;
      label20: {
         try {
            if (var1) {
               var10000 = this.k;
               break label20;
            }
         } catch (NoSuchAlgorithmException var5) {
            throw a(var5);
         }

         var10000 = this.j;
      }

      AtomicReference var3 = var10000;
      SSLContext var4 = (SSLContext)var3.get();
      if (var4 == null) {
         var4 = this.a(var1);
         var3.compareAndSet(null, var4);
      }

      var2.setSslContext(var4);
      return var4;
   }

   private SSLContext a(boolean var1) throws NoSuchAlgorithmException, KeyManagementException {
      SSLContext var2 = SSLContext.getInstance(o[12]);
      int var3 = ConfigFactory.getIntProperty(HttpRoutingAssertion.PROP_SSL_SESSION_TIMEOUT, 600);

      SSLContext var10000;
      KeyManager[] var10001;
      label17: {
         try {
            var2.getClientSessionContext().setSessionTimeout(var3);
            var10000 = var2;
            if (var1) {
               var10001 = this.h.getClientSslKeyManagers();
               break label17;
            }
         } catch (NoSuchAlgorithmException var4) {
            throw a(var4);
         }

         var10001 = null;
      }

      var10000.init(var10001, new TrustManager[]{this.i}, null);
      return var2;
   }

   static {
      String[] var5 = new String[13];
      int var3 = 0;
      String var2 = "_;,I0*|h,?R+dx:\u001a\rjbipt=;^6$\u001a_;,I0*x\u007f=*O,m?q,'\u0006$em:\u001a\rjl\u0007F:t\n\u001ey5\u001a_;,I0*x\u007f=*O,m?q,'\u0006$em:\u001a\rjl!_;,I0*su(:O,m?R\u001d\nvbipt/7A7x~n 1Hl\bq,'u6em\u007f\u001f2\u001b;\u000f\u000ee~~ 0AbBKN\u0019~E-dys.+T#~vu'p\u000by%+U6omR&-R\tv&=G.bpi=\u0003N\u0005\r0S'(G.c{{=7H%*|{*6C&*LI\u0005~E-dk\u007f1*\u0006$em:-;@#\u007fsni5C;$";
      int var4 = "_;,I0*|h,?R+dx:\u001a\rjbipt=;^6$\u001a_;,I0*x\u007f=*O,m?q,'\u0006$em:\u001a\rjl\u0007F:t\n\u001ey5\u001a_;,I0*x\u007f=*O,m?q,'\u0006$em:\u001a\rjl!_;,I0*su(:O,m?R\u001d\nvbipt/7A7x~n 1Hl\bq,'u6em\u007f\u001f2\u001b;\u000f\u000ee~~ 0AbBKN\u0019~E-dys.+T#~vu'p\u000by%+U6omR&-R\tv&=G.bpi=\u0003N\u0005\r0S'(G.c{{=7H%*|{*6C&*LI\u0005~E-dk\u007f1*\u0006$em:-;@#\u007fsni5C;$"
         .length();
      char var1 = 27;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 75;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = a(var10000, b(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     o = var5;
                     a = Logger.getLogger(HttpConfigurationCache.class.getName());
                     n = Pattern.compile(o[2]);
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = ":^I,UO\u0019\rIZ7N\u0001\u001d_\u007fh\u000f\u0007\f\u0015\u0011X^;SA\u0003+`h";
                  var4 = ":^I,UO\u0019\rIZ7N\u0001\u001d_\u007fh\u000f\u0007\f\u0015\u0011X^;SA\u0003+`h".length();
                  var1 = 27;
                  var7 = -1;
            }

            var10000 = 46;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

   private static GeneralSecurityException a(GeneralSecurityException var0) {
      return var0;
   }

   private static char[] b(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 84);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 81;
            case 1 -> 2;
            case 2 -> 21;
            case 3 -> 109;
            case 4 -> 9;
            case 5 -> 65;
            default -> 84;
         });
      }

      return new String(var10001).intern();
   }
}
