package com.l7tech.gateway.common;

import com.l7tech.gateway.common.security.rbac.AttemptedCreate;
import com.l7tech.gateway.common.security.rbac.AttemptedDeleteAll;
import com.l7tech.gateway.common.security.rbac.AttemptedOperation;
import com.l7tech.gateway.common.security.rbac.AttemptedReadAny;
import com.l7tech.gateway.common.security.rbac.AttemptedUpdateAny;
import com.l7tech.gateway.common.security.rbac.EntityProtectionInfo;
import com.l7tech.gateway.common.security.rbac.Permission;
import com.l7tech.gateway.common.security.rbac.RequiredPermission;
import com.l7tech.gateway.common.security.rbac.RequiredPermissionSet;
import java.util.Collection;
import java.util.Map;

public abstract class Authorizer {
   public boolean hasPermission(Class<?> var1) {
      Authorizer var10000;
      try {
         var10000 = this;
         if (var1 == null) {
            return this.hasPermission((RequiredPermissionSet)null);
         }
      } catch (RuntimeException var2) {
         throw a(var2);
      }

      return var10000.hasPermission(var1.getAnnotation(RequiredPermissionSet.class));
   }

   public boolean hasPermission(RequiredPermissionSet var1) {
      boolean var2 = false;

      label60: {
         try {
            if (var1 == null) {
               return var2;
            }

            if (RequiredPermissionSet.Type.ANY != var1.type()) {
               break label60;
            }
         } catch (RuntimeException var8) {
            throw a(var8);
         }

         for (RequiredPermission var6 : var1.requiredPermissions()) {
            if (this.hasPermission(this.a(var6))) {
               var2 = true;
               return var2;
            }
         }

         return var2;
      }

      boolean var9 = true;

      for (RequiredPermission var7 : var1.requiredPermissions()) {
         if (!this.hasPermission(this.a(var7))) {
            var9 = false;
            break;
         }
      }

      return var9;
   }

   public boolean hasPermission(AttemptedOperation 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:
      // 000: aload 0
      // 001: invokevirtual com/l7tech/gateway/common/Authorizer.getUserPermissions ()Ljava/util/Collection;
      // 004: astore 2
      // 005: aload 1
      // 006: ifnull 024
      // 009: aload 2
      // 00a: ifnull 024
      // 00d: goto 014
      // 010: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 013: athrow
      // 014: aload 2
      // 015: invokeinterface java/util/Collection.isEmpty ()Z 1
      // 01a: ifeq 02a
      // 01d: goto 024
      // 020: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 023: athrow
      // 024: bipush 0
      // 025: ireturn
      // 026: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 029: athrow
      // 02a: aload 0
      // 02b: invokevirtual com/l7tech/gateway/common/Authorizer.getProtectedEntities ()Ljava/util/Map;
      // 02e: astore 3
      // 02f: aload 1
      // 030: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedOperation.getOperation ()Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 033: astore 4
      // 035: aload 4
      // 037: ifnull 0b6
      // 03a: getstatic com/l7tech/gateway/common/security/rbac/OperationType.READ Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 03d: aload 4
      // 03f: invokevirtual com/l7tech/gateway/common/security/rbac/OperationType.equals (Ljava/lang/Object;)Z
      // 042: ifne 0b6
      // 045: goto 04c
      // 048: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 04b: athrow
      // 04c: aload 1
      // 04d: instanceof com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation
      // 050: ifeq 0b6
      // 053: goto 05a
      // 056: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 059: athrow
      // 05a: aload 1
      // 05b: checkcast com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation
      // 05e: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation.getEntity ()Lcom/l7tech/objectmodel/Entity;
      // 061: astore 5
      // 063: aload 5
      // 065: ifnull 0b6
      // 068: aload 5
      // 06a: invokeinterface com/l7tech/objectmodel/Entity.getId ()Ljava/lang/String; 1
      // 06f: astore 6
      // 071: aload 6
      // 073: ifnonnull 07e
      // 076: aconst_null
      // 077: goto 089
      // 07a: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 07d: athrow
      // 07e: aload 3
      // 07f: aload 6
      // 081: invokeinterface java/util/Map.get (Ljava/lang/Object;)Ljava/lang/Object; 2
      // 086: checkcast com/l7tech/gateway/common/security/rbac/EntityProtectionInfo
      // 089: astore 7
      // 08b: aload 7
      // 08d: ifnull 0b6
      // 090: aload 7
      // 092: aload 5
      // 094: invokevirtual com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.matchesTypeOf (Lcom/l7tech/objectmodel/Entity;)Z
      // 097: ifeq 0b6
      // 09a: goto 0a1
      // 09d: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 0a0: athrow
      // 0a1: aload 7
      // 0a3: invokevirtual com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.isReadOnly ()Z
      // 0a6: ifeq 0b6
      // 0a9: goto 0b0
      // 0ac: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 0af: athrow
      // 0b0: bipush 0
      // 0b1: ireturn
      // 0b2: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 0b5: athrow
      // 0b6: aload 2
      // 0b7: invokeinterface java/util/Collection.iterator ()Ljava/util/Iterator; 1
      // 0bc: astore 5
      // 0be: aload 5
      // 0c0: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 0c5: ifeq 299
      // 0c8: aload 5
      // 0ca: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 0cf: checkcast com/l7tech/gateway/common/security/rbac/Permission
      // 0d2: astore 6
      // 0d4: aload 6
      // 0d6: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 0d9: getstatic com/l7tech/objectmodel/EntityType.ANY Lcom/l7tech/objectmodel/EntityType;
      // 0dc: if_acmpeq 0f9
      // 0df: aload 6
      // 0e1: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 0e4: aload 1
      // 0e5: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedOperation.getType ()Lcom/l7tech/objectmodel/EntityType;
      // 0e8: if_acmpeq 0f9
      // 0eb: goto 0f2
      // 0ee: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 0f1: athrow
      // 0f2: goto 0be
      // 0f5: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 0f8: athrow
      // 0f9: aload 6
      // 0fb: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getOperation ()Lcom/l7tech/gateway/common/security/rbac/OperationType;
      // 0fe: aload 4
      // 100: if_acmpeq 113
      // 103: aload 1
      // 104: instanceof com/l7tech/gateway/common/security/rbac/AttemptedAnyOperation
      // 107: ifeq 0be
      // 10a: goto 111
      // 10d: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 110: athrow
      // 111: bipush 1
      // 112: ireturn
      // 113: aload 1
      // 114: instanceof com/l7tech/gateway/common/security/rbac/AttemptedOtherSpecific
      // 117: ifeq 13f
      // 11a: aload 1
      // 11b: checkcast com/l7tech/gateway/common/security/rbac/AttemptedOtherSpecific
      // 11e: astore 7
      // 120: aload 6
      // 122: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getOtherOperationName ()Ljava/lang/String;
      // 125: ifnull 0be
      // 128: aload 6
      // 12a: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getOtherOperationName ()Ljava/lang/String;
      // 12d: aload 7
      // 12f: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedOtherSpecific.getOtherOperationName ()Ljava/lang/String;
      // 132: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 135: ifne 13f
      // 138: goto 0be
      // 13b: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 13e: athrow
      // 13f: aload 1
      // 140: instanceof com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation
      // 143: ifeq 1da
      // 146: aload 6
      // 148: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 14b: ifnull 169
      // 14e: goto 155
      // 151: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 154: athrow
      // 155: aload 6
      // 157: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 15a: invokeinterface java/util/Set.size ()I 1
      // 15f: ifne 16f
      // 162: goto 169
      // 165: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 168: athrow
      // 169: bipush 1
      // 16a: ireturn
      // 16b: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 16e: athrow
      // 16f: aload 1
      // 170: checkcast com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation
      // 173: astore 7
      // 175: aload 7
      // 177: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation.getEntity ()Lcom/l7tech/objectmodel/Entity;
      // 17a: ifnull 1d7
      // 17d: bipush 1
      // 17e: istore 8
      // 180: aload 6
      // 182: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 185: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 18a: astore 9
      // 18c: aload 9
      // 18e: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 193: ifeq 1cc
      // 196: aload 9
      // 198: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 19d: checkcast com/l7tech/gateway/common/security/rbac/ScopePredicate
      // 1a0: astore 10
      // 1a2: aload 10
      // 1a4: instanceof com/l7tech/gateway/common/security/rbac/ScopeEvaluator
      // 1a7: ifeq 1c9
      // 1aa: aload 10
      // 1ac: checkcast com/l7tech/gateway/common/security/rbac/ScopeEvaluator
      // 1af: aload 7
      // 1b1: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedEntityOperation.getEntity ()Lcom/l7tech/objectmodel/Entity;
      // 1b4: invokeinterface com/l7tech/gateway/common/security/rbac/ScopeEvaluator.matches (Lcom/l7tech/objectmodel/Entity;)Z 2
      // 1b9: ifne 1c9
      // 1bc: goto 1c3
      // 1bf: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 1c2: athrow
      // 1c3: bipush 0
      // 1c4: istore 8
      // 1c6: goto 1cc
      // 1c9: goto 18c
      // 1cc: iload 8
      // 1ce: ifeq 1d7
      // 1d1: bipush 1
      // 1d2: ireturn
      // 1d3: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 1d6: athrow
      // 1d7: goto 296
      // 1da: aload 1
      // 1db: instanceof com/l7tech/gateway/common/security/rbac/AttemptedCreate
      // 1de: ifeq 1e7
      // 1e1: bipush 1
      // 1e2: ireturn
      // 1e3: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 1e6: athrow
      // 1e7: aload 1
      // 1e8: instanceof com/l7tech/gateway/common/security/rbac/AttemptedReadAny
      // 1eb: ifeq 1f4
      // 1ee: bipush 1
      // 1ef: ireturn
      // 1f0: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 1f3: athrow
      // 1f4: aload 1
      // 1f5: instanceof com/l7tech/gateway/common/security/rbac/AttemptedReadAll
      // 1f8: ifeq 215
      // 1fb: aload 6
      // 1fd: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 200: invokeinterface java/util/Set.isEmpty ()Z 1
      // 205: ifeq 296
      // 208: goto 20f
      // 20b: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 20e: athrow
      // 20f: bipush 1
      // 210: ireturn
      // 211: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 214: athrow
      // 215: aload 1
      // 216: instanceof com/l7tech/gateway/common/security/rbac/AttemptedDeleteAll
      // 219: ifeq 236
      // 21c: aload 6
      // 21e: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 221: invokeinterface java/util/Set.isEmpty ()Z 1
      // 226: ifeq 296
      // 229: goto 230
      // 22c: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 22f: athrow
      // 230: bipush 1
      // 231: ireturn
      // 232: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 235: athrow
      // 236: aload 1
      // 237: instanceof com/l7tech/gateway/common/security/rbac/AttemptedUpdateAny
      // 23a: ifeq 243
      // 23d: bipush 1
      // 23e: ireturn
      // 23f: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 242: athrow
      // 243: aload 1
      // 244: instanceof com/l7tech/gateway/common/security/rbac/AttemptedUpdateAll
      // 247: ifeq 264
      // 24a: aload 6
      // 24c: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getScope ()Ljava/util/Set;
      // 24f: invokeinterface java/util/Set.isEmpty ()Z 1
      // 254: ifeq 296
      // 257: goto 25e
      // 25a: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 25d: athrow
      // 25e: bipush 1
      // 25f: ireturn
      // 260: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 263: athrow
      // 264: aload 1
      // 265: instanceof com/l7tech/gateway/common/security/rbac/AttemptedOther
      // 268: ifeq 296
      // 26b: aload 1
      // 26c: checkcast com/l7tech/gateway/common/security/rbac/AttemptedOther
      // 26f: astore 7
      // 271: aload 6
      // 273: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getOtherOperationName ()Ljava/lang/String;
      // 276: ifnull 296
      // 279: aload 6
      // 27b: invokevirtual com/l7tech/gateway/common/security/rbac/Permission.getOtherOperationName ()Ljava/lang/String;
      // 27e: aload 7
      // 280: invokevirtual com/l7tech/gateway/common/security/rbac/AttemptedOther.getOtherOperationName ()Ljava/lang/String;
      // 283: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 286: ifeq 296
      // 289: goto 290
      // 28c: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 28f: athrow
      // 290: bipush 1
      // 291: ireturn
      // 292: invokestatic com/l7tech/gateway/common/Authorizer.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 295: athrow
      // 296: goto 0be
      // 299: bipush 0
      // 29a: ireturn
      // try (3 -> 7): 8 java/lang/RuntimeException
      // try (5 -> 13): 14 java/lang/RuntimeException
      // try (10 -> 18): 18 java/lang/RuntimeException
      // try (26 -> 32): 33 java/lang/RuntimeException
      // try (28 -> 38): 39 java/lang/RuntimeException
      // try (50 -> 54): 54 java/lang/RuntimeException
      // try (61 -> 67): 68 java/lang/RuntimeException
      // try (63 -> 73): 74 java/lang/RuntimeException
      // try (70 -> 78): 78 java/lang/RuntimeException
      // try (90 -> 99): 100 java/lang/RuntimeException
      // try (94 -> 103): 103 java/lang/RuntimeException
      // try (105 -> 112): 113 java/lang/RuntimeException
      // try (126 -> 133): 133 java/lang/RuntimeException
      // try (135 -> 141): 142 java/lang/RuntimeException
      // try (138 -> 148): 149 java/lang/RuntimeException
      // try (144 -> 153): 153 java/lang/RuntimeException
      // try (174 -> 183): 184 java/lang/RuntimeException
      // try (190 -> 194): 194 java/lang/RuntimeException
      // try (197 -> 202): 202 java/lang/RuntimeException
      // try (204 -> 209): 209 java/lang/RuntimeException
      // try (211 -> 218): 219 java/lang/RuntimeException
      // try (214 -> 223): 223 java/lang/RuntimeException
      // try (225 -> 232): 233 java/lang/RuntimeException
      // try (228 -> 237): 237 java/lang/RuntimeException
      // try (239 -> 244): 244 java/lang/RuntimeException
      // try (246 -> 253): 254 java/lang/RuntimeException
      // try (249 -> 258): 258 java/lang/RuntimeException
      // try (266 -> 275): 276 java/lang/RuntimeException
      // try (269 -> 280): 280 java/lang/RuntimeException
   }

   public abstract Collection<Permission> getUserPermissions() throws RuntimeException;

   public abstract Map<String, EntityProtectionInfo> getProtectedEntities() throws RuntimeException;

   private AttemptedOperation a(RequiredPermission var1) {
      AttemptedOperation var2 = null;
      switch (a.a[var1.operationType().ordinal()]) {
         case 1:
            var2 = new AttemptedCreate(var1.entityType());
            break;
         case 2:
            var2 = new AttemptedReadAny(var1.entityType());
            break;
         case 3:
            var2 = new AttemptedUpdateAny(var1.entityType());
            break;
         case 4:
            var2 = new AttemptedDeleteAll(var1.entityType());
      }

      return var2;
   }

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