package com.l7tech.server.policy.assertion;

import com.l7tech.message.TlsKnob;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.assertion.PolicyAssertionException;
import com.l7tech.policy.assertion.SslAssertion;
import com.l7tech.server.message.PolicyEnforcementContext;
import java.io.IOException;
import org.jetbrains.annotations.NotNull;

public class ServerSslAssertion extends AbstractServerAssertion<SslAssertion> {
   private static final String[] d;

   public ServerSslAssertion(SslAssertion var1) {
      super(var1);
   }

   @Override
   public AssertionStatus checkRequest(PolicyEnforcementContext param1) throws PolicyAssertionException, IOException {
      // $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: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getRequest ()Lcom/l7tech/message/Message; 1
      // 006: ldc com/l7tech/message/TlsKnob
      // 008: invokevirtual com/l7tech/message/Message.getKnob (Ljava/lang/Class;)Ljava/lang/Object;
      // 00b: checkcast com/l7tech/message/TlsKnob
      // 00e: astore 2
      // 00f: aload 2
      // 010: ifnull 02b
      // 013: aload 2
      // 014: invokeinterface com/l7tech/message/TlsKnob.isSecure ()Z 1
      // 019: ifeq 02b
      // 01c: goto 023
      // 01f: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 022: athrow
      // 023: bipush 1
      // 024: goto 02c
      // 027: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 02a: athrow
      // 02b: bipush 0
      // 02c: istore 3
      // 02d: aload 0
      // 02e: getfield com/l7tech/server/policy/assertion/ServerSslAssertion.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 031: checkcast com/l7tech/policy/assertion/SslAssertion
      // 034: invokevirtual com/l7tech/policy/assertion/SslAssertion.getOption ()Lcom/l7tech/policy/assertion/SslAssertion$Option;
      // 037: astore 5
      // 039: aload 5
      // 03b: getstatic com/l7tech/policy/assertion/SslAssertion.REQUIRED Lcom/l7tech/policy/assertion/SslAssertion$Option;
      // 03e: if_acmpne 09e
      // 041: aload 0
      // 042: getfield com/l7tech/server/policy/assertion/ServerSslAssertion.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 045: checkcast com/l7tech/policy/assertion/SslAssertion
      // 048: invokevirtual com/l7tech/policy/assertion/SslAssertion.isCredentialSource ()Z
      // 04b: istore 6
      // 04d: iload 3
      // 04e: ifeq 068
      // 051: iload 6
      // 053: ifeq 068
      // 056: goto 05d
      // 059: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 05c: athrow
      // 05d: aload 0
      // 05e: aload 2
      // 05f: aload 1
      // 060: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.a (Lcom/l7tech/message/TlsKnob;Lcom/l7tech/server/message/PolicyEnforcementContext;)Lcom/l7tech/policy/assertion/AssertionStatus;
      // 063: astore 4
      // 065: goto 09b
      // 068: iload 3
      // 069: ifeq 07b
      // 06c: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 06f: astore 4
      // 071: aload 0
      // 072: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_REQUIRED_PRESENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 075: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 078: goto 09b
      // 07b: iload 6
      // 07d: ifeq 08f
      // 080: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 083: astore 4
      // 085: aload 0
      // 086: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCREDS_AUTH_REQUIRED Lcom/l7tech/gateway/common/audit/Messages$M;
      // 089: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 08c: goto 09b
      // 08f: getstatic com/l7tech/policy/assertion/AssertionStatus.FALSIFIED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 092: astore 4
      // 094: aload 0
      // 095: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_REQUIRED_ABSENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 098: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 09b: goto 0ed
      // 09e: aload 5
      // 0a0: getstatic com/l7tech/policy/assertion/SslAssertion.FORBIDDEN Lcom/l7tech/policy/assertion/SslAssertion$Option;
      // 0a3: if_acmpne 0cf
      // 0a6: iload 3
      // 0a7: ifeq 0c0
      // 0aa: goto 0b1
      // 0ad: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0b0: athrow
      // 0b1: getstatic com/l7tech/policy/assertion/AssertionStatus.FALSIFIED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0b4: astore 4
      // 0b6: aload 0
      // 0b7: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_FORBIDDEN_PRESENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0ba: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 0bd: goto 0ed
      // 0c0: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0c3: astore 4
      // 0c5: aload 0
      // 0c6: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_FORBIDDEN_ABSENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0c9: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 0cc: goto 0ed
      // 0cf: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0d2: astore 4
      // 0d4: iload 3
      // 0d5: ifeq 0e6
      // 0d8: aload 0
      // 0d9: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_OPTIONAL_PRESENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0dc: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 0df: goto 0ed
      // 0e2: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0e5: athrow
      // 0e6: aload 0
      // 0e7: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SSL_OPTIONAL_ABSENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0ea: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 0ed: aload 4
      // 0ef: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0f2: if_acmpeq 102
      // 0f5: aload 1
      // 0f6: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setRequestPolicyViolated ()V 1
      // 0fb: goto 102
      // 0fe: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 101: athrow
      // 102: aload 4
      // 104: areturn
      // try (6 -> 11): 12 com/l7tech/policy/assertion/PolicyAssertionException
      // try (8 -> 16): 16 com/l7tech/policy/assertion/PolicyAssertionException
      // try (33 -> 37): 38 com/l7tech/policy/assertion/PolicyAssertionException
      // try (68 -> 73): 74 com/l7tech/policy/assertion/PolicyAssertionException
      // try (90 -> 96): 96 com/l7tech/policy/assertion/PolicyAssertionException
      // try (101 -> 106): 107 com/l7tech/policy/assertion/PolicyAssertionException
   }

   private AssertionStatus a(@NotNull TlsKnob param1, PolicyEnforcementContext param2) throws PolicyAssertionException, IOException {
      // $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: ifnonnull 00f
      // 004: bipush 0
      // 005: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.b (I)V
      // 008: goto 00f
      // 00b: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 00e: athrow
      // 00f: aload 2
      // 010: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getDefaultAuthenticationContext ()Lcom/l7tech/server/message/AuthenticationContext; 1
      // 015: astore 3
      // 016: aload 3
      // 017: invokevirtual com/l7tech/server/message/AuthenticationContext.getLastCredentials ()Lcom/l7tech/policy/assertion/credential/LoginCredentials;
      // 01a: astore 4
      // 01c: aload 4
      // 01e: ifnull 040
      // 021: aload 4
      // 023: invokevirtual com/l7tech/policy/assertion/credential/LoginCredentials.getCredentialSourceAssertion ()Ljava/lang/Class;
      // 026: aload 0
      // 027: getfield com/l7tech/server/policy/assertion/ServerSslAssertion.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 02a: checkcast com/l7tech/policy/assertion/SslAssertion
      // 02d: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 030: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 033: ifne 040
      // 036: goto 03d
      // 039: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 03c: athrow
      // 03d: aconst_null
      // 03e: astore 4
      // 040: aload 4
      // 042: ifnonnull 117
      // 045: aload 1
      // 046: invokeinterface com/l7tech/message/TlsKnob.getClientCertificate ()[Ljava/security/cert/X509Certificate; 1
      // 04b: astore 5
      // 04d: aload 5
      // 04f: ifnull 106
      // 052: aload 5
      // 054: arraylength
      // 055: ifle 106
      // 058: goto 05f
      // 05b: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 05e: athrow
      // 05f: aload 5
      // 061: bipush 0
      // 062: aaload
      // 063: ifnull 106
      // 066: goto 06d
      // 069: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 06c: athrow
      // 06d: new com/l7tech/security/token/http/TlsClientCertToken
      // 070: dup
      // 071: aload 5
      // 073: bipush 0
      // 074: aaload
      // 075: invokespecial com/l7tech/security/token/http/TlsClientCertToken.<init> (Ljava/security/cert/X509Certificate;)V
      // 078: astore 6
      // 07a: aload 6
      // 07c: ldc com/l7tech/policy/assertion/SslAssertion
      // 07e: invokestatic com/l7tech/policy/assertion/credential/LoginCredentials.makeLoginCredentials (Lcom/l7tech/security/token/SecurityToken;Ljava/lang/Class;)Lcom/l7tech/policy/assertion/credential/LoginCredentials;
      // 081: astore 7
      // 083: aload 0
      // 084: getfield com/l7tech/server/policy/assertion/ServerSslAssertion.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 087: checkcast com/l7tech/policy/assertion/SslAssertion
      // 08a: invokevirtual com/l7tech/policy/assertion/SslAssertion.isCheckCertValidity ()Z
      // 08d: ifeq 0d5
      // 090: aload 5
      // 092: bipush 0
      // 093: aaload
      // 094: invokevirtual java/security/cert/X509Certificate.checkValidity ()V
      // 097: goto 0d5
      // 09a: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 09d: athrow
      // 09e: astore 8
      // 0a0: aload 0
      // 0a1: getstatic com/l7tech/gateway/common/audit/AssertionMessages.EXCEPTION_INFO_WITH_MORE_INFO Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0a4: bipush 1
      // 0a5: anewarray 235
      // 0a8: dup
      // 0a9: bipush 0
      // 0aa: aload 8
      // 0ac: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 0af: invokevirtual java/lang/Class.getSimpleName ()Ljava/lang/String;
      // 0b2: aload 8
      // 0b4: invokestatic com/l7tech/util/ExceptionUtils.getMessage (Ljava/lang/Throwable;)Ljava/lang/String;
      // 0b7: getstatic com/l7tech/server/policy/assertion/ServerSslAssertion.d [Ljava/lang/String;
      // 0ba: bipush 4
      // 0bb: aaload
      // 0bc: swap
      // 0bd: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001\u0001" ]
      // 0c2: aastore
      // 0c3: aload 8
      // 0c5: invokestatic com/l7tech/util/ExceptionUtils.getDebugException (Ljava/lang/Throwable;)Ljava/lang/Throwable;
      // 0c8: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;Ljava/lang/Throwable;)V
      // 0cb: aload 2
      // 0cc: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setRequestPolicyViolated ()V 1
      // 0d1: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_FAILED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0d4: areturn
      // 0d5: aload 0
      // 0d6: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCLIENTCERT_FOUND Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0d9: bipush 1
      // 0da: anewarray 235
      // 0dd: dup
      // 0de: bipush 0
      // 0df: aload 6
      // 0e1: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertCn ()Ljava/lang/String;
      // 0e4: ifnonnull 0f3
      // 0e7: aload 6
      // 0e9: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertDn ()Ljava/lang/String;
      // 0ec: goto 0f8
      // 0ef: invokestatic com/l7tech/server/policy/assertion/ServerSslAssertion.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0f2: athrow
      // 0f3: aload 6
      // 0f5: invokevirtual com/l7tech/security/token/http/TlsClientCertToken.getCertCn ()Ljava/lang/String;
      // 0f8: aastore
      // 0f9: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 0fc: aload 3
      // 0fd: aload 7
      // 0ff: invokevirtual com/l7tech/server/message/AuthenticationContext.addCredentials (Lcom/l7tech/policy/assertion/credential/LoginCredentials;)V
      // 102: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 105: areturn
      // 106: aload 0
      // 107: getstatic com/l7tech/gateway/common/audit/AssertionMessages.HTTPCLIENTCERT_NO_CERT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 10a: invokevirtual com/l7tech/server/policy/assertion/ServerSslAssertion.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 10d: aload 2
      // 10e: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setAuthenticationMissing ()V 1
      // 113: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 116: areturn
      // 117: aload 3
      // 118: aload 4
      // 11a: invokevirtual com/l7tech/server/message/AuthenticationContext.addCredentials (Lcom/l7tech/policy/assertion/credential/LoginCredentials;)V
      // 11d: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 120: areturn
      // try (35 -> 45): 46 java/security/cert/CertificateExpiredException
      // try (33 -> 38): 39 java/security/cert/CertificateExpiredException
      // try (13 -> 23): 24 java/security/cert/CertificateExpiredException
      // try (0 -> 4): 5 java/security/cert/CertificateExpiredException
      // try (64 -> 68): 71 java/security/cert/CertificateExpiredException
      // try (64 -> 68): 71 java/security/cert/CertificateNotYetValidException
      // try (59 -> 69): 69 com/l7tech/policy/assertion/PolicyAssertionException
      // try (96 -> 108): 108 java/security/cert/CertificateExpiredException
   }

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

   static {
      String[] var5 = new String[5];
      int var3 = 0;
      String var2 = "\u0018V\u0012k':S-\u0004\u0013q8\u007f}\u0017K\u0001P?3QyT\u0014l+2X-A\u0007>mzN~\u0004\u001axjzNw\u0001\u0006>'*N-\u0004\u001bq>\u007f_<\u0004\u001bk&35:K\u00181&hI<G\u001d19:O/A\u00071:0Q0G\f1+,N<V\u0001w%1\u0012\nA\u0007h/-n*H4m9:O-M\u001ap\")V\u001a}/,N\u0018W6l/;X7P\u001c\u007f&\fR,V\u0016{\u000b,N<V\u0001w%1";
      int var4 = "\u0018V\u0012k':S-\u0004\u0013q8\u007f}\u0017K\u0001P?3QyT\u0014l+2X-A\u0007>mzN~\u0004\u001axjzNw\u0001\u0006>'*N-\u0004\u001bq>\u007f_<\u0004\u001bk&35:K\u00181&hI<G\u001d19:O/A\u00071:0Q0G\f1+,N<V\u0001w%1\u0012\nA\u0007h/-n*H4m9:O-M\u001ap\")V\u001a}/,N\u0018W6l/;X7P\u001c\u007f&\fR,V\u0016{\u000b,N<V\u0001w%1"
         .length();
      char var1 = '>';
      int var7 = -1;

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

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

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

                  var2 = "\bm#p\u0001\u0015z\u0002F!";
                  var4 = "\bm#p\u0001\u0015z\u0002F!".length();
                  var1 = 7;
                  var7 = -1;
            }

            var10000 = 41;
            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] ^ 49);
      }

      return var10000;
   }

   private static String b(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 -> 85;
            case 1 -> 40;
            case 2 -> 121;
            case 3 -> 18;
            case 4 -> 70;
            case 5 -> 83;
            default -> 49;
         });
      }

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