package com.l7tech.gateway.common.security;

import com.l7tech.objectmodel.imp.ZoneableNamedEntityImp;
import com.l7tech.util.Charsets;
import com.l7tech.util.ClassFilterBuilder;
import com.l7tech.util.DeserializeSafe;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "revocation_check_policy")
@DeserializeSafe
public class RevocationCheckPolicy extends ZoneableNamedEntityImp implements Cloneable {
   private static final Charset PROPERTIES_ENCODING = Charsets.UTF8;
   private transient String revocationCheckPolicyXml;
   private List<RevocationCheckPolicyItem> revocationCheckItems = Collections.emptyList();
   private boolean defaultPolicy;
   private boolean defaultSuccess;
   private boolean continueOnServerUnavailable;
   private static final ClassFilterBuilder FILTER_BUILDER;
   static final long serialVersionUID = 4599121866286243555L;

   @Column(name = "default_policy")
   public boolean isDefaultPolicy() {
      return this.defaultPolicy;
   }

   public void setDefaultPolicy(boolean var1) {
      this.defaultPolicy = var1;
   }

   @Column(name = "default_success")
   public boolean isDefaultSuccess() {
      return this.defaultSuccess;
   }

   public void setDefaultSuccess(boolean var1) {
      this.defaultSuccess = var1;
   }

   @Column(name = "continue_server_unavailable")
   public boolean isContinueOnServerUnavailable() {
      return this.continueOnServerUnavailable;
   }

   public void setContinueOnServerUnavailable(boolean var1) {
      this.continueOnServerUnavailable = var1;
   }

   @Transient
   public List<RevocationCheckPolicyItem> getRevocationCheckItems() {
      return this.revocationCheckItems;
   }

   public void setRevocationCheckItems(List<RevocationCheckPolicyItem> var1) {
      try {
         this.revocationCheckPolicyXml = null;
         if (var1 == null) {
            this.revocationCheckItems = Collections.emptyList();
            return;
         }
      } catch (IllegalStateException var2) {
         throw a(var2);
      }

      this.revocationCheckItems = Collections.unmodifiableList(new ArrayList<>(var1));
   }

   @Override
   public boolean equals(Object 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: aload 1
      // 02: if_acmpne 0b
      // 05: bipush 1
      // 06: ireturn
      // 07: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 0a: athrow
      // 0b: aload 1
      // 0c: ifnull 21
      // 0f: aload 0
      // 10: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 13: aload 1
      // 14: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 17: if_acmpeq 27
      // 1a: goto 21
      // 1d: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 20: athrow
      // 21: bipush 0
      // 22: ireturn
      // 23: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 26: athrow
      // 27: aload 0
      // 28: aload 1
      // 29: invokespecial com/l7tech/objectmodel/imp/ZoneableNamedEntityImp.equals (Ljava/lang/Object;)Z
      // 2c: ifne 35
      // 2f: bipush 0
      // 30: ireturn
      // 31: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 34: athrow
      // 35: aload 1
      // 36: checkcast com/l7tech/gateway/common/security/RevocationCheckPolicy
      // 39: astore 2
      // 3a: aload 0
      // 3b: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.defaultPolicy Z
      // 3e: aload 2
      // 3f: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.defaultPolicy Z
      // 42: if_icmpne b9
      // 45: aload 0
      // 46: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.defaultSuccess Z
      // 49: aload 2
      // 4a: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.defaultSuccess Z
      // 4d: if_icmpne b9
      // 50: goto 57
      // 53: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 56: athrow
      // 57: aload 0
      // 58: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.continueOnServerUnavailable Z
      // 5b: aload 2
      // 5c: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.continueOnServerUnavailable Z
      // 5f: if_icmpne b9
      // 62: goto 69
      // 65: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 68: athrow
      // 69: aload 0
      // 6a: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckItems Ljava/util/List;
      // 6d: aload 2
      // 6e: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckItems Ljava/util/List;
      // 71: invokeinterface java/util/List.equals (Ljava/lang/Object;)Z 2
      // 76: ifeq b9
      // 79: goto 80
      // 7c: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 7f: athrow
      // 80: aload 0
      // 81: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // 84: ifnull aa
      // 87: goto 8e
      // 8a: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 8d: athrow
      // 8e: aload 0
      // 8f: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // 92: aload 2
      // 93: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // 96: invokevirtual com/l7tech/objectmodel/SecurityZone.equals (Ljava/lang/Object;)Z
      // 99: ifeq b9
      // 9c: goto a3
      // 9f: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // a2: athrow
      // a3: goto b1
      // a6: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // a9: athrow
      // aa: aload 2
      // ab: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.securityZone Lcom/l7tech/objectmodel/SecurityZone;
      // ae: ifnonnull b9
      // b1: bipush 1
      // b2: goto ba
      // b5: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // b8: athrow
      // b9: bipush 0
      // ba: ireturn
      // try (0 -> 5): 5 java/lang/IllegalStateException
      // try (7 -> 14): 15 java/lang/IllegalStateException
      // try (9 -> 19): 19 java/lang/IllegalStateException
      // try (21 -> 27): 27 java/lang/IllegalStateException
      // try (32 -> 42): 43 java/lang/IllegalStateException
      // try (37 -> 50): 51 java/lang/IllegalStateException
      // try (45 -> 59): 60 java/lang/IllegalStateException
      // try (53 -> 65): 66 java/lang/IllegalStateException
      // try (62 -> 74): 75 java/lang/IllegalStateException
      // try (68 -> 78): 78 java/lang/IllegalStateException
      // try (80 -> 85): 85 java/lang/IllegalStateException
   }

   @Override
   public int hashCode() {
      int var1 = super.hashCode();
      var1 = 31 * var1 + this.revocationCheckItems.hashCode();

      int var10000;
      byte var10001;
      label59: {
         try {
            var10000 = 31 * var1;
            if (this.defaultPolicy) {
               var10001 = 1;
               break label59;
            }
         } catch (IllegalStateException var5) {
            throw a(var5);
         }

         var10001 = 0;
      }

      var1 = var10000 + var10001;

      label51: {
         try {
            var10000 = 31 * var1;
            if (this.defaultSuccess) {
               var10001 = 1;
               break label51;
            }
         } catch (IllegalStateException var4) {
            throw a(var4);
         }

         var10001 = 0;
      }

      var1 = var10000 + var10001;

      label43: {
         try {
            var10000 = 31 * var1;
            if (this.continueOnServerUnavailable) {
               var10001 = 1;
               break label43;
            }
         } catch (IllegalStateException var3) {
            throw a(var3);
         }

         var10001 = 0;
      }

      var1 = var10000 + var10001;

      try {
         var10000 = 31 * var1;
         if (this.securityZone != null) {
            return var10000 + this.securityZone.hashCode();
         }
      } catch (IllegalStateException var2) {
         throw a(var2);
      }

      return var10000 + 0;
   }

   public final RevocationCheckPolicy clone() {
      try {
         RevocationCheckPolicy var1 = (RevocationCheckPolicy)super.clone();
         var1.setRevocationCheckPolicyXml(this.getRevocationCheckPolicyXml());
         return var1;
      } catch (CloneNotSupportedException var2) {
         throw new IllegalStateException(var2);
      }
   }

   @Column(name = "revocation_policy_xml", length = Integer.MAX_VALUE)
   @Lob
   protected String getRevocationCheckPolicyXml() {
      // $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/gateway/common/security/RevocationCheckPolicy.revocationCheckPolicyXml Ljava/lang/String;
      // 04: ifnonnull 72
      // 07: aload 0
      // 08: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckItems Ljava/util/List;
      // 0b: astore 1
      // 0c: aload 1
      // 0d: ifnull 20
      // 10: aload 1
      // 11: invokeinterface java/util/List.isEmpty ()Z 1
      // 16: ifeq 26
      // 19: goto 20
      // 1c: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 1f: athrow
      // 20: aconst_null
      // 21: areturn
      // 22: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 25: athrow
      // 26: new com/l7tech/util/PoolByteArrayOutputStream
      // 29: dup
      // 2a: invokespecial com/l7tech/util/PoolByteArrayOutputStream.<init> ()V
      // 2d: astore 2
      // 2e: new java/beans/XMLEncoder
      // 31: dup
      // 32: new com/l7tech/common/io/NonCloseableOutputStream
      // 35: dup
      // 36: aload 2
      // 37: invokespecial com/l7tech/common/io/NonCloseableOutputStream.<init> (Ljava/io/OutputStream;)V
      // 3a: invokespecial java/beans/XMLEncoder.<init> (Ljava/io/OutputStream;)V
      // 3d: astore 3
      // 3e: aload 3
      // 3f: ldc com/l7tech/objectmodel/Goid
      // 41: invokestatic com/l7tech/objectmodel/Goid.getPersistenceDelegate ()Ljava/beans/PersistenceDelegate;
      // 44: invokevirtual java/beans/XMLEncoder.setPersistenceDelegate (Ljava/lang/Class;Ljava/beans/PersistenceDelegate;)V
      // 47: aload 3
      // 48: new java/util/ArrayList
      // 4b: dup
      // 4c: aload 1
      // 4d: invokespecial java/util/ArrayList.<init> (Ljava/util/Collection;)V
      // 50: invokevirtual java/beans/XMLEncoder.writeObject (Ljava/lang/Object;)V
      // 53: aload 3
      // 54: invokevirtual java/beans/XMLEncoder.close ()V
      // 57: aload 0
      // 58: aload 2
      // 59: getstatic com/l7tech/gateway/common/security/RevocationCheckPolicy.PROPERTIES_ENCODING Ljava/nio/charset/Charset;
      // 5c: invokevirtual com/l7tech/util/PoolByteArrayOutputStream.toString (Ljava/nio/charset/Charset;)Ljava/lang/String;
      // 5f: putfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckPolicyXml Ljava/lang/String;
      // 62: aload 2
      // 63: invokevirtual com/l7tech/util/PoolByteArrayOutputStream.close ()V
      // 66: goto 72
      // 69: astore 4
      // 6b: aload 2
      // 6c: invokevirtual com/l7tech/util/PoolByteArrayOutputStream.close ()V
      // 6f: aload 4
      // 71: athrow
      // 72: aload 0
      // 73: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckPolicyXml Ljava/lang/String;
      // 76: areturn
      // try (8 -> 16): 16 java/lang/IllegalStateException
      // try (6 -> 11): 12 java/lang/IllegalStateException
      // try (22 -> 47): 50 null
      // try (50 -> 51): 50 null
   }

   protected void setRevocationCheckPolicyXml(String 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 1
      // 01: ifnull 1b
      // 04: aload 1
      // 05: aload 0
      // 06: getfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckPolicyXml Ljava/lang/String;
      // 09: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 0c: ifeq 1b
      // 0f: goto 16
      // 12: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 15: athrow
      // 16: return
      // 17: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 1a: athrow
      // 1b: aload 0
      // 1c: aload 1
      // 1d: putfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckPolicyXml Ljava/lang/String;
      // 20: aload 1
      // 21: ifnull 63
      // 24: aload 1
      // 25: invokevirtual java/lang/String.length ()I
      // 28: ifle 63
      // 2b: goto 32
      // 2e: invokestatic com/l7tech/gateway/common/security/RevocationCheckPolicy.a (Ljava/lang/IllegalStateException;)Ljava/lang/IllegalStateException;
      // 31: athrow
      // 32: new com/l7tech/util/SafeXMLDecoderBuilder
      // 35: dup
      // 36: getstatic com/l7tech/gateway/common/security/RevocationCheckPolicy.FILTER_BUILDER Lcom/l7tech/util/ClassFilterBuilder;
      // 39: new java/io/ByteArrayInputStream
      // 3c: dup
      // 3d: aload 1
      // 3e: getstatic com/l7tech/gateway/common/security/RevocationCheckPolicy.PROPERTIES_ENCODING Ljava/nio/charset/Charset;
      // 41: invokevirtual java/lang/String.getBytes (Ljava/nio/charset/Charset;)[B
      // 44: invokespecial java/io/ByteArrayInputStream.<init> ([B)V
      // 47: invokespecial com/l7tech/util/SafeXMLDecoderBuilder.<init> (Lcom/l7tech/util/ClassFilterBuilder;Ljava/io/InputStream;)V
      // 4a: invokevirtual com/l7tech/util/SafeXMLDecoderBuilder.build ()Lcom/l7tech/util/SafeXMLDecoder;
      // 4d: astore 2
      // 4e: aload 0
      // 4f: new java/util/ArrayList
      // 52: dup
      // 53: aload 2
      // 54: invokevirtual com/l7tech/util/SafeXMLDecoder.readObject ()Ljava/lang/Object;
      // 57: checkcast java/util/List
      // 5a: invokespecial java/util/ArrayList.<init> (Ljava/util/Collection;)V
      // 5d: invokestatic java/util/Collections.unmodifiableList (Ljava/util/List;)Ljava/util/List;
      // 60: putfield com/l7tech/gateway/common/security/RevocationCheckPolicy.revocationCheckItems Ljava/util/List;
      // 63: return
      // try (0 -> 7): 8 java/lang/IllegalStateException
      // try (2 -> 11): 11 java/lang/IllegalStateException
      // try (13 -> 21): 22 java/lang/IllegalStateException
   }

   static {
      String var10002 = b(40, b("YM79l\u0006W_A29gPW_U;n.RLWO5y.BFYW(~tH\rhG,xcPWSM4ThT@Qr5{iRZsV?z$eZJGtaa]V_m<?jPU[\f6vnV\riV(~nV\n"));
      byte var10001 = -1;
      String var0 = var10002;
      FILTER_BUILDER = new ClassFilterBuilder().allowDefaults().addMethods(new String[]{var0});
   }

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

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

      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 -> 18;
            case 1 -> 10;
            case 2 -> 114;
            case 3 -> 63;
            case 4 -> 40;
            case 5 -> 25;
            default -> 11;
         });
      }

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