package com.l7tech.server.policy.assertion.xmlsec;

import com.l7tech.gateway.common.audit.AssertionMessages;
import com.l7tech.message.Message;
import com.l7tech.policy.assertion.AssertionStatus;
import com.l7tech.policy.assertion.PolicyAssertionException;
import com.l7tech.policy.assertion.xmlsec.RequireWssSaml;
import com.l7tech.policy.assertion.xmlsec.SecurityHeaderAddressableSupport;
import com.l7tech.security.token.SamlSecurityToken;
import com.l7tech.security.xml.processor.ProcessorResult;
import com.l7tech.server.message.AuthenticationContext;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.util.Triple;
import java.io.IOException;
import org.jetbrains.annotations.NotNull;

public class ServerRequireWssSaml<AT extends RequireWssSaml> extends ServerRequireSaml<AT> {
   private static final String e;

   public ServerRequireWssSaml(AT var1) {
      super((AT)var1);
   }

   @Override
   public AssertionStatus checkRequest(PolicyEnforcementContext var1) throws IOException, PolicyAssertionException {
      try {
         if (!SecurityHeaderAddressableSupport.isLocalRecipient(this.assertion)) {
            this.logAndAudit(AssertionMessages.REQUESTWSS_NOT_FOR_US);
            return AssertionStatus.NONE;
         }
      } catch (IOException var2) {
         throw a(var2);
      }

      return super.checkRequest(var1);
   }

   @NotNull
   @Override
   protected Triple<AssertionStatus, ProcessorResult, SamlSecurityToken> getSamlSecurityTokenAndContext(
      Message param1, String param2, AuthenticationContext param3
   ) throws 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: invokevirtual com/l7tech/message/Message.isSoap ()Z
      // 004: ifne 027
      // 007: aload 0
      // 008: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SAML_AUTHN_STMT_REQUEST_NOT_SOAP Lcom/l7tech/gateway/common/audit/Messages$M;
      // 00b: bipush 1
      // 00c: anewarray 140
      // 00f: dup
      // 010: bipush 0
      // 011: aload 2
      // 012: aastore
      // 013: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 016: new com/l7tech/util/Triple
      // 019: dup
      // 01a: getstatic com/l7tech/policy/assertion/AssertionStatus.NOT_APPLICABLE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 01d: aconst_null
      // 01e: aconst_null
      // 01f: invokespecial com/l7tech/util/Triple.<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      // 022: areturn
      // 023: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 026: athrow
      // 027: goto 036
      // 02a: astore 4
      // 02c: new java/io/IOException
      // 02f: dup
      // 030: aload 4
      // 032: invokespecial java/io/IOException.<init> (Ljava/lang/Throwable;)V
      // 035: athrow
      // 036: aload 0
      // 037: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.isRequest ()Z
      // 03a: ifeq 062
      // 03d: aload 0
      // 03e: getfield com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.config Lcom/l7tech/util/Config;
      // 041: getstatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.e Ljava/lang/String;
      // 044: bipush 1
      // 045: invokeinterface com/l7tech/util/Config.getBooleanProperty (Ljava/lang/String;Z)Z 3
      // 04a: ifne 062
      // 04d: goto 054
      // 050: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 053: athrow
      // 054: aload 1
      // 055: invokevirtual com/l7tech/message/Message.getSecurityKnob ()Lcom/l7tech/message/SecurityKnob;
      // 058: invokeinterface com/l7tech/message/SecurityKnob.getProcessorResult ()Lcom/l7tech/security/xml/processor/ProcessorResult; 1
      // 05d: astore 4
      // 05f: goto 071
      // 062: aload 1
      // 063: aload 2
      // 064: aload 0
      // 065: getfield com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.securityTokenResolver Lcom/l7tech/security/xml/SecurityTokenResolver;
      // 068: aload 0
      // 069: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.getAudit ()Lcom/l7tech/gateway/common/audit/Audit;
      // 06c: invokestatic com/l7tech/server/util/WSSecurityProcessorUtils.getWssResults (Lcom/l7tech/message/Message;Ljava/lang/String;Lcom/l7tech/security/xml/SecurityTokenResolver;Lcom/l7tech/gateway/common/audit/Audit;)Lcom/l7tech/security/xml/processor/ProcessorResult;
      // 06f: astore 4
      // 071: aload 4
      // 073: ifnonnull 0ab
      // 076: aload 0
      // 077: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SAML_AUTHN_STMT_NO_TOKENS_PROCESSED Lcom/l7tech/gateway/common/audit/Messages$M;
      // 07a: bipush 1
      // 07b: anewarray 140
      // 07e: dup
      // 07f: bipush 0
      // 080: aload 2
      // 081: aastore
      // 082: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 085: aload 0
      // 086: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.isRequest ()Z
      // 089: ifeq 09e
      // 08c: goto 093
      // 08f: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 092: athrow
      // 093: aload 3
      // 094: invokevirtual com/l7tech/server/message/AuthenticationContext.setAuthenticationMissing ()V
      // 097: goto 09e
      // 09a: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 09d: athrow
      // 09e: new com/l7tech/util/Triple
      // 0a1: dup
      // 0a2: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0a5: aconst_null
      // 0a6: aconst_null
      // 0a7: invokespecial com/l7tech/util/Triple.<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      // 0aa: areturn
      // 0ab: aload 4
      // 0ad: invokeinterface com/l7tech/security/xml/processor/ProcessorResult.getXmlSecurityTokens ()[Lcom/l7tech/security/token/XmlSecurityToken; 1
      // 0b2: astore 5
      // 0b4: aload 5
      // 0b6: ifnonnull 0ee
      // 0b9: aload 0
      // 0ba: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SAML_AUTHN_STMT_NO_TOKENS_PROCESSED Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0bd: bipush 1
      // 0be: anewarray 140
      // 0c1: dup
      // 0c2: bipush 0
      // 0c3: aload 2
      // 0c4: aastore
      // 0c5: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 0c8: aload 0
      // 0c9: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.isRequest ()Z
      // 0cc: ifeq 0e1
      // 0cf: goto 0d6
      // 0d2: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0d5: athrow
      // 0d6: aload 3
      // 0d7: invokevirtual com/l7tech/server/message/AuthenticationContext.setAuthenticationMissing ()V
      // 0da: goto 0e1
      // 0dd: invokestatic com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0e0: athrow
      // 0e1: new com/l7tech/util/Triple
      // 0e4: dup
      // 0e5: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0e8: aconst_null
      // 0e9: aconst_null
      // 0ea: invokespecial com/l7tech/util/Triple.<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      // 0ed: areturn
      // 0ee: aconst_null
      // 0ef: astore 6
      // 0f1: aload 5
      // 0f3: astore 7
      // 0f5: aload 7
      // 0f7: arraylength
      // 0f8: istore 8
      // 0fa: bipush 0
      // 0fb: istore 9
      // 0fd: iload 9
      // 0ff: iload 8
      // 101: if_icmpge 14a
      // 104: aload 7
      // 106: iload 9
      // 108: aaload
      // 109: astore 10
      // 10b: aload 10
      // 10d: instanceof com/l7tech/security/token/SamlSecurityToken
      // 110: ifeq 144
      // 113: aload 10
      // 115: checkcast com/l7tech/security/token/SamlSecurityToken
      // 118: astore 11
      // 11a: aload 6
      // 11c: ifnull 140
      // 11f: aload 0
      // 120: getstatic com/l7tech/gateway/common/audit/AssertionMessages.SAML_AUTHN_STMT_MULTIPLE_SAML_ASSERTIONS_UNSUPPORTED Lcom/l7tech/gateway/common/audit/Messages$M;
      // 123: bipush 1
      // 124: anewarray 140
      // 127: dup
      // 128: bipush 0
      // 129: aload 2
      // 12a: aastore
      // 12b: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 12e: aload 0
      // 12f: invokevirtual com/l7tech/server/policy/assertion/xmlsec/ServerRequireWssSaml.getBadMessageStatus ()Lcom/l7tech/policy/assertion/AssertionStatus;
      // 132: astore 12
      // 134: new com/l7tech/util/Triple
      // 137: dup
      // 138: aload 12
      // 13a: aconst_null
      // 13b: aconst_null
      // 13c: invokespecial com/l7tech/util/Triple.<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      // 13f: areturn
      // 140: aload 11
      // 142: astore 6
      // 144: iinc 9 1
      // 147: goto 0fd
      // 14a: new com/l7tech/util/Triple
      // 14d: dup
      // 14e: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 151: aload 4
      // 153: aload 6
      // 155: invokespecial com/l7tech/util/Triple.<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
      // 158: areturn
      // try (0 -> 18): 22 org/xml/sax/SAXException
      // try (0 -> 19): 19 java/io/IOException
      // try (28 -> 37): 38 org/xml/sax/SAXException
      // try (53 -> 67): 68 org/xml/sax/SAXException
      // try (55 -> 72): 73 org/xml/sax/SAXException
      // try (85 -> 99): 100 org/xml/sax/SAXException
      // try (87 -> 104): 105 org/xml/sax/SAXException
   }

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

   static {
      String var10002 = d(
         67, c("\u0002Jju\u001d\u0012\u0007\u0016\\j(\u0002\u0012F\u0010Wx9\u0001\u0005,\u0010_|)\u001f\u0005\f'\\h.\b\u0013\u001c%Kv8\b\u0013\u001b\u001cW~")
      );
      byte var10001 = -1;
      e = var10002;
   }

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

      return var10000;
   }

   private static String d(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 -> 54;
            case 1 -> 122;
            case 2 -> 90;
            case 3 -> 24;
            case 4 -> 46;
            case 5 -> 35;
            default -> 43;
         });
      }

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