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

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.credential.wss.WssBasic;
import com.l7tech.security.xml.SecurityTokenResolver;
import com.l7tech.server.message.AuthenticationContext;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.assertion.AbstractMessageTargetableServerAssertion;
import com.l7tech.util.Config;
import java.io.IOException;
import org.springframework.context.ApplicationContext;

public class ServerWssBasic extends AbstractMessageTargetableServerAssertion<WssBasic> {
   private final Config d;
   private final SecurityTokenResolver e;
   private static final String[] f;

   public ServerWssBasic(WssBasic var1, ApplicationContext var2) {
      super(var1);
      String[] var3 = f;
      this.d = (Config)var2.getBean(var3[2], Config.class);
      this.e = (SecurityTokenResolver)var2.getBean(var3[0]);
   }

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

      return super.checkRequest(var1);
   }

   @Override
   protected AssertionStatus doCheckRequest(PolicyEnforcementContext param1, Message param2, String param3, AuthenticationContext param4) throws IOException, PolicyAssertionException {
      // $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 2
      // 001: invokevirtual com/l7tech/message/Message.isSoap ()Z
      // 004: ifne 01e
      // 007: aload 0
      // 008: getstatic com/l7tech/gateway/common/audit/AssertionMessages.WSS_BASIC_NOT_SOAP Lcom/l7tech/gateway/common/audit/Messages$M;
      // 00b: bipush 1
      // 00c: anewarray 59
      // 00f: dup
      // 010: bipush 0
      // 011: aload 3
      // 012: aastore
      // 013: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 016: getstatic com/l7tech/policy/assertion/AssertionStatus.NOT_APPLICABLE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 019: areturn
      // 01a: invokestatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 01d: athrow
      // 01e: aload 0
      // 01f: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.isRequest ()Z
      // 022: ifeq 04c
      // 025: aload 0
      // 026: getfield com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.d Lcom/l7tech/util/Config;
      // 029: getstatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.f [Ljava/lang/String;
      // 02c: bipush 1
      // 02d: aaload
      // 02e: bipush 1
      // 02f: invokeinterface com/l7tech/util/Config.getBooleanProperty (Ljava/lang/String;Z)Z 3
      // 034: ifne 04c
      // 037: goto 03e
      // 03a: invokestatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 03d: athrow
      // 03e: aload 2
      // 03f: invokevirtual com/l7tech/message/Message.getSecurityKnob ()Lcom/l7tech/message/SecurityKnob;
      // 042: invokeinterface com/l7tech/message/SecurityKnob.getProcessorResult ()Lcom/l7tech/security/xml/processor/ProcessorResult; 1
      // 047: astore 5
      // 049: goto 05b
      // 04c: aload 2
      // 04d: aload 3
      // 04e: aload 0
      // 04f: getfield com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.e Lcom/l7tech/security/xml/SecurityTokenResolver;
      // 052: aload 0
      // 053: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.getAudit ()Lcom/l7tech/gateway/common/audit/Audit;
      // 056: 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;
      // 059: astore 5
      // 05b: goto 07e
      // 05e: astore 6
      // 060: new com/l7tech/util/CausedIOException
      // 063: dup
      // 064: aload 3
      // 065: getstatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.f [Ljava/lang/String;
      // 068: astore 13
      // 06a: aload 13
      // 06c: bipush 4
      // 06d: aaload
      // 06e: swap
      // 06f: aload 13
      // 071: bipush 3
      // 072: aaload
      // 073: 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" ]
      // 078: aload 6
      // 07a: invokespecial com/l7tech/util/CausedIOException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // 07d: athrow
      // 07e: aload 5
      // 080: ifnonnull 0b7
      // 083: aload 0
      // 084: getstatic com/l7tech/gateway/common/audit/AssertionMessages.WSS_BASIC_NO_CREDENTIALS Lcom/l7tech/gateway/common/audit/Messages$M;
      // 087: bipush 1
      // 088: anewarray 59
      // 08b: dup
      // 08c: bipush 0
      // 08d: aload 3
      // 08e: aastore
      // 08f: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 092: aload 0
      // 093: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.isRequest ()Z
      // 096: ifeq 0b3
      // 099: goto 0a0
      // 09c: invokestatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 09f: athrow
      // 0a0: aload 1
      // 0a1: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setAuthenticationMissing ()V 1
      // 0a6: aload 1
      // 0a7: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setRequestPolicyViolated ()V 1
      // 0ac: goto 0b3
      // 0af: invokestatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0b2: athrow
      // 0b3: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0b6: areturn
      // 0b7: aload 5
      // 0b9: invokeinterface com/l7tech/security/xml/processor/ProcessorResult.getXmlSecurityTokens ()[Lcom/l7tech/security/token/XmlSecurityToken; 1
      // 0be: astore 6
      // 0c0: aload 6
      // 0c2: astore 7
      // 0c4: aload 7
      // 0c6: arraylength
      // 0c7: istore 8
      // 0c9: bipush 0
      // 0ca: istore 9
      // 0cc: iload 9
      // 0ce: iload 8
      // 0d0: if_icmpge 103
      // 0d3: aload 7
      // 0d5: iload 9
      // 0d7: aaload
      // 0d8: astore 10
      // 0da: aload 10
      // 0dc: instanceof com/l7tech/security/token/UsernameToken
      // 0df: ifeq 0fd
      // 0e2: aload 10
      // 0e4: checkcast com/l7tech/security/token/UsernameToken
      // 0e7: astore 11
      // 0e9: aload 11
      // 0eb: ldc com/l7tech/policy/assertion/credential/wss/WssBasic
      // 0ed: invokestatic com/l7tech/policy/assertion/credential/LoginCredentials.makeLoginCredentials (Lcom/l7tech/security/token/SecurityToken;Ljava/lang/Class;)Lcom/l7tech/policy/assertion/credential/LoginCredentials;
      // 0f0: astore 12
      // 0f2: aload 4
      // 0f4: aload 12
      // 0f6: invokevirtual com/l7tech/server/message/AuthenticationContext.addCredentials (Lcom/l7tech/policy/assertion/credential/LoginCredentials;)V
      // 0f9: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0fc: areturn
      // 0fd: iinc 9 1
      // 100: goto 0cc
      // 103: aload 0
      // 104: getstatic com/l7tech/gateway/common/audit/AssertionMessages.WSS_BASIC_CANNOT_FIND_CREDENTIALS Lcom/l7tech/gateway/common/audit/Messages$M;
      // 107: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 10a: aload 0
      // 10b: invokevirtual com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.isRequest ()Z
      // 10e: ifeq 11e
      // 111: aload 1
      // 112: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setRequestPolicyViolated ()V 1
      // 117: goto 11e
      // 11a: invokestatic com/l7tech/server/policy/assertion/credential/wss/ServerWssBasic.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 11d: athrow
      // 11e: getstatic com/l7tech/policy/assertion/AssertionStatus.AUTH_REQUIRED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 121: areturn
      // try (0 -> 13): 44 org/xml/sax/SAXException
      // try (16 -> 27): 28 org/xml/sax/SAXException
      // try (0 -> 14): 14 java/io/IOException
      // try (16 -> 43): 44 org/xml/sax/SAXException
      // try (61 -> 75): 76 org/xml/sax/SAXException
      // try (63 -> 82): 83 org/xml/sax/SAXException
      // try (121 -> 129): 130 org/xml/sax/SAXException
   }

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

   static {
      String[] var5 = new String[5];
      int var3 = 0;
      String var2 = "g\f4W\u0006RXm=8I\u0011U~q\u001a8N\u0002^^-c\u001a$\f\u0004ICw\f$Q\u001bI\u0002q\u00076@\u0018^hq\u000f2P\u0006^HF\f&W\u0011HXD\u001b8A\u0011H_}\u00070\fg\f%T\u0011Io{\u00071K\u0013";
      int var4 = "g\f4W\u0006RXm=8I\u0011U~q\u001a8N\u0002^^-c\u001a$\f\u0004ICw\f$Q\u001bI\u0002q\u00076@\u0018^hq\u000f2P\u0006^HF\f&W\u0011HXD\u001b8A\u0011H_}\u00070\fg\f%T\u0011Io{\u00071K\u0013"
         .length();
      char var1 = 21;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 92;
         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) {
                     f = var5;
                     return;
                  }

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

                  var2 = "^$^*z: \u000ba^ox%a!Ivo{#5YmIow95Ys_#u{'\u0016vW*}\t4aI<x1$Y#";
                  var4 = "^$^*z: \u000ba^ox%a!Ivo{#5YmIow95Ys_#u{'\u0016vW*}\t4aI<x1$Y#".length();
                  var1 = '(';
                  var7 = -1;
            }

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

      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 -> 72;
            case 1 -> 53;
            case 2 -> 11;
            case 3 -> 126;
            case 4 -> 40;
            case 5 -> 103;
            default -> 112;
         });
      }

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