package com.l7tech.policy.validator;

import com.l7tech.policy.assertion.Assertion;
import com.l7tech.policy.assertion.IdentityTagable;
import com.l7tech.policy.assertion.IdentityTargetable;
import com.l7tech.policy.assertion.RequestSwAAssertion;
import com.l7tech.policy.assertion.RequestXpathAssertion;
import com.l7tech.policy.assertion.ResponseXpathAssertion;
import com.l7tech.policy.assertion.SetsVariables;
import com.l7tech.policy.assertion.UsesVariables;
import com.l7tech.policy.assertion.WsiBspAssertion;
import com.l7tech.policy.assertion.WsspAssertion;
import com.l7tech.policy.assertion.xmlsec.WssDecorationConfig;
import com.l7tech.util.ConstructorInvocation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;

class h {
   private static final Map<Class<? extends Assertion>, Class<? extends AssertionValidator>> a;
   private static final Map<Class<? extends Assertion>, Object> b;
   private static Map<Class<? extends Assertion>, Constructor<AssertionValidator>> c;
   private static final String[] d;

   private h() {
   }

   static AssertionValidator a(Assertion param0) {
      // $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: ifnonnull 10
      // 04: new java/lang/IllegalArgumentException
      // 07: dup
      // 08: invokespecial java/lang/IllegalArgumentException.<init> ()V
      // 0b: athrow
      // 0c: invokestatic com/l7tech/policy/validator/h.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0f: athrow
      // 10: aload 0
      // 11: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 14: astore 1
      // 15: getstatic com/l7tech/policy/validator/h.c Ljava/util/Map;
      // 18: aload 1
      // 19: invokeinterface java/util/Map.get (Ljava/lang/Object;)Ljava/lang/Object; 2
      // 1e: checkcast java/lang/reflect/Constructor
      // 21: astore 2
      // 22: aload 2
      // 23: ifnull 44
      // 26: aload 0
      // 27: aload 2
      // 28: bipush 1
      // 29: anewarray 119
      // 2c: dup
      // 2d: bipush 0
      // 2e: aload 0
      // 2f: aastore
      // 30: invokevirtual java/lang/reflect/Constructor.newInstance ([Ljava/lang/Object;)Ljava/lang/Object;
      // 33: checkcast com/l7tech/policy/validator/AssertionValidator
      // 36: invokestatic com/l7tech/policy/validator/h.a (Lcom/l7tech/policy/assertion/Assertion;Lcom/l7tech/policy/validator/AssertionValidator;)Lcom/l7tech/policy/validator/AssertionValidator;
      // 39: areturn
      // 3a: astore 3
      // 3b: new java/lang/RuntimeException
      // 3e: dup
      // 3f: aload 3
      // 40: invokespecial java/lang/RuntimeException.<init> (Ljava/lang/Throwable;)V
      // 43: athrow
      // 44: getstatic com/l7tech/policy/validator/h.a Ljava/util/Map;
      // 47: aload 1
      // 48: invokeinterface java/util/Map.get (Ljava/lang/Object;)Ljava/lang/Object; 2
      // 4d: checkcast java/lang/Class
      // 50: astore 3
      // 51: aconst_null
      // 52: aload 3
      // 53: if_acmpne 9c
      // 56: getstatic com/l7tech/policy/validator/h.b Ljava/util/Map;
      // 59: aload 1
      // 5a: invokeinterface java/util/Map.containsKey (Ljava/lang/Object;)Z 2
      // 5f: ifeq 7a
      // 62: goto 69
      // 65: invokestatic com/l7tech/policy/validator/h.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 68: athrow
      // 69: aload 0
      // 6a: new com/l7tech/policy/validator/i
      // 6d: dup
      // 6e: aload 0
      // 6f: invokespecial com/l7tech/policy/validator/i.<init> (Lcom/l7tech/policy/assertion/Assertion;)V
      // 72: invokestatic com/l7tech/policy/validator/h.a (Lcom/l7tech/policy/assertion/Assertion;Lcom/l7tech/policy/validator/AssertionValidator;)Lcom/l7tech/policy/validator/AssertionValidator;
      // 75: areturn
      // 76: invokestatic com/l7tech/policy/validator/h.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 79: athrow
      // 7a: aload 0
      // 7b: invokevirtual com/l7tech/policy/assertion/Assertion.meta ()Lcom/l7tech/policy/assertion/AssertionMetadata;
      // 7e: getstatic com/l7tech/policy/validator/h.d [Ljava/lang/String;
      // 81: bipush 1
      // 82: aaload
      // 83: invokeinterface com/l7tech/policy/assertion/AssertionMetadata.get (Ljava/lang/String;)Ljava/lang/Object; 2
      // 88: checkcast java/lang/String
      // 8b: astore 4
      // 8d: aload 1
      // 8e: invokevirtual java/lang/Class.getClassLoader ()Ljava/lang/ClassLoader;
      // 91: aload 4
      // 93: invokevirtual java/lang/ClassLoader.loadClass (Ljava/lang/String;)Ljava/lang/Class;
      // 96: astore 3
      // 97: goto 9c
      // 9a: astore 5
      // 9c: aconst_null
      // 9d: aload 3
      // 9e: if_acmpne bf
      // a1: getstatic com/l7tech/policy/validator/h.b Ljava/util/Map;
      // a4: aload 1
      // a5: getstatic java/lang/Boolean.TRUE Ljava/lang/Boolean;
      // a8: invokeinterface java/util/Map.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 3
      // ad: pop
      // ae: aload 0
      // af: new com/l7tech/policy/validator/i
      // b2: dup
      // b3: aload 0
      // b4: invokespecial com/l7tech/policy/validator/i.<init> (Lcom/l7tech/policy/assertion/Assertion;)V
      // b7: invokestatic com/l7tech/policy/validator/h.a (Lcom/l7tech/policy/assertion/Assertion;Lcom/l7tech/policy/validator/AssertionValidator;)Lcom/l7tech/policy/validator/AssertionValidator;
      // ba: areturn
      // bb: invokestatic com/l7tech/policy/validator/h.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // be: athrow
      // bf: aload 0
      // c0: aload 3
      // c1: aload 0
      // c2: invokestatic com/l7tech/policy/validator/h.a (Ljava/lang/Class;Lcom/l7tech/policy/assertion/Assertion;)Lcom/l7tech/policy/validator/AssertionValidator;
      // c5: invokestatic com/l7tech/policy/validator/h.a (Lcom/l7tech/policy/assertion/Assertion;Lcom/l7tech/policy/validator/AssertionValidator;)Lcom/l7tech/policy/validator/AssertionValidator;
      // c8: areturn
      // c9: astore 4
      // cb: new java/lang/RuntimeException
      // ce: dup
      // cf: aload 4
      // d1: invokespecial java/lang/RuntimeException.<init> (Ljava/lang/Throwable;)V
      // d4: athrow
      // try (0 -> 6): 6 java/lang/Exception
      // try (18 -> 29): 30 java/lang/Exception
      // try (44 -> 58): 58 java/lang/Exception
      // try (41 -> 48): 49 java/lang/Exception
      // try (68 -> 73): 74 java/lang/ClassNotFoundException
      // try (75 -> 90): 90 java/lang/Exception
      // try (92 -> 97): 98 java/lang/Exception
   }

   private static AssertionValidator a(Class var0, Assertion var1) throws InstantiationException, InvocationTargetException, IllegalAccessException {
      Constructor var2 = ConstructorInvocation.findMatchingConstructor(var0, new Class[]{var1.getClass()});

      try {
         if (var2 != null) {
            c.put((Class<? extends Assertion>)var1.getClass(), var2);
            return (AssertionValidator)var2.newInstance(var1);
         }
      } catch (InstantiationException var3) {
         throw a(var3);
      }

      throw new RuntimeException(d[0] + var0);
   }

   private static AssertionValidator a(Assertion var0, AssertionValidator var1) {
      AssertionValidator var2 = var1;
      if (var0 instanceof UsesVariables) {
         var2 = new SequenceValidator(var2, new VariableUseValidator(var0));
      }

      if (var0 instanceof SetsVariables) {
         var2 = new SequenceValidator(var2, new VariableSetValidator(var0));
      }

      if (var0 instanceof WssDecorationConfig) {
         var2 = new SequenceValidator(var2, new WssDecorationConfigAssertionValidator(var0));
      }

      if (var0 instanceof IdentityTargetable) {
         var2 = new SequenceValidator(var2, new IdentityTargetableAssertionValidator(var0));
      }

      if (var0 instanceof IdentityTagable) {
         var2 = new SequenceValidator(var2, new IdentityTagAssertionValidator(var0));
      }

      return var2;
   }

   static {
      String[] var5 = new String[2];
      int var3 = 0;
      String var2 = "#>e\u00153T=\f0h\u001a(E=\u0005'{\u001e?Tx\u0004\u007fc\u001e|Cr\u000e,\u007f\t)Ci\u000f-+\u00122\u0000\u0018\u00100g\u0012?YK\u00013b\u001f=Tr\u0012\u001cg\u001a/Ss\u00012n";
      int var4 = "#>e\u00153T=\f0h\u001a(E=\u0005'{\u001e?Tx\u0004\u007fc\u001e|Cr\u000e,\u007f\t)Ci\u000f-+\u00122\u0000\u0018\u00100g\u0012?YK\u00013b\u001f=Tr\u0012\u001cg\u001a/Ss\u00012n"
         .length();
      char var1 = ')';
      int var0 = -1;

      while (true) {
         String var10002 = a(102, a(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            d = var5;
            a = new HashMap<>();
            b = Collections.synchronizedMap(new WeakHashMap<>());
            a.put(RequestXpathAssertion.class, XpathBasedAssertionValidator.class);
            a.put(ResponseXpathAssertion.class, XpathBasedAssertionValidator.class);
            a.put(RequestSwAAssertion.class, SwaRequestAssertionValidator.class);
            a.put(WsiBspAssertion.class, WsiBspAssertionValidator.class);
            a.put(WsspAssertion.class, WsspAssertionValidator.class);
            c = Collections.synchronizedMap(new WeakHashMap<>());
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

   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] ^ 123);
      }

      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 -> 6;
            case 1 -> 57;
            case 2 -> 109;
            case 3 -> 29;
            case 4 -> 58;
            case 5 -> 70;
            default -> 123;
         });
      }

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