package com.l7tech.server.policy.assertion.credential.http;

import com.l7tech.message.Message;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.assertion.credential.CredentialFinderException;
import com.l7tech.policy.assertion.credential.LoginCredentials;
import com.l7tech.policy.assertion.credential.http.HttpClientCert;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.credential.ServerCredentialSourceAssertion;
import java.io.IOException;
import java.util.Map;

public class ServerHttpClientCert extends ServerCredentialSourceAssertion<HttpClientCert> {
   public static final String PARAM_HTTP_X509CERT;
   private static final String[] d;

   public ServerHttpClientCert(HttpClientCert var1) {
      super(var1);
   }

   @Override
   protected LoginCredentials findCredentials(Message param1, Map<String, String> param2) throws IOException, CredentialFinderException {
      // $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:
      // 00: aload 1
      // 01: ldc com/l7tech/message/HttpRequestKnob
      // 03: invokevirtual com/l7tech/message/Message.getKnob (Ljava/lang/Class;)Ljava/lang/Object;
      // 06: checkcast com/l7tech/message/HttpRequestKnob
      // 09: astore 3
      // 0a: aload 3
      // 0b: ifnonnull 1b
      // 0e: aload 0
      // 0f: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCLIENTCERT_NOT_HTTP Lcom/l7tech/gateway/common/audit/Messages$M;
      // 12: invokevirtual com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 15: aconst_null
      // 16: areturn
      // 17: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1a: athrow
      // 1b: aload 3
      // 1c: invokeinterface com/l7tech/message/HttpRequestKnob.getClientCertificate ()[Ljava/security/cert/X509Certificate; 1
      // 21: astore 4
      // 23: aload 4
      // 25: ifnull 36
      // 28: aload 4
      // 2a: arraylength
      // 2b: bipush 1
      // 2c: if_icmpge 43
      // 2f: goto 36
      // 32: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 35: athrow
      // 36: aload 0
      // 37: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCLIENTCERT_NO_CERT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 3a: invokevirtual com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 3d: aconst_null
      // 3e: areturn
      // 3f: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 42: athrow
      // 43: aload 4
      // 45: bipush 0
      // 46: aaload
      // 47: astore 5
      // 49: aload 5
      // 4b: ifnonnull 5f
      // 4e: new com/l7tech/policy/assertion/credential/CredentialFinderException
      // 51: dup
      // 52: getstatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.d [Ljava/lang/String;
      // 55: bipush 0
      // 56: aaload
      // 57: invokespecial com/l7tech/policy/assertion/credential/CredentialFinderException.<init> (Ljava/lang/String;)V
      // 5a: athrow
      // 5b: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 5e: athrow
      // 5f: aload 0
      // 60: getfield com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 63: checkcast com/l7tech/policy/assertion/credential/http/HttpClientCert
      // 66: invokevirtual com/l7tech/policy/assertion/credential/http/HttpClientCert.isCheckCertValidity ()Z
      // 69: ifeq 78
      // 6c: aload 5
      // 6e: invokevirtual java/security/cert/X509Certificate.checkValidity ()V
      // 71: goto 78
      // 74: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 77: athrow
      // 78: goto a7
      // 7b: astore 6
      // 7d: new com/l7tech/policy/assertion/credential/CredentialFinderException
      // 80: dup
      // 81: getstatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.d [Ljava/lang/String;
      // 84: astore 7
      // 86: aload 7
      // 88: bipush 3
      // 89: aaload
      // 8a: aload 6
      // 8c: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_FAILED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 8f: invokespecial com/l7tech/policy/assertion/credential/CredentialFinderException.<init> (Ljava/lang/String;Ljava/lang/Throwable;Lcom/l7tech/policy/assertion/AssertionStatus;)V
      // 92: athrow
      // 93: astore 6
      // 95: new com/l7tech/policy/assertion/credential/CredentialFinderException
      // 98: dup
      // 99: getstatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.d [Ljava/lang/String;
      // 9c: bipush 2
      // 9d: aaload
      // 9e: aload 6
      // a0: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_FAILED Lcom/l7tech/policy/assertion/AssertionStatus;
      // a3: invokespecial com/l7tech/policy/assertion/credential/CredentialFinderException.<init> (Ljava/lang/String;Ljava/lang/Throwable;Lcom/l7tech/policy/assertion/AssertionStatus;)V
      // a6: athrow
      // a7: new com/l7tech/security/token/http/TlsClientCertToken
      // aa: dup
      // ab: aload 5
      // ad: invokespecial com/l7tech/security/token/http/TlsClientCertToken.<init> (Ljava/security/cert/X509Certificate;)V
      // b0: astore 6
      // b2: aload 0
      // b3: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCLIENTCERT_FOUND Lcom/l7tech/gateway/common/audit/Messages$M;
      // b6: bipush 1
      // b7: anewarray 113
      // ba: dup
      // bb: bipush 0
      // bc: aload 6
      // be: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertCn ()Ljava/lang/String;
      // c1: ifnonnull d0
      // c4: aload 6
      // c6: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertDn ()Ljava/lang/String;
      // c9: goto d5
      // cc: invokestatic com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // cf: athrow
      // d0: aload 6
      // d2: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertCn ()Ljava/lang/String;
      // d5: aastore
      // d6: invokevirtual com/l7tech/server/policy/assertion/credential/http/ServerHttpClientCert.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // d9: aload 6
      // db: ldc com/l7tech/policy/assertion/SslAssertion
      // dd: invokestatic com/l7tech/policy/assertion/credential/LoginCredentials.makeLoginCredentials (Lcom/l7tech/security/token/SecurityToken;Ljava/lang/Class;)Lcom/l7tech/policy/assertion/credential/LoginCredentials;
      // e0: areturn
      // try (48 -> 55): 56 java/io/IOException
      // try (37 -> 46): 46 java/security/cert/CertificateExpiredException
      // try (19 -> 31): 31 java/security/cert/CertificateExpiredException
      // try (17 -> 23): 24 java/security/cert/CertificateExpiredException
      // try (5 -> 12): 12 java/security/cert/CertificateExpiredException
      // try (48 -> 58): 59 java/security/cert/CertificateExpiredException
      // try (48 -> 58): 71 java/security/cert/CertificateNotYetValidException
      // try (86 -> 98): 98 java/security/cert/CertificateExpiredException
   }

   @Override
   protected AssertionStatus checkCredentials(LoginCredentials var1, Map<String, String> var2) throws CredentialFinderException {
      return AssertionStatus.NONE;
   }

   @Override
   protected void challenge(PolicyEnforcementContext var1, Map<String, String> var2) {
   }

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

   static {
      String[] var5 = new String[4];
      int var3 = 0;
      String var2 = "I(\u0007^u.Ku)K[;mMo<\u0002\\'m<\u0000S'9O).\u000e@#!Kss\u0019W$8Kt)Ej`}\u0017D8\u0019F<+Gd<\u001fW";
      int var4 = "I(\u0007^u.Ku)K[;mMo<\u0002\\'m<\u0000S'9O).\u000e@#!Kss\u0019W$8Kt)Ej`}\u0017D8\u0019F<+Gd<\u001fW".length();
      char var1 = 18;
      int var7 = -1;

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

         while (true) {
            String var8 = c(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     d = var5;
                     PARAM_HTTP_X509CERT = d[1];
                     return;
                  }

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

                  var2 = "G2\u0001T8:\rG;\u001aE?(Dg?\u001cTv'^$0\u0007Ev7Hp~\u001eP:'I\u001eG2\u0001T8:\rG;\u001aE?(Dg?\u001cTv&Lw~\rI&'_a:";
                  var4 = "G2\u0001T8:\rG;\u001aE?(Dg?\u001cTv'^$0\u0007Ev7Hp~\u001eP:'I\u001eG2\u0001T8:\rG;\u001aE?(Dg?\u001cTv&Lw~\rI&'_a:".length();
                  var1 = '#';
                  var7 = -1;
            }

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

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

      return var10000;
   }

   private static String c(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 -> 94;
            case 1 -> 4;
            case 2 -> 50;
            case 3 -> 107;
            case 4 -> 12;
            case 5 -> 20;
            default -> 119;
         });
      }

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