package com.l7tech.policy.validator;

import com.l7tech.objectmodel.encass.EncapsulatedAssertionConfig;
import com.l7tech.policy.PolicyType;
import com.l7tech.policy.assertion.Assertion;
import com.l7tech.util.Either;
import com.l7tech.wsdl.SerializableWSDLLocator;
import com.l7tech.wsdl.Wsdl;
import com.l7tech.xml.soap.SoapVersion;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.wsdl.WSDLException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class PolicyValidationContext implements Serializable {
   private static final Logger logger;
   @NotNull
   private final PolicyType policyType;
   @Nullable
   private final String policyInternalTag;
   @Nullable
   private final String policyInternalSubTag;
   @Nullable
   private final SerializableWSDLLocator wsdlLocator;
   private final boolean soap;
   @Nullable
   private final SoapVersion soapVersion;
   private transient Map<Assertion, AssertionValidator> validatorMap = new HashMap<>();
   private transient Either<WSDLException, Wsdl> wsdl;
   private Set<String> permittedAssertionClasses;
   @Nullable
   private EncapsulatedAssertionConfig interfaceDescription;
   private Map<String, String> registeredCustomAssertionFeatureSets = new HashMap<>();
   static final long serialVersionUID = 4944427743985113443L;
   private static final String[] a;

   public PolicyValidationContext(
      @NotNull PolicyType var1, @Nullable String var2, @Nullable String var3, @Nullable Wsdl var4, boolean var5, @Nullable SoapVersion var6
   ) {
      this.policyType = var1;
      this.policyInternalTag = var2;
      this.policyInternalSubTag = var3;
      this.wsdlLocator = null;
      this.wsdl = var4 == null ? null : Either.right(var4);
      this.soap = var5;
      this.soapVersion = var6;
   }

   public PolicyValidationContext(
      @NotNull PolicyType var1, @Nullable String var2, @Nullable String var3, @Nullable SerializableWSDLLocator var4, boolean var5, @Nullable SoapVersion var6
   ) {
      this.policyType = var1;
      this.policyInternalTag = var2;
      this.policyInternalSubTag = var3;
      this.wsdlLocator = var4;
      this.soap = var5;
      this.soapVersion = var6;
   }

   @NotNull
   public PolicyType getPolicyType() {
      try {
         return this.policyType;
      } catch (IllegalArgumentException var1) {
         throw a(var1);
      }
   }

   @Nullable
   public String getPolicyInternalTag() {
      return this.policyInternalTag;
   }

   @Nullable
   public String getPolicyInternalSubTag() {
      return this.policyInternalSubTag;
   }

   @Nullable
   public Wsdl getWsdl() {
      // $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 0
      // 01: getfield com/l7tech/policy/validator/PolicyValidationContext.wsdl Lcom/l7tech/util/Either;
      // 04: ifnonnull 50
      // 07: aload 0
      // 08: getfield com/l7tech/policy/validator/PolicyValidationContext.wsdlLocator Lcom/l7tech/wsdl/SerializableWSDLLocator;
      // 0b: ifnull 50
      // 0e: goto 15
      // 11: invokestatic com/l7tech/policy/validator/PolicyValidationContext.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 14: athrow
      // 15: aload 0
      // 16: aload 0
      // 17: getfield com/l7tech/policy/validator/PolicyValidationContext.wsdlLocator Lcom/l7tech/wsdl/SerializableWSDLLocator;
      // 1a: invokestatic com/l7tech/wsdl/Wsdl.newInstance (Ljavax/wsdl/xml/WSDLLocator;)Lcom/l7tech/wsdl/Wsdl;
      // 1d: invokestatic com/l7tech/util/Either.right (Ljava/lang/Object;)Lcom/l7tech/util/Either;
      // 20: putfield com/l7tech/policy/validator/PolicyValidationContext.wsdl Lcom/l7tech/util/Either;
      // 23: goto 50
      // 26: invokestatic com/l7tech/policy/validator/PolicyValidationContext.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 29: athrow
      // 2a: astore 1
      // 2b: aload 0
      // 2c: aload 1
      // 2d: invokestatic com/l7tech/util/Either.left (Ljava/lang/Object;)Lcom/l7tech/util/Either;
      // 30: putfield com/l7tech/policy/validator/PolicyValidationContext.wsdl Lcom/l7tech/util/Either;
      // 33: getstatic com/l7tech/policy/validator/PolicyValidationContext.logger Ljava/util/logging/Logger;
      // 36: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // 39: aload 1
      // 3a: invokestatic com/l7tech/util/ExceptionUtils.getMessage (Ljava/lang/Throwable;)Ljava/lang/String;
      // 3d: getstatic com/l7tech/policy/validator/PolicyValidationContext.a [Ljava/lang/String;
      // 40: bipush 7
      // 42: aaload
      // 43: swap
      // 44: invokedynamic makeConcatWithConstants (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" ]
      // 49: aload 1
      // 4a: invokestatic com/l7tech/util/ExceptionUtils.getDebugException (Ljava/lang/Throwable;)Ljava/lang/Throwable;
      // 4d: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
      // 50: aload 0
      // 51: getfield com/l7tech/policy/validator/PolicyValidationContext.wsdl Lcom/l7tech/util/Either;
      // 54: ifnonnull 5f
      // 57: aconst_null
      // 58: goto 6c
      // 5b: invokestatic com/l7tech/policy/validator/PolicyValidationContext.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 5e: athrow
      // 5f: aload 0
      // 60: getfield com/l7tech/policy/validator/PolicyValidationContext.wsdl Lcom/l7tech/util/Either;
      // 63: invokevirtual com/l7tech/util/Either.toRightOption ()Lcom/l7tech/util/Option;
      // 66: invokevirtual com/l7tech/util/Option.toNull ()Ljava/lang/Object;
      // 69: checkcast com/l7tech/wsdl/Wsdl
      // 6c: areturn
      // try (0 -> 6): 7 javax/wsdl/WSDLException
      // try (9 -> 15): 18 javax/wsdl/WSDLException
      // try (3 -> 16): 16 java/lang/IllegalArgumentException
      // try (35 -> 40): 40 javax/wsdl/WSDLException
   }

   public boolean isSoap() {
      return this.soap;
   }

   @Nullable
   public SoapVersion getSoapVersion() {
      return this.soapVersion;
   }

   public void setPermittedAssertionClasses(@Nullable Set<String> var1) {
      this.permittedAssertionClasses = var1;
   }

   @Nullable
   public Set<String> getPermittedAssertionClasses() {
      return this.permittedAssertionClasses;
   }

   @Nullable
   public EncapsulatedAssertionConfig getInterfaceDescription() {
      return this.interfaceDescription;
   }

   public void setInterfaceDescription(@Nullable EncapsulatedAssertionConfig var1) {
      this.interfaceDescription = var1;
   }

   public Map<String, String> getRegisteredCustomAssertionFeatureSets() {
      return this.registeredCustomAssertionFeatureSets;
   }

   AssertionValidator getValidator(Assertion var1) {
      AssertionValidator var2 = this.validatorMap.get(var1);
      if (var2 == null) {
         var2 = h.a(var1);
         this.validatorMap.put(var1, var2);
      }

      return var2;
   }

   private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
      var1.defaultReadObject();
      this.validatorMap = new HashMap<>();
   }

   static {
      String[] var5 = new String[8];
      int var3 = 0;
      String var2 = "<\u0018\n\rf!*@?\u000b\u0010\\j^lQ\t\u0001fw]dQA\u0017<:A \u001c\u0011\u0017f?\\o\u0005D\u0016wkGr\u001fD\ngs^>A\u0003\u0003\u0011\u007fz\\tQ\u0002\u000b`?rN\u001e\u0010*gs^ \u0001\u0005\u0016srWt\u0014\u0016D5:A'Q\u000b\u00022:A.T\u0017D\u007fjAtQ\n\u000bf?PeQ\n\u0011~s\rg\u0014\u00104}s[c\b0\u001dbz3c\u001e\tK~(Fe\u0012\fKbp^i\u0012\u001dKd~^i\u0015\u0005\u0010}m\u001dP\u001e\b\rqfda\u001d\r\u0000sk[o\u001f'\u000b|kWx\u0005\np\u001e\b\rqffy\u0001\u0001";
      int var4 = "<\u0018\n\rf!*@?\u000b\u0010\\j^lQ\t\u0001fw]dQA\u0017<:A \u001c\u0011\u0017f?\\o\u0005D\u0016wkGr\u001fD\ngs^>A\u0003\u0003\u0011\u007fz\\tQ\u0002\u000b`?rN\u001e\u0010*gs^ \u0001\u0005\u0016srWt\u0014\u0016D5:A'Q\u000b\u00022:A.T\u0017D\u007fjAtQ\n\u000bf?PeQ\n\u0011~s\rg\u0014\u00104}s[c\b0\u001dbz3c\u001e\tK~(Fe\u0012\fKbp^i\u0012\u001dKd~^i\u0015\u0005\u0010}m\u001dP\u001e\b\rqfda\u001d\r\u0000sk[o\u001f'\u000b|kWx\u0005\np\u001e\b\rqffy\u0001\u0001"
         .length();
      char var1 = 6;
      int var7 = -1;

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

         while (true) {
            String var8 = a(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     a = var5;
                     logger = Logger.getLogger(PolicyValidationContext.class.getName());
                     return;
                  }

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

                  var2 = "\u0004yn,\u0019O!\u0002uk,\u0005\u00179\u000euz,\u0003\u00199\u000erbw\u001a\nz7yoj\u0016\u0001\u0003\u0006zjg\u0014\f<\bx@l\u001b\f0\u001fb\u0017\"dql\u0007X%\u0015y`f\u0006\u000b<\tq#T&<\u0019]6";
                  var4 = "\u0004yn,\u0019O!\u0002uk,\u0005\u00179\u000euz,\u0003\u00199\u000erbw\u001a\nz7yoj\u0016\u0001\u0003\u0006zjg\u0014\f<\bx@l\u001b\f0\u001fb\u0017\"dql\u0007X%\u0015y`f\u0006\u000b<\tq#T&<\u0019]6"
                     .length();
                  var1 = '3';
                  var7 = -1;
            }

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

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

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

      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 -> 37;
            case 1 -> 84;
            case 2 -> 65;
            case 3 -> 65;
            case 4 -> 55;
            case 5 -> 58;
            default -> 23;
         });
      }

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