package com.l7tech.server.security.rbac;

import com.l7tech.identity.Group;
import com.l7tech.identity.IdentityProvider;
import com.l7tech.identity.User;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.IdentityHeader;
import com.l7tech.objectmodel.UpdateException;
import java.util.Collections;
import java.util.Set;
import org.jetbrains.annotations.NotNull;

public abstract class RoleManagerIdentitySourceSupport implements RoleManagerIdentitySource {
   protected RoleManager roleManager;
   private static final String[] v;

   @Override
   public void validateRoleAssignments() throws UpdateException {
      // $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/server/security/rbac/RoleManagerIdentitySourceSupport.getAdminIdentityProviders ()Ljava/util/Set;
      // 004: astore 1
      // 005: bipush 0
      // 006: istore 2
      // 007: aload 1
      // 008: invokeinterface java/util/Set.isEmpty ()Z 1
      // 00d: ifne 025
      // 010: aload 1
      // 011: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 016: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 01b: checkcast com/l7tech/identity/IdentityProvider
      // 01e: goto 026
      // 021: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 024: athrow
      // 025: aconst_null
      // 026: astore 3
      // 027: aload 3
      // 028: instanceof com/l7tech/server/identity/internal/InternalIdentityProvider
      // 02b: ifeq 21b
      // 02e: aload 3
      // 02f: checkcast com/l7tech/server/identity/internal/InternalIdentityProvider
      // 032: astore 4
      // 034: aload 4
      // 036: invokeinterface com/l7tech/server/identity/internal/InternalIdentityProvider.getUserManager ()Lcom/l7tech/identity/UserManager; 1
      // 03b: checkcast com/l7tech/server/identity/internal/InternalUserManager
      // 03e: astore 5
      // 040: aload 4
      // 042: invokeinterface com/l7tech/server/identity/internal/InternalIdentityProvider.getGroupManager ()Lcom/l7tech/identity/GroupManager; 1
      // 047: checkcast com/l7tech/server/identity/internal/InternalGroupManager
      // 04a: astore 6
      // 04c: aload 0
      // 04d: getfield com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.roleManager Lcom/l7tech/server/security/rbac/RoleManager;
      // 050: getstatic com/l7tech/gateway/common/security/rbac/Role$Tag.ADMIN Lcom/l7tech/gateway/common/security/rbac/Role$Tag;
      // 053: invokeinterface com/l7tech/server/security/rbac/RoleManager.findByTag (Lcom/l7tech/gateway/common/security/rbac/Role$Tag;)Lcom/l7tech/gateway/common/security/rbac/Role; 2
      // 058: astore 7
      // 05a: aload 7
      // 05c: ifnull 21b
      // 05f: new java/util/HashSet
      // 062: dup
      // 063: invokespecial java/util/HashSet.<init> ()V
      // 066: astore 8
      // 068: aload 7
      // 06a: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getRoleAssignments ()Ljava/util/Set;
      // 06d: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 072: astore 9
      // 074: aload 9
      // 076: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 07b: ifeq 102
      // 07e: aload 9
      // 080: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 085: checkcast com/l7tech/gateway/common/security/rbac/RoleAssignment
      // 088: astore 10
      // 08a: aload 10
      // 08c: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getProviderId ()Lcom/l7tech/objectmodel/Goid;
      // 08f: aload 4
      // 091: invokeinterface com/l7tech/server/identity/internal/InternalIdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 096: invokevirtual com/l7tech/identity/IdentityProviderConfig.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 099: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 09c: ifeq 0ff
      // 09f: getstatic com/l7tech/objectmodel/EntityType.USER Lcom/l7tech/objectmodel/EntityType;
      // 0a2: invokevirtual com/l7tech/objectmodel/EntityType.getName ()Ljava/lang/String;
      // 0a5: aload 10
      // 0a7: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getEntityType ()Ljava/lang/String;
      // 0aa: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 0ad: ifeq 0ff
      // 0b0: goto 0b7
      // 0b3: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 0b6: athrow
      // 0b7: aload 5
      // 0b9: aload 10
      // 0bb: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 0be: invokeinterface com/l7tech/server/identity/internal/InternalUserManager.findByPrimaryKey (Ljava/lang/String;)Lcom/l7tech/identity/User; 2
      // 0c3: checkcast com/l7tech/identity/internal/InternalUser
      // 0c6: astore 11
      // 0c8: aload 11
      // 0ca: ifnull 0f2
      // 0cd: aload 11
      // 0cf: invokevirtual com/l7tech/identity/internal/InternalUser.isEnabled ()Z
      // 0d2: ifeq 0f2
      // 0d5: goto 0dc
      // 0d8: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 0db: athrow
      // 0dc: aload 11
      // 0de: invokevirtual com/l7tech/identity/internal/InternalUser.getExpiration ()J
      // 0e1: lconst_0
      // 0e2: lcmp
      // 0e3: ifge 0f2
      // 0e6: goto 0ed
      // 0e9: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 0ec: athrow
      // 0ed: bipush 1
      // 0ee: istore 2
      // 0ef: goto 102
      // 0f2: aload 8
      // 0f4: aload 10
      // 0f6: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 0f9: invokeinterface java/util/Set.add (Ljava/lang/Object;)Z 2
      // 0fe: pop
      // 0ff: goto 074
      // 102: iload 2
      // 103: ifne 206
      // 106: aload 7
      // 108: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getRoleAssignments ()Ljava/util/Set;
      // 10b: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 110: astore 9
      // 112: aload 9
      // 114: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 119: ifeq 206
      // 11c: aload 9
      // 11e: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 123: checkcast com/l7tech/gateway/common/security/rbac/RoleAssignment
      // 126: astore 10
      // 128: aload 10
      // 12a: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getProviderId ()Lcom/l7tech/objectmodel/Goid;
      // 12d: aload 4
      // 12f: invokeinterface com/l7tech/server/identity/internal/InternalIdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 134: invokevirtual com/l7tech/identity/IdentityProviderConfig.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 137: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 13a: ifeq 203
      // 13d: getstatic com/l7tech/objectmodel/EntityType.GROUP Lcom/l7tech/objectmodel/EntityType;
      // 140: invokevirtual com/l7tech/objectmodel/EntityType.getName ()Ljava/lang/String;
      // 143: aload 10
      // 145: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getEntityType ()Ljava/lang/String;
      // 148: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 14b: ifeq 203
      // 14e: goto 155
      // 151: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 154: athrow
      // 155: aload 6
      // 157: aload 10
      // 159: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 15c: invokeinterface com/l7tech/server/identity/internal/InternalGroupManager.findByPrimaryKey (Ljava/lang/String;)Lcom/l7tech/identity/Group; 2
      // 161: checkcast com/l7tech/identity/internal/InternalGroup
      // 164: astore 11
      // 166: aload 11
      // 168: invokevirtual com/l7tech/identity/internal/InternalGroup.isEnabled ()Z
      // 16b: ifne 175
      // 16e: goto 112
      // 171: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 174: athrow
      // 175: aload 6
      // 177: aload 10
      // 179: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 17c: invokeinterface com/l7tech/server/identity/internal/InternalGroupManager.getUserHeaders (Ljava/lang/String;)Ljava/util/Set; 2
      // 181: astore 12
      // 183: aload 12
      // 185: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 18a: astore 13
      // 18c: aload 13
      // 18e: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 193: ifeq 203
      // 196: aload 13
      // 198: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 19d: checkcast com/l7tech/objectmodel/IdentityHeader
      // 1a0: astore 14
      // 1a2: aload 8
      // 1a4: aload 14
      // 1a6: invokevirtual com/l7tech/objectmodel/IdentityHeader.getStrId ()Ljava/lang/String;
      // 1a9: invokeinterface java/util/Set.contains (Ljava/lang/Object;)Z 2
      // 1ae: ifeq 1b8
      // 1b1: goto 18c
      // 1b4: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 1b7: athrow
      // 1b8: aload 5
      // 1ba: aload 14
      // 1bc: invokevirtual com/l7tech/objectmodel/IdentityHeader.getStrId ()Ljava/lang/String;
      // 1bf: invokeinterface com/l7tech/server/identity/internal/InternalUserManager.findByPrimaryKey (Ljava/lang/String;)Lcom/l7tech/identity/User; 2
      // 1c4: checkcast com/l7tech/identity/internal/InternalUser
      // 1c7: astore 15
      // 1c9: aload 15
      // 1cb: ifnull 1f3
      // 1ce: aload 15
      // 1d0: invokevirtual com/l7tech/identity/internal/InternalUser.isEnabled ()Z
      // 1d3: ifeq 1f3
      // 1d6: goto 1dd
      // 1d9: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 1dc: athrow
      // 1dd: aload 15
      // 1df: invokevirtual com/l7tech/identity/internal/InternalUser.getExpiration ()J
      // 1e2: lconst_0
      // 1e3: lcmp
      // 1e4: ifge 1f3
      // 1e7: goto 1ee
      // 1ea: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 1ed: athrow
      // 1ee: bipush 1
      // 1ef: istore 2
      // 1f0: goto 203
      // 1f3: aload 8
      // 1f5: aload 10
      // 1f7: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 1fa: invokeinterface java/util/Set.add (Ljava/lang/Object;)Z 2
      // 1ff: pop
      // 200: goto 18c
      // 203: goto 112
      // 206: iload 2
      // 207: ifne 21b
      // 20a: new com/l7tech/objectmodel/UpdateException
      // 20d: dup
      // 20e: getstatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.v [Ljava/lang/String;
      // 211: bipush 2
      // 212: aaload
      // 213: invokespecial com/l7tech/objectmodel/UpdateException.<init> (Ljava/lang/String;)V
      // 216: athrow
      // 217: invokestatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.a (Lcom/l7tech/objectmodel/FindException;)Lcom/l7tech/objectmodel/FindException;
      // 21a: athrow
      // 21b: goto 22d
      // 21e: astore 1
      // 21f: new com/l7tech/objectmodel/UpdateException
      // 222: dup
      // 223: getstatic com/l7tech/server/security/rbac/RoleManagerIdentitySourceSupport.v [Ljava/lang/String;
      // 226: bipush 0
      // 227: aaload
      // 228: aload 1
      // 229: invokespecial com/l7tech/objectmodel/UpdateException.<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
      // 22c: athrow
      // 22d: return
      // try (196 -> 205): 205 com/l7tech/objectmodel/FindException
      // try (172 -> 183): 184 com/l7tech/objectmodel/FindException
      // try (170 -> 175): 176 com/l7tech/objectmodel/FindException
      // try (156 -> 162): 162 com/l7tech/objectmodel/FindException
      // try (135 -> 139): 139 com/l7tech/objectmodel/FindException
      // try (113 -> 126): 127 com/l7tech/objectmodel/FindException
      // try (77 -> 88): 89 com/l7tech/objectmodel/FindException
      // try (75 -> 80): 81 com/l7tech/objectmodel/FindException
      // try (53 -> 66): 67 com/l7tech/objectmodel/FindException
      // try (5 -> 13): 13 com/l7tech/objectmodel/FindException
      // try (0 -> 207): 208 com/l7tech/objectmodel/FindException
   }

   @Override
   public Set<IdentityHeader> getGroups(User var1, boolean var2) throws FindException {
      return Collections.emptySet();
   }

   @Override
   public Set<IdentityHeader> getGroups(@NotNull Group var1) throws FindException {
      try {
         if (var1 == null) {
            a(0);
         }
      } catch (FindException var2) {
         throw a(var2);
      }

      return Collections.emptySet();
   }

   protected abstract Set<IdentityProvider> getAdminIdentityProviders();

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

   static {
      String[] var5 = new String[6];
      int var3 = 0;
      String var2 = "8Ul!6Y&\u0015B}%-\u0017\"]Uq\"!Y$\u000eTw)*\u001c(\u0018Ij=j\u0005\u001aUq;4x<S>\"!\u00186\t\u0007q !Y,\u0013S{<*\u0018)]Rm+6Y2\u0014Svn*\u0016e\u0018_n'6\u00181\u0014Hpn)\f6\t\u0007|+d\u00186\u000eNy !\u001de\tH>:,\u001ce\u001cCs'*\u00106\tU\u007f:-\u000f ]Uq\"!Ym\u001eFpn&\u001ce\u000bN\u007fn#\u000b*\bW>/7\n,\u001aIs+*\rlS><Uy;)\u001c+\t\u0007x!6Y\u00053Hj\u00001\u0015)]W\u007f<%\u0014 \tBlnc\\6Z\u0007q(d\\6S\u0002mn)\f6\t\u0007p!0Y'\u0018\u0007p;(\u0015";
      int var4 = "8Ul!6Y&\u0015B}%-\u0017\"]Uq\"!Y$\u000eTw)*\u001c(\u0018Ij=j\u0005\u001aUq;4x<S>\"!\u00186\t\u0007q !Y,\u0013S{<*\u0018)]Rm+6Y2\u0014Svn*\u0016e\u0018_n'6\u00181\u0014Hpn)\f6\t\u0007|+d\u00186\u000eNy !\u001de\tH>:,\u001ce\u001cCs'*\u00106\tU\u007f:-\u000f ]Uq\"!Ym\u001eFpn&\u001ce\u000bN\u007fn#\u000b*\bW>/7\n,\u001aIs+*\rlS><Uy;)\u001c+\t\u0007x!6Y\u00053Hj\u00001\u0015)]W\u007f<%\u0014 \tBlnc\\6Z\u0007q(d\\6S\u0002mn)\f6\t\u0007p!0Y'\u0018\u0007p;(\u0015"
         .length();
      char var1 = '!';
      int var7 = -1;

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

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

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

                  var2 = "k=\u0006\u0014];Dm1\u0003\u0014BiB~7\u0019\u0014BiS} \u0002OH#Bj3\b\u0014cc\\m\u001f\nUPkUz\u001b\u000f^_xY|+8TD~Sm\u0001\u001eKAcB|\to7\u001f|CcEx!";
                  var4 = "k=\u0006\u0014];Dm1\u0003\u0014BiB~7\u0019\u0014BiS} \u0002OH#Bj3\b\u0014cc\\m\u001f\nUPkUz\u001b\u000f^_xY|+8TD~Sm\u0001\u001eKAcB|\to7\u001f|CcEx!"
                     .length();
                  var1 = '@';
                  var7 = -1;
            }

            var10000 = 77;
            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] ^ 125);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 69;
            case 1 -> 31;
            case 2 -> 38;
            case 3 -> 118;
            case 4 -> 124;
            case 5 -> 65;
            default -> 125;
         });
      }

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