package com.l7tech.server.policy.custom;

import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.policy.assertion.ext.CustomAssertion;
import com.l7tech.policy.assertion.ext.CustomAuditor;
import com.l7tech.policy.assertion.ext.ServiceInvocation;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CustomAuditorImpl implements CustomAuditor {
   private static final Logger a;
   private final Audit b;
   private static final String[] c;

   public CustomAuditorImpl(Audit var1) {
      if (var1 == null) {
         throw new IllegalArgumentException(c[0]);
      }

      this.b = var1;
   }

   public void auditInfo(CustomAssertion param1, String param2) {
      // $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 1
      // 01: ifnull 37
      // 04: aload 2
      // 05: ifnull 37
      // 08: goto 0f
      // 0b: invokestatic com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 0e: athrow
      // 0f: aload 0
      // 10: getfield com/l7tech/server/policy/custom/CustomAuditorImpl.b Lcom/l7tech/gateway/common/audit/Audit;
      // 13: getstatic com/l7tech/gateway/common/audit/AssertionMessages.CUSTOM_ASSERTION_INFO Lcom/l7tech/gateway/common/audit/Messages$M;
      // 16: bipush 2
      // 17: anewarray 12
      // 1a: dup
      // 1b: bipush 0
      // 1c: aload 0
      // 1d: aload 1
      // 1e: invokeinterface com/l7tech/policy/assertion/ext/CustomAssertion.getName ()Ljava/lang/String; 1
      // 23: invokevirtual com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/String;)Ljava/lang/String;
      // 26: aastore
      // 27: dup
      // 28: bipush 1
      // 29: aload 2
      // 2a: aastore
      // 2b: invokeinterface com/l7tech/gateway/common/audit/Audit.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V 3
      // 30: goto 37
      // 33: invokestatic com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 36: athrow
      // 37: return
      // try (0 -> 4): 5 java/lang/IllegalArgumentException
      // try (2 -> 24): 25 java/lang/IllegalArgumentException
   }

   public void auditWarning(CustomAssertion param1, String param2) {
      // $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 1
      // 01: ifnull 37
      // 04: aload 2
      // 05: ifnull 37
      // 08: goto 0f
      // 0b: invokestatic com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 0e: athrow
      // 0f: aload 0
      // 10: getfield com/l7tech/server/policy/custom/CustomAuditorImpl.b Lcom/l7tech/gateway/common/audit/Audit;
      // 13: getstatic com/l7tech/gateway/common/audit/AssertionMessages.CUSTOM_ASSERTION_WARN Lcom/l7tech/gateway/common/audit/Messages$M;
      // 16: bipush 2
      // 17: anewarray 12
      // 1a: dup
      // 1b: bipush 0
      // 1c: aload 0
      // 1d: aload 1
      // 1e: invokeinterface com/l7tech/policy/assertion/ext/CustomAssertion.getName ()Ljava/lang/String; 1
      // 23: invokevirtual com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/String;)Ljava/lang/String;
      // 26: aastore
      // 27: dup
      // 28: bipush 1
      // 29: aload 2
      // 2a: aastore
      // 2b: invokeinterface com/l7tech/gateway/common/audit/Audit.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V 3
      // 30: goto 37
      // 33: invokestatic com/l7tech/server/policy/custom/CustomAuditorImpl.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 36: athrow
      // 37: return
      // try (0 -> 4): 5 java/lang/IllegalArgumentException
      // try (2 -> 24): 25 java/lang/IllegalArgumentException
   }

   public void register(ServiceInvocation var1) {
      try {
         String[] var3 = c;
         Method var2 = ServiceInvocation.class.getDeclaredMethod(var3[2], CustomAuditor.class);
         var2.setAccessible(true);
         var2.invoke(var1, this);
      } catch (Exception var4) {
         a.log(Level.WARNING, c[1], var4);
      }
   }

   private String a(String var1) {
      try {
         if (var1 == null) {
            return "";
         }
      } catch (IllegalArgumentException var2) {
         throw a(var2);
      }

      return var1;
   }

   static {
      String[] var5 = new String[3];
      int var3 = 0;
      String var2 = "rR\u001c0z[93J\r*z\u0014%|SX;k\u0014%fK\u0014+VU\n6|\u00148vS\f0`SkrR\u001c0z[93A\u0017+.W>`S\u00174.U8`B\n-g[%=\u0010`B\f\u001a{G?|J9,j]?|U";
      int var4 = "rR\u001c0z[93J\r*z\u0014%|SX;k\u0014%fK\u0014+VU\n6|\u00148vS\f0`SkrR\u001c0z[93A\u0017+.W>`S\u00174.U8`B\n-g[%=\u0010`B\f\u001a{G?|J9,j]?|U"
         .length();
      char var1 = 24;
      int var0 = -1;

      while (true) {
         String var10002 = a(127, b(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            c = var5;
            a = Logger.getLogger(CustomAuditorImpl.class.getName());
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

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

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

      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 -> 108;
            case 1 -> 88;
            case 2 -> 7;
            case 3 -> 38;
            case 4 -> 113;
            case 5 -> 75;
            default -> 52;
         });
      }

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