package com.l7tech.server.policy;

import com.l7tech.objectmodel.DeleteException;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.objectmodel.EntityManager.UniqueType;
import com.l7tech.objectmodel.folder.Folder;
import com.l7tech.policy.CircularPolicyException;
import com.l7tech.policy.Policy;
import com.l7tech.policy.PolicyAlias;
import com.l7tech.policy.PolicyDeletionForbiddenException;
import com.l7tech.policy.PolicyHeader;
import com.l7tech.policy.PolicyType;
import com.l7tech.server.FolderSupportHibernateEntityManager;
import com.l7tech.server.folder.FolderManager;
import com.l7tech.server.security.rbac.RoleManager;
import com.l7tech.util.Config;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class PolicyManagerImpl extends FolderSupportHibernateEntityManager<Policy, PolicyHeader> implements PolicyManager {
   private static final Logger n;
   String o;
   String p;
   private static final Pattern q;
   private static final boolean r;
   static final String s;
   private final PolicyCache t;
   private final RoleManager u;
   private final PolicyAliasManager v;
   private final FolderManager w;
   private final Config x;
   private static final String[] z;

   public PolicyManagerImpl(RoleManager var1, PolicyAliasManager var2, FolderManager var3, PolicyCache var4, @NotNull Config var5) {
      if (var5 == null) {
         c(0);
      }

      super();
      String[] var6 = z;
      this.o = var6[8];
      this.p = var6[6] + this.o + var6[17];
      this.u = var1;
      this.v = var2;
      this.w = var3;
      this.t = var4;
      this.x = var5;
   }

   public Policy findByHeader(EntityHeader param1) throws FindException {
      // $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: instanceof com/l7tech/objectmodel/GuidEntityHeader
      // 04: ifeq 28
      // 07: aload 1
      // 08: checkcast com/l7tech/objectmodel/GuidEntityHeader
      // 0b: invokevirtual com/l7tech/objectmodel/GuidEntityHeader.getGuid ()Ljava/lang/String;
      // 0e: ifnull 28
      // 11: goto 18
      // 14: invokestatic com/l7tech/server/policy/PolicyManagerImpl.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 17: athrow
      // 18: aload 0
      // 19: aload 1
      // 1a: checkcast com/l7tech/objectmodel/GuidEntityHeader
      // 1d: invokevirtual com/l7tech/objectmodel/GuidEntityHeader.getGuid ()Ljava/lang/String;
      // 20: invokevirtual com/l7tech/server/policy/PolicyManagerImpl.findByGuid (Ljava/lang/String;)Lcom/l7tech/policy/Policy;
      // 23: areturn
      // 24: invokestatic com/l7tech/server/policy/PolicyManagerImpl.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 27: athrow
      // 28: aload 0
      // 29: aload 1
      // 2a: invokespecial com/l7tech/server/FolderSupportHibernateEntityManager.findByHeader (Lcom/l7tech/objectmodel/EntityHeader;)Lcom/l7tech/objectmodel/PersistentEntity;
      // 2d: checkcast com/l7tech/policy/Policy
      // 30: areturn
      // try (0 -> 7): 8 com/l7tech/objectmodel/FindException
      // try (3 -> 16): 16 com/l7tech/objectmodel/FindException
   }

   @Override
   public Policy findByGuid(String var1) throws FindException {
      try {
         return (Policy)this.getHibernateTemplate().execute(new ar(this, var1));
      } catch (Exception var3) {
         throw new FindException(z[0], var3);
      }
   }

   @Override
   public Collection<PolicyHeader> findHeadersWithTypes(Set<PolicyType> var1) throws FindException {
      return this.findHeadersWithTypes(var1, false);
   }

   @Override
   public Collection<PolicyHeader> findHeadersWithTypes(Set<PolicyType> var1, boolean var2) throws FindException {
      List var3 = (List)this.getHibernateTemplate().execute(new as(this, var1));
      ArrayList var4 = new ArrayList(var3.size());

      for (Policy var6 : var3) {
         var4.add(this.newHeader(var6));
      }

      try {
         if (!var2) {
            return var4;
         }
      } catch (FindException var15) {
         throw a(var15);
      }

      Collection var16 = this.v.findAll();
      HashMap var17 = new HashMap();

      for (PolicyAlias var8 : var16) {
         Goid var9 = var8.getEntityGoid();
         if (!var17.containsKey(var9)) {
            HashSet var10 = new HashSet();
            var17.put(var9, var10);
         }

         ((Set)var17.get(var9)).add(var8);
      }

      ArrayList var18 = new ArrayList();

      for (PolicyHeader var20 : var4) {
         Goid var21 = var20.getGoid();
         var18.add(var20);
         if (var17.containsKey(var21)) {
            for (PolicyAlias var13 : (Set)var17.get(var21)) {
               PolicyHeader var14 = new PolicyHeader(var20);
               var14.setAliasGoid(var13.getGoid());
               var14.setFolderId(var13.getFolder().getGoid());
               var18.add(var14);
            }
         }
      }

      return var18;
   }

   public Collection<PolicyHeader> findHeaders(int var1, int var2, Map<String, String> var3) throws FindException {
      Map var4 = var3;
      String[] var6 = z;
      String var5 = (String)var3.get(var6[29]);

      label18: {
         try {
            if (var5 == null || var5.isEmpty()) {
               break label18;
            }
         } catch (FindException var7) {
            throw a(var7);
         }

         var4 = new HashMap(var3);
         var6 = z;
         var4.put(var6[21], var5);
      }

      var4.remove(z[2]);
      return this.doFindHeaders(var1, var2, var4, true);
   }

   public Goid save(Policy var1) throws SaveException {
      try {
         this.t.validate(var1);
      } catch (CircularPolicyException var5) {
         String var10002 = ExceptionUtils.getMessage(var5);
         String[] var4 = z;
         throw new SaveException(var4[18] + var10002, var5);
      }

      try {
         if (var1.getFolder() == null) {
            Folder var3 = this.w.findRootFolder();
            var1.setFolder(var3);
         }
      } catch (FindException var6) {
         throw new SaveException(z[13]);
      }

      return super.save(var1);
   }

   public void update(Policy var1) throws UpdateException {
      try {
         this.t.validate(var1);
      } catch (CircularPolicyException var4) {
         String var10002 = ExceptionUtils.getMessage(var4);
         String[] var3 = z;
         throw new UpdateException(var3[16] + var10002, var4);
      }

      label25: {
         FindException var2;
         try {
            if (var1.getType() == PolicyType.PRIVATE_SERVICE) {
               break label25;
            }

            try {
               this.u.renameEntitySpecificRoles(EntityType.POLICY, var1, q);
               break label25;
            } catch (FindException var5) {
               var2 = var5;
            }
         } catch (CircularPolicyException var6) {
            throw a(var6);
         }

         throw new UpdateException(z[23], var2);
      }

      super.update(var1);
   }

   public void updateFolder(Goid var1, Folder var2) throws UpdateException {
      this.setParentFolderForEntity(var1, var2);
   }

   public void updateFolder(Policy var1, Folder var2) throws UpdateException {
      try {
         if (var1 == null) {
            throw new UpdateException(z[3]);
         }
      } catch (UpdateException var3) {
         throw a(var3);
      }

      this.setParentFolderForEntity(var1.getGoid(), var2);
   }

   @Override
   public void delete(Goid var1) throws DeleteException, FindException {
      this.findAndDelete(var1);
   }

   public void delete(Policy var1) throws DeleteException {
      try {
         try {
            if (var1 != null) {
               this.t.validateRemove(var1.getGoid());
            }
         } catch (DeleteException var3) {
            throw a(var3);
         }
      } catch (PolicyDeletionForbiddenException var4) {
         throw new DeleteException(z[22] + ExceptionUtils.getMessage(var4), var4);
      }

      super.delete(var1);
   }

   @Override
   public void deleteWithoutValidation(Policy var1) throws DeleteException {
      super.delete(var1);
   }

   @Transactional(readOnly = true)
   @Override
   public Collection<PolicyHeader> findHeadersByType(PolicyType var1) throws FindException {
      return this.findHeadersWithTypes(EnumSet.of(var1));
   }

   public void createRoles(Policy var1) throws SaveException {
      try {
         if (this.x.getBooleanProperty(z[28], true)) {
            this.addManagePolicyRole(var1);
         }
      } catch (SaveException var2) {
         throw a(var2);
      }
   }

   public void updateRoles(Policy var1) throws UpdateException {
   }

   @Override
   public void addManagePolicyRole(Policy param1) throws SaveException {
      // $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: invokestatic com/l7tech/server/util/JaasUtils.getCurrentUser ()Lcom/l7tech/identity/User;
      // 003: astore 2
      // 004: aload 1
      // 005: invokevirtual com/l7tech/policy/Policy.getName ()Ljava/lang/String;
      // 008: astore 3
      // 009: aload 3
      // 00a: bipush 50
      // 00c: invokestatic com/l7tech/util/TextUtils.truncStringMiddle (Ljava/lang/String;I)Ljava/lang/String;
      // 00f: astore 3
      // 010: getstatic com/l7tech/server/policy/PolicyManagerImpl.z [Ljava/lang/String;
      // 013: astore 8
      // 015: aload 8
      // 017: bipush 30
      // 019: aaload
      // 01a: bipush 2
      // 01b: anewarray 32
      // 01e: dup
      // 01f: bipush 0
      // 020: aload 3
      // 021: aastore
      // 022: dup
      // 023: bipush 1
      // 024: aload 1
      // 025: invokevirtual com/l7tech/policy/Policy.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 028: aastore
      // 029: invokestatic java/text/MessageFormat.format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
      // 02c: astore 4
      // 02e: getstatic com/l7tech/server/policy/PolicyManagerImpl.n Ljava/util/logging/Logger;
      // 031: aload 4
      // 033: aload 8
      // 035: bipush 10
      // 037: aaload
      // 038: swap
      // 039: 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" ]
      // 03e: invokevirtual java/util/logging/Logger.info (Ljava/lang/String;)V
      // 041: new com/l7tech/gateway/common/security/rbac/Role
      // 044: dup
      // 045: invokespecial com/l7tech/gateway/common/security/rbac/Role.<init> ()V
      // 048: astore 5
      // 04a: aload 5
      // 04c: aload 4
      // 04e: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setName (Ljava/lang/String;)V
      // 051: aload 5
      // 053: aload 8
      // 055: bipush 1
      // 056: aaload
      // 057: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setDescription (Ljava/lang/String;)V
      // 05a: aload 5
      // 05c: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 05f: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setEntityType (Lcom/l7tech/objectmodel/EntityType;)V
      // 062: aload 5
      // 064: aload 1
      // 065: invokevirtual com/l7tech/policy/Policy.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 068: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setEntityGoid (Lcom/l7tech/objectmodel/Goid;)V
      // 06b: aload 5
      // 06d: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 070: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 073: aload 1
      // 074: invokevirtual com/l7tech/policy/Policy.getId ()Ljava/lang/String;
      // 077: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 07a: aload 5
      // 07c: getstatic com/l7tech/gateway/common/security/rbac/OperationType.UPDATE Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 07f: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 082: aload 1
      // 083: invokevirtual com/l7tech/policy/Policy.getId ()Ljava/lang/String;
      // 086: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 089: aload 5
      // 08b: getstatic com/l7tech/gateway/common/security/rbac/OperationType.DELETE Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 08e: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 091: aload 1
      // 092: invokevirtual com/l7tech/policy/Policy.getId ()Ljava/lang/String;
      // 095: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 098: aload 1
      // 099: invokevirtual com/l7tech/policy/Policy.getType ()Lcom/l7tech/policy/PolicyType;
      // 09c: getstatic com/l7tech/policy/PolicyType.GLOBAL_FRAGMENT Lcom/l7tech/policy/PolicyType;
      // 09f: invokevirtual com/l7tech/policy/PolicyType.equals (Ljava/lang/Object;)Z
      // 0a2: ifeq 0be
      // 0a5: aload 5
      // 0a7: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 0aa: aload 1
      // 0ab: invokevirtual com/l7tech/policy/Policy.getId ()Ljava/lang/String;
      // 0ae: getstatic com/l7tech/gateway/common/security/rbac/OtherOperationName.DEBUGGER Lcom/l7tech/gateway/common/security/rbac/OtherOperationName;
      // 0b1: invokevirtual com/l7tech/gateway/common/security/rbac/OtherOperationName.getOperationName ()Ljava/lang/String;
      // 0b4: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityOtherPermission (Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;Ljava/lang/String;)V
      // 0b7: goto 0be
      // 0ba: invokestatic com/l7tech/server/policy/PolicyManagerImpl.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0bd: athrow
      // 0be: aload 5
      // 0c0: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0c3: getstatic com/l7tech/objectmodel/EntityType.SERVICE_TEMPLATE Lcom/l7tech/objectmodel/EntityType;
      // 0c6: aconst_null
      // 0c7: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 0ca: aload 5
      // 0cc: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0cf: getstatic com/l7tech/objectmodel/EntityType.JDBC_CONNECTION Lcom/l7tech/objectmodel/EntityType;
      // 0d2: aconst_null
      // 0d3: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 0d6: aload 5
      // 0d8: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0db: getstatic com/l7tech/objectmodel/EntityType.HTTP_CONFIGURATION Lcom/l7tech/objectmodel/EntityType;
      // 0de: aconst_null
      // 0df: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 0e2: aload 5
      // 0e4: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 0e7: aload 1
      // 0e8: invokevirtual com/l7tech/policy/Policy.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 0eb: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityFolderAncestryPermission (Lcom/l7tech/objectmodel/EntityType;Lcom/l7tech/objectmodel/Goid;)V
      // 0ee: aload 5
      // 0f0: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0f3: getstatic com/l7tech/objectmodel/EntityType.ENCAPSULATED_ASSERTION Lcom/l7tech/objectmodel/EntityType;
      // 0f6: aconst_null
      // 0f7: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 0fa: aload 5
      // 0fc: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0ff: getstatic com/l7tech/objectmodel/EntityType.ASSERTION_ACCESS Lcom/l7tech/objectmodel/EntityType;
      // 102: aconst_null
      // 103: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addEntityPermission (Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;)V
      // 106: aload 2
      // 107: ifnull 1c9
      // 10a: aload 0
      // 10b: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 10e: aload 2
      // 10f: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 112: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 115: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 11a: istore 6
      // 11c: iload 6
      // 11e: aload 0
      // 11f: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 122: aload 2
      // 123: getstatic com/l7tech/gateway/common/security/rbac/OperationType.UPDATE Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 126: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 129: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 12e: iand
      // 12f: istore 6
      // 131: iload 6
      // 133: aload 0
      // 134: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 137: aload 2
      // 138: getstatic com/l7tech/gateway/common/security/rbac/OperationType.DELETE Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 13b: getstatic com/l7tech/objectmodel/EntityType.POLICY Lcom/l7tech/objectmodel/EntityType;
      // 13e: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 143: iand
      // 144: istore 6
      // 146: iload 6
      // 148: aload 0
      // 149: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 14c: aload 2
      // 14d: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 150: getstatic com/l7tech/objectmodel/EntityType.FOLDER Lcom/l7tech/objectmodel/EntityType;
      // 153: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 158: iand
      // 159: istore 6
      // 15b: iload 6
      // 15d: aload 0
      // 15e: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 161: aload 2
      // 162: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 165: getstatic com/l7tech/objectmodel/EntityType.JDBC_CONNECTION Lcom/l7tech/objectmodel/EntityType;
      // 168: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 16d: iand
      // 16e: istore 6
      // 170: iload 6
      // 172: aload 0
      // 173: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 176: aload 2
      // 177: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 17a: getstatic com/l7tech/objectmodel/EntityType.ENCAPSULATED_ASSERTION Lcom/l7tech/objectmodel/EntityType;
      // 17d: invokeinterface com/l7tech/server/security/rbac/RoleManager.isPermittedForAnyEntityOfType (Lcom/l7tech/identity/User;Lcom/l7tech/gateway/common/security/rbac/OperationType;Lcom/l7tech/objectmodel/EntityType;)Z 4
      // 182: iand
      // 183: istore 6
      // 185: goto 19e
      // 188: astore 7
      // 18a: new com/l7tech/objectmodel/SaveException
      // 18d: dup
      // 18e: getstatic com/l7tech/server/policy/PolicyManagerImpl.z [Ljava/lang/String;
      // 191: astore 8
      // 193: aload 8
      // 195: bipush 33
      // 197: aaload
      // 198: aload 7
      // 19a: invokespecial com/l7tech/objectmodel/SaveException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // 19d: athrow
      // 19e: iload 6
      // 1a0: ifne 1c9
      // 1a3: aload 0
      // 1a4: invokevirtual com/l7tech/server/policy/PolicyManagerImpl.a ()Z
      // 1a7: ifeq 1c9
      // 1aa: goto 1b1
      // 1ad: invokestatic com/l7tech/server/policy/PolicyManagerImpl.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1b0: athrow
      // 1b1: getstatic com/l7tech/server/policy/PolicyManagerImpl.n Ljava/util/logging/Logger;
      // 1b4: getstatic com/l7tech/server/policy/PolicyManagerImpl.z [Ljava/lang/String;
      // 1b7: bipush 4
      // 1b8: aaload
      // 1b9: invokevirtual java/util/logging/Logger.info (Ljava/lang/String;)V
      // 1bc: aload 5
      // 1be: aload 2
      // 1bf: invokevirtual com/l7tech/gateway/common/security/rbac/Role.addAssignedUser (Lcom/l7tech/identity/User;)V
      // 1c2: goto 1c9
      // 1c5: invokestatic com/l7tech/server/policy/PolicyManagerImpl.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1c8: athrow
      // 1c9: aload 0
      // 1ca: getfield com/l7tech/server/policy/PolicyManagerImpl.u Lcom/l7tech/server/security/rbac/RoleManager;
      // 1cd: aload 5
      // 1cf: invokeinterface com/l7tech/server/security/rbac/RoleManager.save (Lcom/l7tech/objectmodel/PersistentEntity;)Lcom/l7tech/objectmodel/Goid; 2
      // 1d4: pop
      // 1d5: return
      // try (39 -> 84): 85 com/l7tech/objectmodel/FindException
      // try (119 -> 171): 172 com/l7tech/objectmodel/FindException
      // try (183 -> 188): 189 com/l7tech/objectmodel/FindException
      // try (185 -> 199): 200 com/l7tech/objectmodel/FindException
   }

   private boolean a() {
      return ConfigFactory.getBooleanProperty(z[26], true);
   }

   @Transactional(propagation = Propagation.SUPPORTS)
   public Class<? extends Entity> getImpClass() {
      return Policy.class;
   }

   @Transactional(propagation = Propagation.SUPPORTS)
   @Override
   public Class<? extends Entity> getInterfaceClass() {
      return Policy.class;
   }

   @Transactional(propagation = Propagation.SUPPORTS)
   @Override
   public String getTableName() {
      return z[15];
   }

   protected PolicyHeader newHeader(Policy var1) {
      return new PolicyHeader(var1);
   }

   @Override
   protected Predicate doFindHeaderPredicate(Predicate var1, CriteriaBuilder var2, Root<Policy> var3) {
      return var2.and(var1, var2.equal(var3.get(z[24]), PolicyType.INCLUDE_FRAGMENT));
   }

   protected Collection<Map<String, Object>> getUniqueConstraints(Policy var1) {
      ArrayList var2 = new ArrayList();
      HashMap var3 = new HashMap();

      label40: {
         try {
            var3.put(z[12], var1.getName());
            var2.add(var3);
            if (var1.getType() != PolicyType.GLOBAL_FRAGMENT || r) {
               break label40;
            }
         } catch (IllegalArgumentException var8) {
            throw a(var8);
         }

         HashMap var4 = new HashMap();

         try {
            var4.put(z[19], PolicyType.GLOBAL_FRAGMENT);
            if (var1.getInternalTag() != null) {
               var4.put(z[32], var1.getInternalTag());
            }
         } catch (IllegalArgumentException var7) {
            throw a(var7);
         }

         var2.add(var4);
      }

      if (var1.getType() == PolicyType.INTERNAL) {
         String var9 = var1.getInternalTag();
         if (PolicyType.getAuditMessageFilterTags().contains(var9)) {
            HashMap var5 = new HashMap();
            String[] var6 = z;
            var5.put(var6[24], PolicyType.INTERNAL);
            var5.put(var6[7], var9);
            var2.add(var5);
         }
      }

      return var2;
   }

   @Override
   protected UniqueType getUniqueType() {
      return UniqueType.OTHER;
   }

   static {
      String[] var5 = new String[34];
      int var3 = 0;
      String var2 = "J#5\u00178?s}l#\u001392?)9.\u0012-$1g)3\bZ\\?%\t/q5z?)\u001c240)8/[(91)7p\u0006|#;e)`\u0013='1)8(\u001e|06` )\u000f%q fl2\u001e=5x)90\u001f=%1)-.\u001f|51e)4\u001e|%<ll;J!q$f )\u0018%\u007f\t5(%\u001d=$8}r\u001fY#,\u0012?(t`?`\t9 !`>%\u001f|3!}l-\u0012/\"=g+n\"H?3\u0012;?=g+`\u0018)#&l\"4[\t\"1{l4\u0014|?1~l\u0012\u001404/j#-U0f l/(U/4&\u007f)2U,>8`/9U1$8}%0\u00179\u00168f.!\u0017\f>8`/)\u001e/\u000bD-.\u001a;4tr|=[\u000b`\"4\u001e.?5e\u0018!\u001c\u0006Y#,\u0012?(>H>'\u000e14:}l&\u0014.q\u0014G#45)=8)<!\t=<1})2[{t'.l/\u001d|t''i3[1$'}l.\u0014(q6ll.\u000e0=\u0013J>%\u001a(8:nl.\u001e+q\u0006f %A|\u0006Y#,\u0012?(\u0004g--\u001e'J#5\u00178?s}l3\u001a*4ty#,\u0012?(t|\"$\u001e.q&f#4[:>8m)2U%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/8.45})\u0006y#,\u0012?(\u0018J#5\u00178?s}l5\u000b80 ll\u0010\u0014087pv`\u0007)dc\u0000m,}\u0016J#5\u00178?s}l3\u001a*4tY#,\u0012?(n)\u0004}50\u001e\u00065%.\u0012(o\u0004g--\u001e\u0018J#5\u00178?s}l$\u001e04 ll\u0010\u0014087pv`\u001cJ#5\u00178?s}l&\u001225t[#,\u001e|%;)>%\u0015=<1\u0004}50\u001e\u0006j#.\u001d56%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/:/\"=n\"=!s|F\u0002\r#.7gJp`f1k=\\|xz#shDaq/91`'tr\u000fU(\u001b'8}tT0\u001b:q\u000b5$6pVe\f\t#\u0010i_u%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/8.45})\t5(%\u001d=$8}r\u0018D-.\u001a;4tr|=[\f>8`/9[tr/81i*j#-T0f l/(T/4&\u007f)2T,>8`/9T\f>8`/96=?5n)221!8";
      int var4 = "J#5\u00178?s}l#\u001392?)9.\u0012-$1g)3\bZ\\?%\t/q5z?)\u001c240)8/[(91)7p\u0006|#;e)`\u0013='1)8(\u001e|06` )\u000f%q fl2\u001e=5x)90\u001f=%1)-.\u001f|51e)4\u001e|%<ll;J!q$f )\u0018%\u007f\t5(%\u001d=$8}r\u001fY#,\u0012?(t`?`\t9 !`>%\u001f|3!}l-\u0012/\"=g+n\"H?3\u0012;?=g+`\u0018)#&l\"4[\t\"1{l4\u0014|?1~l\u0012\u001404/j#-U0f l/(U/4&\u007f)2U,>8`/9U1$8}%0\u00179\u00168f.!\u0017\f>8`/)\u001e/\u000bD-.\u001a;4tr|=[\u000b`\"4\u001e.?5e\u0018!\u001c\u0006Y#,\u0012?(>H>'\u000e14:}l&\u0014.q\u0014G#45)=8)<!\t=<1})2[{t'.l/\u001d|t''i3[1$'}l.\u0014(q6ll.\u000e0=\u0013J>%\u001a(8:nl.\u001e+q\u0006f %A|\u0006Y#,\u0012?(\u0004g--\u001e'J#5\u00178?s}l3\u001a*4ty#,\u0012?(t|\"$\u001e.q&f#4[:>8m)2U%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/8.45})\u0006y#,\u0012?(\u0018J#5\u00178?s}l5\u000b80 ll\u0010\u0014087pv`\u0007)dc\u0000m,}\u0016J#5\u00178?s}l3\u001a*4tY#,\u0012?(n)\u0004}50\u001e\u00065%.\u0012(o\u0004g--\u001e\u0018J#5\u00178?s}l$\u001e04 ll\u0010\u0014087pv`\u001cJ#5\u00178?s}l&\u001225t[#,\u001e|%;)>%\u0015=<1\u0004}50\u001e\u0006j#.\u001d56%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/:/\"=n\"=!s|F\u0002\r#.7gJp`f1k=\\|xz#shDaq/91`'tr\u000fU(\u001b'8}tT0\u001b:q\u000b5$6pVe\f\t#\u0010i_u%{.!\u0018r0!}#\u0012\u001404zd-.\u001a;4\u0004f )\u0018%\u007f5|8/8.45})\t5(%\u001d=$8}r\u0018D-.\u001a;4tr|=[\f>8`/9[tr/81i*j#-T0f l/(T/4&\u007f)2T,>8`/9T\f>8`/96=?5n)221!8"
         .length();
      char var1 = 25;
      int var7 = -1;

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

         while (true) {
            String var9 = c(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var9;
                  if ((var7 += var1) >= var4) {
                     z = var5;
                     s = z[14];
                     n = Logger.getLogger(PolicyManagerImpl.class.getName());
                     String[] var8 = z;
                     q = Pattern.compile(MessageFormat.format(var8[27], var8[11]));
                     r = ConfigFactory.getBooleanProperty(var8[5], false);
                     return;
                  }

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

                  var2 = "\u000fM[qAPZ\nwNs!%LZxWP\u001c\u0012\u0003HqG\u001e^\u001eJ\\`ZP\\FSJf^WH\u0015J@z@";
                  var4 = "\u000fM[qAPZ\nwNs!%LZxWP\u001c\u0012\u0003HqG\u001e^\u001eJ\\`ZP\\FSJf^WH\u0015J@z@".length();
                  var1 = 11;
                  var7 = -1;
            }

            var10000 = 39;
            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] ^ 28);
      }

      return var10000;
   }

   private static String c(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 -> 65;
            case 1 -> 4;
            case 2 -> 8;
            case 3 -> 51;
            case 4 -> 20;
            case 5 -> 25;
            default -> 28;
         });
      }

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