package com.l7tech.server.policy.assertion;

import com.l7tech.common.mime.ContentTypeHeader;
import com.l7tech.common.mime.NoSuchPartException;
import com.l7tech.common.mime.PartInfo;
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.Regex;
import com.l7tech.policy.variable.NoSuchVariableException;
import com.l7tech.server.message.ContextVariableBackedMessageUtils;
import com.l7tech.server.message.ContextVariableKnob;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.policy.variable.ExpandVariables;
import com.l7tech.util.Charsets;
import com.l7tech.util.Either;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Pair;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

public class ServerRegex extends AbstractServerAssertion<Regex> {
   private Exception d;
   private final Either<Pattern, String> e;
   private final String[] f;
   private final boolean g;
   private final int h;
   private final boolean i;
   private final boolean j;
   private final String k;
   private final boolean l;
   private static final String[] m;

   public ServerRegex(Regex var1) {
      super(var1);
      String var2 = var1.getRegex();
      this.l = this.assertion.isCaseInsensitive();
      this.g = this.assertion.isReplace();
      this.f = var1.getVariablesUsed();
      this.h = Math.abs(var1.getReplaceRepeatCount());
      this.i = var1.isIncludeEntireExpressionCapture();
      this.k = this.assertion.getCaptureVar();
      this.j = this.assertion.isFindAll();

      Either var3;
      try {
         if (this.assertion.isPatternContainsVariables()) {
            var3 = Either.right(var2);
         } else {
            var3 = Either.left(Pattern.compile(var2, this.a()));
         }
      } catch (Exception var5) {
         this.d = var5;
         var3 = null;
      }

      this.e = var3;
   }

   private int a() {
      byte var1 = 40;
      if (this.l) {
         var1 |= 2;
      }

      return var1;
   }

   @Override
   public AssertionStatus checkRequest(PolicyEnforcementContext var1) throws IOException, PolicyAssertionException {
      Pair var2 = this.a(var1);
      Pattern var3 = this.d(var1);

      try {
         if (this.assertion.getRegexVar() != null) {
            var1.setVariable(this.assertion.getRegexVar(), var3.pattern());
         }
      } catch (IOException var4) {
         throw a(var4);
      }

      try {
         if (this.g) {
            return this.a(var1, var3, (ai)var2.left, (aj)var2.right);
         }
      } catch (IOException var5) {
         throw a(var5);
      }

      return this.a(var1, var3.matcher(((ai)var2.left).getInput()));
   }

   private Pair<ai, aj> a(PolicyEnforcementContext var1) throws IOException {
      aj var3 = null;
      Message var4 = this.b(var1);
      int var5 = this.assertion.getMimePart();

      ai var2;
      try {
         PartInfo var6 = var4.getMimeKnob().getPart(var5);
         Charset var7 = this.a(var6);
         ContextVariableKnob var8 = (ContextVariableKnob)var4.getKnob(ContextVariableKnob.class);

         try {
            if (var8 != null) {
               var8.setOverrideEncoding(var7);
            }
         } catch (NoSuchPartException var9) {
            throw a(var9);
         }

         var2 = this.a(var6, var7);
         if (this.g) {
            var3 = this.b(var6, var7);
         }
      } catch (NoSuchPartException var10) {
         this.logAndAudit(AssertionMessages.REGEX_NO_SUCH_PART, Integer.toString(var5));
         throw new AssertionStatusException(var10);
      }

      return new Pair(var2, var3);
   }

   private ai a(PartInfo var1, Charset var2) {
      return new af(this, var1, var2);
   }

   private aj b(PartInfo var1, Charset var2) {
      return new ag(this, var1, var2);
   }

   private Charset a(PartInfo var1) {
      String var2 = this.assertion.getEncoding();

      Charset var3;
      label29: {
         label28: {
            try {
               if (var2 == null || var2.length() < 1) {
                  break label28;
               }
            } catch (UnsupportedCharsetException var6) {
               throw a(var6);
            }

            try {
               var3 = Charset.forName(var2);
               this.logAndAudit(AssertionMessages.REGEX_ENCODING_OVERRIDE, var2);
            } catch (UnsupportedCharsetException var5) {
               var3 = null;
            }
            break label29;
         }

         var3 = var1.getContentType().getEncoding();
      }

      if (var3 == null) {
         this.logAndAudit(AssertionMessages.REGEX_NO_ENCODING, Charsets.UTF8.name());
         var3 = Charsets.UTF8;
      }

      return var3;
   }

   private Message b(PolicyEnforcementContext param1) {
      // $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/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 04: checkcast com/l7tech/policy/assertion/Regex
      // 07: invokevirtual com/l7tech/policy/assertion/Regex.isAutoTarget ()Z
      // 0a: ifeq 31
      // 0d: aload 1
      // 0e: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.isPostRouting ()Z 1
      // 13: ifeq 2a
      // 16: goto 1d
      // 19: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1c: athrow
      // 1d: aload 1
      // 1e: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getResponse ()Lcom/l7tech/message/Message; 1
      // 23: goto 30
      // 26: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 29: athrow
      // 2a: aload 1
      // 2b: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getRequest ()Lcom/l7tech/message/Message; 1
      // 30: areturn
      // 31: getstatic com/l7tech/policy/assertion/TargetMessageType.OTHER Lcom/l7tech/policy/assertion/TargetMessageType;
      // 34: aload 0
      // 35: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 38: checkcast com/l7tech/policy/assertion/Regex
      // 3b: invokevirtual com/l7tech/policy/assertion/Regex.getTarget ()Lcom/l7tech/policy/assertion/TargetMessageType;
      // 3e: invokevirtual com/l7tech/policy/assertion/TargetMessageType.equals (Ljava/lang/Object;)Z
      // 41: ifeq 50
      // 44: aload 0
      // 45: aload 1
      // 46: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.c (Lcom/l7tech/server/message/PolicyEnforcementContext;)Lcom/l7tech/message/Message;
      // 49: goto 5e
      // 4c: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 4f: athrow
      // 50: aload 1
      // 51: aload 0
      // 52: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 55: checkcast com/l7tech/policy/assertion/MessageTargetable
      // 58: bipush 1
      // 59: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getTargetMessage (Lcom/l7tech/policy/assertion/MessageTargetable;Z)Lcom/l7tech/message/Message; 3
      // 5e: areturn
      // 5f: astore 2
      // 60: aload 0
      // 61: getstatic com/l7tech/gateway/common/audit/AssertionMessages.NO_SUCH_VARIABLE Lcom/l7tech/gateway/common/audit/Messages$M;
      // 64: bipush 1
      // 65: anewarray 252
      // 68: dup
      // 69: bipush 0
      // 6a: aload 2
      // 6b: invokevirtual com/l7tech/policy/variable/NoSuchVariableException.getVariable ()Ljava/lang/String;
      // 6e: aastore
      // 6f: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 72: new com/l7tech/server/policy/assertion/AssertionStatusException
      // 75: dup
      // 76: getstatic com/l7tech/policy/assertion/AssertionStatus.SERVER_ERROR Lcom/l7tech/policy/assertion/AssertionStatus;
      // 79: invokespecial com/l7tech/server/policy/assertion/AssertionStatusException.<init> (Lcom/l7tech/policy/assertion/AssertionStatus;)V
      // 7c: athrow
      // try (5 -> 14): 14 com/l7tech/policy/variable/NoSuchVariableException
      // try (0 -> 8): 9 com/l7tech/policy/variable/NoSuchVariableException
      // try (0 -> 18): 39 com/l7tech/policy/variable/NoSuchVariableException
      // try (19 -> 30): 30 com/l7tech/policy/variable/NoSuchVariableException
      // try (19 -> 38): 39 com/l7tech/policy/variable/NoSuchVariableException
   }

   private Message c(PolicyEnforcementContext var1) throws NoSuchVariableException {
      String var2 = this.assertion.getOtherTargetMessageVariable();

      try {
         if (var2 == null) {
            throw new IllegalArgumentException(m[2]);
         }
      } catch (NoSuchVariableException var8) {
         throw a(var8);
      }

      Object var3 = var1.getVariable(var2);

      try {
         if (var3 == null) {
            throw new NoSuchVariableException(var2, m[5]);
         }
      } catch (NoSuchVariableException var6) {
         throw a(var6);
      }

      try {
         if (var3 instanceof Message) {
            return (Message)var3;
         }
      } catch (NoSuchVariableException var7) {
         throw a(var7);
      }

      String var4;
      if (var3 instanceof CharSequence) {
         var4 = var3.toString();
      } else if (var3 instanceof AbstractCollection) {
         var4 = var3.toString();
      } else if (var3 instanceof Collection) {
         var4 = new ArrayList((Collection)var3).toString();
      } else if (var3 instanceof Object[] var5) {
         var4 = Arrays.asList(var5).toString();
      } else {
         var4 = var3.toString();
      }

      return ContextVariableBackedMessageUtils.createContextVariableBackedMessage(var1, var2, ContentTypeHeader.TEXT_DEFAULT, var4);
   }

   private AssertionStatus a(PolicyEnforcementContext param1, Matcher 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:
      // 000: aload 2
      // 001: invokevirtual java/util/regex/Matcher.find ()Z
      // 004: istore 3
      // 005: iload 3
      // 006: ifeq 075
      // 009: aload 0
      // 00a: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 00d: ifnull 075
      // 010: goto 017
      // 013: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 016: athrow
      // 017: new java/util/ArrayList
      // 01a: dup
      // 01b: invokespecial java/util/ArrayList.<init> ()V
      // 01e: astore 4
      // 020: aload 0
      // 021: aload 4
      // 023: aload 2
      // 024: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/util/List;Ljava/util/regex/Matcher;)V
      // 027: aload 0
      // 028: getfield com/l7tech/server/policy/assertion/ServerRegex.j Z
      // 02b: ifeq 05a
      // 02e: new java/lang/StringBuffer
      // 031: dup
      // 032: invokespecial java/lang/StringBuffer.<init> ()V
      // 035: astore 6
      // 037: aload 2
      // 038: invokevirtual java/util/regex/Matcher.find ()Z
      // 03b: istore 5
      // 03d: iload 5
      // 03f: ifne 049
      // 042: goto 053
      // 045: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 048: athrow
      // 049: aload 0
      // 04a: aload 4
      // 04c: aload 2
      // 04d: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/util/List;Ljava/util/regex/Matcher;)V
      // 050: goto 037
      // 053: aload 2
      // 054: aload 6
      // 056: invokevirtual java/util/regex/Matcher.appendTail (Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer;
      // 059: pop
      // 05a: aload 1
      // 05b: aload 0
      // 05c: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 05f: aload 4
      // 061: aload 4
      // 063: invokeinterface java/util/List.size ()I 1
      // 068: anewarray 252
      // 06b: invokeinterface java/util/List.toArray ([Ljava/lang/Object;)[Ljava/lang/Object; 2
      // 070: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setVariable (Ljava/lang/String;Ljava/lang/Object;)V 3
      // 075: aload 0
      // 076: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 079: checkcast com/l7tech/policy/assertion/Regex
      // 07c: invokevirtual com/l7tech/policy/assertion/Regex.isProceedIfPatternMatches ()Z
      // 07f: ifeq 0e5
      // 082: iload 3
      // 083: ifeq 0c9
      // 086: goto 08d
      // 089: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 08c: athrow
      // 08d: aload 0
      // 08e: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 091: getstatic java/util/logging/Level.FINE Ljava/util/logging/Level;
      // 094: invokevirtual java/util/logging/Logger.isLoggable (Ljava/util/logging/Level;)Z
      // 097: ifeq 0c5
      // 09a: goto 0a1
      // 09d: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0a0: athrow
      // 0a1: aload 0
      // 0a2: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 0a5: aload 0
      // 0a6: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 0a9: checkcast com/l7tech/policy/assertion/Regex
      // 0ac: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 0af: getstatic com/l7tech/server/policy/assertion/ServerRegex.m [Ljava/lang/String;
      // 0b2: bipush 6
      // 0b4: aaload
      // 0b5: swap
      // 0b6: 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" ]
      // 0bb: invokevirtual java/util/logging/Logger.fine (Ljava/lang/String;)V
      // 0be: goto 0c5
      // 0c1: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0c4: athrow
      // 0c5: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0c8: areturn
      // 0c9: aload 0
      // 0ca: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_NO_MATCH_FAILURE Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0cd: bipush 1
      // 0ce: anewarray 252
      // 0d1: dup
      // 0d2: bipush 0
      // 0d3: aload 0
      // 0d4: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 0d7: checkcast com/l7tech/policy/assertion/Regex
      // 0da: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 0dd: aastore
      // 0de: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 0e1: getstatic com/l7tech/policy/assertion/AssertionStatus.FALSIFIED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0e4: areturn
      // 0e5: iload 3
      // 0e6: ifeq 109
      // 0e9: aload 0
      // 0ea: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_MATCH_FAILURE Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0ed: bipush 1
      // 0ee: anewarray 252
      // 0f1: dup
      // 0f2: bipush 0
      // 0f3: aload 0
      // 0f4: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 0f7: checkcast com/l7tech/policy/assertion/Regex
      // 0fa: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 0fd: aastore
      // 0fe: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 101: getstatic com/l7tech/policy/assertion/AssertionStatus.FALSIFIED Lcom/l7tech/policy/assertion/AssertionStatus;
      // 104: areturn
      // 105: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 108: athrow
      // 109: aload 0
      // 10a: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 10d: getstatic java/util/logging/Level.FINE Ljava/util/logging/Level;
      // 110: invokevirtual java/util/logging/Logger.isLoggable (Ljava/util/logging/Level;)Z
      // 113: ifeq 139
      // 116: aload 0
      // 117: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 11a: aload 0
      // 11b: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 11e: checkcast com/l7tech/policy/assertion/Regex
      // 121: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 124: getstatic com/l7tech/server/policy/assertion/ServerRegex.m [Ljava/lang/String;
      // 127: bipush 3
      // 128: aaload
      // 129: swap
      // 12a: 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" ]
      // 12f: invokevirtual java/util/logging/Logger.fine (Ljava/lang/String;)V
      // 132: goto 139
      // 135: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 138: athrow
      // 139: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 13c: areturn
      // try (3 -> 8): 9 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (29 -> 32): 32 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (52 -> 59): 60 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (57 -> 67): 68 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (62 -> 82): 83 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (101 -> 117): 117 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (119 -> 136): 137 com/l7tech/server/policy/assertion/AssertionStatusException
   }

   private void a(List<String> var1, Matcher var2) {
      try {
         if (this.i) {
            var1.add(var2.group(0));
         }
      } catch (AssertionStatusException var5) {
         throw a(var5);
      }

      int var3 = 1;

      try {
         while (var3 <= var2.groupCount()) {
            var1.add(var2.group(var3));
            var3++;
         }
      } catch (AssertionStatusException var4) {
         throw a(var4);
      }
   }

   private AssertionStatus a(PolicyEnforcementContext param1, Pattern param2, ai param3, aj param4) 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 0
      // 001: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 004: checkcast com/l7tech/policy/assertion/Regex
      // 007: invokevirtual com/l7tech/policy/assertion/Regex.getReplacement ()Ljava/lang/String;
      // 00a: astore 5
      // 00c: aload 0
      // 00d: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 010: getstatic java/util/logging/Level.FINE Ljava/util/logging/Level;
      // 013: invokevirtual java/util/logging/Logger.isLoggable (Ljava/util/logging/Level;)Z
      // 016: ifeq 045
      // 019: aload 0
      // 01a: getfield com/l7tech/server/policy/assertion/ServerRegex.logger Ljava/util/logging/Logger;
      // 01d: getstatic java/util/logging/Level.FINE Ljava/util/logging/Level;
      // 020: getstatic com/l7tech/server/policy/assertion/ServerRegex.m [Ljava/lang/String;
      // 023: bipush 4
      // 024: aaload
      // 025: bipush 2
      // 026: anewarray 47
      // 029: dup
      // 02a: bipush 0
      // 02b: aload 0
      // 02c: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 02f: checkcast com/l7tech/policy/assertion/Regex
      // 032: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 035: aastore
      // 036: dup
      // 037: bipush 1
      // 038: aload 5
      // 03a: aastore
      // 03b: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;[Ljava/lang/Object;)V
      // 03e: goto 045
      // 041: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 044: athrow
      // 045: aload 5
      // 047: aload 1
      // 048: aload 0
      // 049: getfield com/l7tech/server/policy/assertion/ServerRegex.f [Ljava/lang/String;
      // 04c: aload 0
      // 04d: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.getAudit ()Lcom/l7tech/gateway/common/audit/Audit;
      // 050: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.getVariableMap ([Ljava/lang/String;Lcom/l7tech/gateway/common/audit/Audit;)Ljava/util/Map; 3
      // 055: aload 0
      // 056: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.getAudit ()Lcom/l7tech/gateway/common/audit/Audit;
      // 059: invokestatic com/l7tech/server/policy/variable/ExpandVariables.process (Ljava/lang/String;Ljava/util/Map;Lcom/l7tech/gateway/common/audit/Audit;)Ljava/lang/String;
      // 05c: astore 5
      // 05e: new java/util/ArrayList
      // 061: dup
      // 062: invokespecial java/util/ArrayList.<init> ()V
      // 065: astore 6
      // 067: aload 3
      // 068: invokeinterface com/l7tech/server/policy/assertion/ai.getInput ()Ljava/lang/CharSequence; 1
      // 06d: astore 7
      // 06f: aload 7
      // 071: astore 8
      // 073: bipush 0
      // 074: istore 10
      // 076: iload 10
      // 078: aload 0
      // 079: getfield com/l7tech/server/policy/assertion/ServerRegex.h I
      // 07c: if_icmpgt 130
      // 07f: aload 2
      // 080: aload 8
      // 082: invokevirtual java/util/regex/Pattern.matcher (Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;
      // 085: astore 9
      // 087: aload 9
      // 089: invokevirtual java/util/regex/Matcher.find ()Z
      // 08c: istore 11
      // 08e: iload 11
      // 090: ifeq 130
      // 093: aload 0
      // 094: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 097: ifnull 0b0
      // 09a: goto 0a1
      // 09d: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0a0: athrow
      // 0a1: aload 0
      // 0a2: aload 6
      // 0a4: aload 9
      // 0a6: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/util/List;Ljava/util/regex/Matcher;)V
      // 0a9: goto 0b0
      // 0ac: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0af: athrow
      // 0b0: new java/lang/StringBuffer
      // 0b3: dup
      // 0b4: invokespecial java/lang/StringBuffer.<init> ()V
      // 0b7: astore 12
      // 0b9: aload 9
      // 0bb: aload 12
      // 0bd: aload 5
      // 0bf: invokevirtual java/util/regex/Matcher.appendReplacement (Ljava/lang/StringBuffer;Ljava/lang/String;)Ljava/util/regex/Matcher;
      // 0c2: pop
      // 0c3: goto 0f6
      // 0c6: astore 13
      // 0c8: aload 0
      // 0c9: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_REPLACEMENT_INVALID Lcom/l7tech/gateway/common/audit/Messages$M;
      // 0cc: bipush 1
      // 0cd: anewarray 252
      // 0d0: dup
      // 0d1: bipush 0
      // 0d2: aload 13
      // 0d4: invokevirtual java/lang/RuntimeException.getMessage ()Ljava/lang/String;
      // 0d7: getstatic com/l7tech/server/policy/assertion/ServerRegex.m [Ljava/lang/String;
      // 0da: bipush 0
      // 0db: aaload
      // 0dc: swap
      // 0dd: 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" ]
      // 0e2: aastore
      // 0e3: aload 13
      // 0e5: invokestatic com/l7tech/util/ExceptionUtils.getDebugException (Ljava/lang/Throwable;)Ljava/lang/Throwable;
      // 0e8: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;Ljava/lang/Throwable;)V
      // 0eb: new com/l7tech/server/policy/assertion/AssertionStatusException
      // 0ee: dup
      // 0ef: getstatic com/l7tech/policy/assertion/AssertionStatus.SERVER_ERROR Lcom/l7tech/policy/assertion/AssertionStatus;
      // 0f2: invokespecial com/l7tech/server/policy/assertion/AssertionStatusException.<init> (Lcom/l7tech/policy/assertion/AssertionStatus;)V
      // 0f5: athrow
      // 0f6: aload 9
      // 0f8: invokevirtual java/util/regex/Matcher.find ()Z
      // 0fb: istore 11
      // 0fd: iload 11
      // 0ff: ifne 109
      // 102: goto 11b
      // 105: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 108: athrow
      // 109: aload 0
      // 10a: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 10d: ifnull 0b9
      // 110: aload 0
      // 111: aload 6
      // 113: aload 9
      // 115: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/util/List;Ljava/util/regex/Matcher;)V
      // 118: goto 0b9
      // 11b: aload 9
      // 11d: aload 12
      // 11f: invokevirtual java/util/regex/Matcher.appendTail (Ljava/lang/StringBuffer;)Ljava/lang/StringBuffer;
      // 122: pop
      // 123: aload 12
      // 125: invokevirtual java/lang/StringBuffer.toString ()Ljava/lang/String;
      // 128: astore 8
      // 12a: iinc 10 1
      // 12d: goto 076
      // 130: aload 8
      // 132: aload 7
      // 134: if_acmpeq 147
      // 137: aload 4
      // 139: aload 8
      // 13b: invokeinterface com/l7tech/server/policy/assertion/aj.setOutput (Ljava/lang/CharSequence;)V 2
      // 140: goto 147
      // 143: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 146: athrow
      // 147: aload 0
      // 148: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 14b: ifnull 170
      // 14e: aload 1
      // 14f: aload 0
      // 150: getfield com/l7tech/server/policy/assertion/ServerRegex.k Ljava/lang/String;
      // 153: aload 6
      // 155: aload 6
      // 157: invokeinterface java/util/List.size ()I 1
      // 15c: anewarray 252
      // 15f: invokeinterface java/util/List.toArray ([Ljava/lang/Object;)[Ljava/lang/Object; 2
      // 164: invokeinterface com/l7tech/server/message/PolicyEnforcementContext.setVariable (Ljava/lang/String;Ljava/lang/Object;)V 3
      // 169: goto 170
      // 16c: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 16f: athrow
      // 170: getstatic com/l7tech/policy/assertion/AssertionStatus.NONE Lcom/l7tech/policy/assertion/AssertionStatus;
      // 173: areturn
      // try (68 -> 78): 79 java/lang/IndexOutOfBoundsException
      // try (66 -> 71): 72 java/lang/IndexOutOfBoundsException
      // try (5 -> 30): 31 java/lang/IndexOutOfBoundsException
      // try (85 -> 90): 91 java/lang/IndexOutOfBoundsException
      // try (85 -> 90): 91 java/lang/IllegalArgumentException
      // try (117 -> 120): 120 java/lang/IndexOutOfBoundsException
      // try (139 -> 145): 146 java/lang/IndexOutOfBoundsException
      // try (148 -> 160): 161 java/lang/IndexOutOfBoundsException
   }

   private Pattern d(PolicyEnforcementContext var1) throws PolicyAssertionException {
      try {
         this.b();
         if (this.e.isLeft()) {
            return (Pattern)this.e.left();
         }
      } catch (PatternSyntaxException var5) {
         throw a(var5);
      }

      String var2 = ExpandVariables.process((String)this.e.right(), var1.getVariableMap(this.f, this.getAudit()), this.getAudit(), new ah(this));

      try {
         return Pattern.compile(var2, this.a());
      } catch (PatternSyntaxException var4) {
         this.logAndAudit(AssertionMessages.REGEX_PATTERN_INVALID, new String[]{var2, ExceptionUtils.getMessage(var4)}, ExceptionUtils.getDebugException(var4));
         throw new AssertionStatusException(AssertionStatus.SERVER_ERROR, var4);
      }
   }

   private void b() throws AssertionStatusException, 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:
      // 00: aload 0
      // 01: getfield com/l7tech/server/policy/assertion/ServerRegex.e Lcom/l7tech/util/Either;
      // 04: ifnonnull 6d
      // 07: aload 0
      // 08: getfield com/l7tech/server/policy/assertion/ServerRegex.d Ljava/lang/Exception;
      // 0b: ifnull 42
      // 0e: goto 15
      // 11: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 14: athrow
      // 15: aload 0
      // 16: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_PATTERN_INVALID Lcom/l7tech/gateway/common/audit/Messages$M;
      // 19: bipush 2
      // 1a: anewarray 252
      // 1d: dup
      // 1e: bipush 0
      // 1f: aload 0
      // 20: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 23: checkcast com/l7tech/policy/assertion/Regex
      // 26: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 29: aastore
      // 2a: dup
      // 2b: bipush 1
      // 2c: aload 0
      // 2d: getfield com/l7tech/server/policy/assertion/ServerRegex.d Ljava/lang/Exception;
      // 30: invokevirtual java/lang/Exception.getMessage ()Ljava/lang/String;
      // 33: aastore
      // 34: aload 0
      // 35: getfield com/l7tech/server/policy/assertion/ServerRegex.d Ljava/lang/Exception;
      // 38: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;Ljava/lang/Throwable;)V
      // 3b: goto 62
      // 3e: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 41: athrow
      // 42: aload 0
      // 43: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_PATTERN_INVALID Lcom/l7tech/gateway/common/audit/Messages$M;
      // 46: bipush 2
      // 47: anewarray 252
      // 4a: dup
      // 4b: bipush 0
      // 4c: aload 0
      // 4d: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 50: checkcast com/l7tech/policy/assertion/Regex
      // 53: invokevirtual com/l7tech/policy/assertion/Regex.getRegex ()Ljava/lang/String;
      // 56: aastore
      // 57: dup
      // 58: bipush 1
      // 59: getstatic com/l7tech/server/policy/assertion/ServerRegex.m [Ljava/lang/String;
      // 5c: bipush 1
      // 5d: aaload
      // 5e: aastore
      // 5f: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;[Ljava/lang/String;)V
      // 62: new com/l7tech/server/policy/assertion/AssertionStatusException
      // 65: dup
      // 66: getstatic com/l7tech/policy/assertion/AssertionStatus.SERVER_ERROR Lcom/l7tech/policy/assertion/AssertionStatus;
      // 69: invokespecial com/l7tech/server/policy/assertion/AssertionStatusException.<init> (Lcom/l7tech/policy/assertion/AssertionStatus;)V
      // 6c: athrow
      // 6d: aload 0
      // 6e: getfield com/l7tech/server/policy/assertion/ServerRegex.g Z
      // 71: ifeq a5
      // 74: aload 0
      // 75: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 78: checkcast com/l7tech/policy/assertion/Regex
      // 7b: invokevirtual com/l7tech/policy/assertion/Regex.getReplacement ()Ljava/lang/String;
      // 7e: ifnonnull a5
      // 81: goto 88
      // 84: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 87: athrow
      // 88: aload 0
      // 89: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_NO_REPLACEMENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 8c: invokevirtual com/l7tech/server/policy/assertion/ServerRegex.logAndAudit (Lcom/l7tech/gateway/common/audit/AuditDetailMessage;)V
      // 8f: new com/l7tech/policy/assertion/PolicyAssertionException
      // 92: dup
      // 93: aload 0
      // 94: getfield com/l7tech/server/policy/assertion/ServerRegex.assertion Lcom/l7tech/policy/assertion/Assertion;
      // 97: getstatic com/l7tech/gateway/common/audit/AssertionMessages.REGEX_NO_REPLACEMENT Lcom/l7tech/gateway/common/audit/Messages$M;
      // 9a: invokevirtual com/l7tech/gateway/common/audit/Messages$M.getMessage ()Ljava/lang/String;
      // 9d: invokespecial com/l7tech/policy/assertion/PolicyAssertionException.<init> (Lcom/l7tech/policy/assertion/Assertion;Ljava/lang/String;)V
      // a0: athrow
      // a1: invokestatic com/l7tech/server/policy/assertion/ServerRegex.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // a4: athrow
      // a5: return
      // try (0 -> 6): 7 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (3 -> 30): 30 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (55 -> 63): 64 com/l7tech/server/policy/assertion/AssertionStatusException
      // try (58 -> 77): 77 com/l7tech/server/policy/assertion/AssertionStatusException
   }

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

   static {
      String[] var5 = new String[7];
      int var3 = 0;
      String var2 = "{\u0002H<K@\u0012z\u0003\t?WUW`\b\t,BU^o\u000fL3BKF.\tQ.U@A}\u0005F0\u0007\rBa\u001fZ7EIW.\u0002F0B][}\u0018L0S\u0005Po\u000fB~U@Tk\u001eL0D@\u0012a\u001e\t7KIWi\rE~@W]{\u001c\t,BCW|\tG=B\f\u001c.)[,HW\b.\r{\u0002B0HR\\.\t[,HW,Z\r[9BQ\u0012g\u001f\t\u0011smw\\LK+S\u0005\\aL_?ULSl\u0000L~ID_kL^?T\u0005Ak\u0018;^\u001eF=B@Vg\u0002N~\u001d\u0005|a\u0018\t3FQQf\tM~FKV.\u001c[1D@WjL@8\u0007K].\u0001H*DM\u0012|\tX+BVFk\b\tA\\\tY2FFW.\u001eL/R@Az\tMd\u0007hSz\u000fA~WDFz\t[0\u0007\u0002\u0015u\\Ty\u0000\t\u0012|\tY2FFW.\u001cH*S@@`L\u000ey\\\u0014O)K";
      int var4 = "{\u0002H<K@\u0012z\u0003\t?WUW`\b\t,BU^o\u000fL3BKF.\tQ.U@A}\u0005F0\u0007\rBa\u001fZ7EIW.\u0002F0B][}\u0018L0S\u0005Po\u000fB~U@Tk\u001eL0D@\u0012a\u001e\t7KIWi\rE~@W]{\u001c\t,BCW|\tG=B\f\u001c.)[,HW\b.\r{\u0002B0HR\\.\t[,HW,Z\r[9BQ\u0012g\u001f\t\u0011smw\\LK+S\u0005\\aL_?ULSl\u0000L~ID_kL^?T\u0005Ak\u0018;^\u001eF=B@Vg\u0002N~\u001d\u0005|a\u0018\t3FQQf\tM~FKV.\u001c[1D@WjL@8\u0007K].\u0001H*DM\u0012|\tX+BVFk\b\tA\\\tY2FFW.\u001eL/R@Az\tMd\u0007hSz\u000fA~WDFz\t[0\u0007\u0002\u0015u\\Ty\u0000\t\u0012|\tY2FFW.\u001cH*S@@`L\u000ey\\\u0014O)K"
         .length();
      char var1 = 'q';
      int var7 = -1;

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

         while (true) {
            String var8 = b(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     m = var5;
                     return;
                  }

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

                  var2 = "b5c\u0001zi*_'1)KUOdts\u0013k=|W&x\u0007}qo\u0016\"p\njx*_'1\bjqf\u0015f&~\u0005zxn_:vF%=GW r\u000ezy*";
                  var4 = "b5c\u0001zi*_'1)KUOdts\u0013k=|W&x\u0007}qo\u0016\"p\njx*_'1\bjqf\u0015f&~\u0005zxn_:vF%=GW r\u000ezy*".length();
                  var1 = '*';
                  var7 = -1;
            }

            var10000 = 63;
            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] ^ 53);
      }

      return var10000;
   }

   private static String b(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 -> 9;
            case 1 -> 107;
            case 2 -> 46;
            case 3 -> 89;
            case 4 -> 32;
            case 5 -> 34;
            default -> 53;
         });
      }

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