package com.l7tech.external.assertions.gatewaygraphql.server.data;

import com.l7tech.identity.IdentityProvider;
import com.l7tech.identity.User;
import com.l7tech.objectmodel.EntityHeaderSet;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.IdentityHeader;
import com.l7tech.server.identity.IdentityProviderFactory;
import java.util.logging.Logger;
import lombok.Generated;

public class IdentityProviderHelper {
   @Generated
   private static final Logger a;
   private static final String b;
   private final IdentityProviderFactory c;
   private static final String[] d;

   public IdentityProviderHelper(IdentityProviderFactory var1) {
      this.c = var1;
   }

   public String[] resolveUserByLogin(String param1, String 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:
      // 00: aload 0
      // 01: getfield com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.c Lcom/l7tech/server/identity/IdentityProviderFactory;
      // 04: invokevirtual com/l7tech/server/identity/IdentityProviderFactory.findAllIdentityProviders ()Ljava/util/Collection;
      // 07: invokeinterface java/util/Collection.stream ()Ljava/util/stream/Stream; 1
      // 0c: aload 1
      // 0d: invokedynamic test (Ljava/lang/String;)Ljava/util/function/Predicate; bsm=java/lang/invoke/LambdaMetafactory.metafactory (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; args=[ (Ljava/lang/Object;)Z, com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.lambda$resolveUserByLogin$0 (Ljava/lang/String;Lcom/l7tech/identity/IdentityProvider;)Z, (Lcom/l7tech/identity/IdentityProvider;)Z ]
      // 12: invokeinterface java/util/stream/Stream.filter (Ljava/util/function/Predicate;)Ljava/util/stream/Stream; 2
      // 17: invokeinterface java/util/stream/Stream.findFirst ()Ljava/util/Optional; 1
      // 1c: aconst_null
      // 1d: invokevirtual java/util/Optional.orElse (Ljava/lang/Object;)Ljava/lang/Object;
      // 20: checkcast com/l7tech/identity/IdentityProvider
      // 23: astore 3
      // 24: aload 3
      // 25: ifnull ae
      // 28: getstatic com/l7tech/identity/IdentityProviderType.INTERNAL Lcom/l7tech/identity/IdentityProviderType;
      // 2b: aload 3
      // 2c: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 31: invokevirtual com/l7tech/identity/IdentityProviderConfig.type ()Lcom/l7tech/identity/IdentityProviderType;
      // 34: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 37: ifne 5a
      // 3a: goto 41
      // 3d: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 40: athrow
      // 41: getstatic com/l7tech/identity/IdentityProviderType.FEDERATED Lcom/l7tech/identity/IdentityProviderType;
      // 44: aload 3
      // 45: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 4a: invokevirtual com/l7tech/identity/IdentityProviderConfig.type ()Lcom/l7tech/identity/IdentityProviderType;
      // 4d: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 50: ifeq 96
      // 53: goto 5a
      // 56: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 59: athrow
      // 5a: aload 0
      // 5b: aload 3
      // 5c: aload 2
      // 5d: invokevirtual com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Lcom/l7tech/identity/IdentityProvider;Ljava/lang/String;)Lcom/l7tech/identity/User;
      // 60: astore 4
      // 62: aload 4
      // 64: ifnull 85
      // 67: bipush 2
      // 68: anewarray 107
      // 6b: dup
      // 6c: bipush 0
      // 6d: aload 3
      // 6e: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 73: invokevirtual com/l7tech/identity/IdentityProviderConfig.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 76: invokevirtual com/l7tech/objectmodel/Goid.toHexString ()Ljava/lang/String;
      // 79: aastore
      // 7a: dup
      // 7b: bipush 1
      // 7c: aload 4
      // 7e: invokeinterface com/l7tech/identity/User.getId ()Ljava/lang/String; 1
      // 83: aastore
      // 84: areturn
      // 85: new java/lang/IllegalArgumentException
      // 88: dup
      // 89: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // 8c: astore 5
      // 8e: aload 5
      // 90: bipush 0
      // 91: aaload
      // 92: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // 95: athrow
      // 96: bipush 2
      // 97: anewarray 107
      // 9a: dup
      // 9b: bipush 0
      // 9c: aload 3
      // 9d: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // a2: invokevirtual com/l7tech/identity/IdentityProviderConfig.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // a5: invokevirtual com/l7tech/objectmodel/Goid.toHexString ()Ljava/lang/String;
      // a8: aastore
      // a9: dup
      // aa: bipush 1
      // ab: aload 2
      // ac: aastore
      // ad: areturn
      // ae: new java/lang/IllegalArgumentException
      // b1: dup
      // b2: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // b5: astore 5
      // b7: aload 5
      // b9: bipush 2
      // ba: aaload
      // bb: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // be: athrow
      // bf: astore 3
      // c0: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a Ljava/util/logging/Logger;
      // c3: getstatic java/util/logging/Level.INFO Ljava/util/logging/Level;
      // c6: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // c9: bipush 6
      // cb: aaload
      // cc: bipush 3
      // cd: anewarray 160
      // d0: dup
      // d1: bipush 0
      // d2: aload 1
      // d3: aastore
      // d4: dup
      // d5: bipush 1
      // d6: aload 2
      // d7: aastore
      // d8: dup
      // d9: bipush 2
      // da: aload 3
      // db: invokevirtual java/lang/Exception.getMessage ()Ljava/lang/String;
      // de: aastore
      // df: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;[Ljava/lang/Object;)V
      // e2: bipush 2
      // e3: anewarray 107
      // e6: dup
      // e7: bipush 0
      // e8: aconst_null
      // e9: aastore
      // ea: dup
      // eb: bipush 1
      // ec: aconst_null
      // ed: aastore
      // ee: areturn
      // try (14 -> 29): 30 java/lang/Exception
      // try (12 -> 20): 21 java/lang/Exception
      // try (0 -> 53): 86 java/lang/Exception
      // try (54 -> 76): 86 java/lang/Exception
      // try (77 -> 86): 86 java/lang/Exception
   }

   public String[] resolveUserById(Goid param1, String 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 0
      // 001: getfield com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.c Lcom/l7tech/server/identity/IdentityProviderFactory;
      // 004: aload 1
      // 005: invokevirtual com/l7tech/server/identity/IdentityProviderFactory.getProvider (Lcom/l7tech/objectmodel/Goid;)Lcom/l7tech/identity/IdentityProvider;
      // 008: astore 3
      // 009: aload 3
      // 00a: ifnull 0c4
      // 00d: getstatic com/l7tech/identity/IdentityProviderType.INTERNAL Lcom/l7tech/identity/IdentityProviderType;
      // 010: aload 3
      // 011: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 016: invokevirtual com/l7tech/identity/IdentityProviderConfig.type ()Lcom/l7tech/identity/IdentityProviderType;
      // 019: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 01c: ifne 03f
      // 01f: goto 026
      // 022: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 025: athrow
      // 026: getstatic com/l7tech/identity/IdentityProviderType.FEDERATED Lcom/l7tech/identity/IdentityProviderType;
      // 029: aload 3
      // 02a: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 02f: invokevirtual com/l7tech/identity/IdentityProviderConfig.type ()Lcom/l7tech/identity/IdentityProviderType;
      // 032: invokevirtual java/lang/Object.equals (Ljava/lang/Object;)Z
      // 035: ifeq 0af
      // 038: goto 03f
      // 03b: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 03e: athrow
      // 03f: aload 3
      // 040: invokeinterface com/l7tech/identity/IdentityProvider.getUserManager ()Lcom/l7tech/identity/UserManager; 1
      // 045: aload 2
      // 046: invokeinterface com/l7tech/identity/UserManager.findByPrimaryKey (Ljava/lang/String;)Lcom/l7tech/identity/User; 2
      // 04b: astore 4
      // 04d: aload 4
      // 04f: ifnull 09e
      // 052: bipush 2
      // 053: anewarray 107
      // 056: dup
      // 057: bipush 0
      // 058: aload 3
      // 059: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 05e: invokevirtual com/l7tech/identity/IdentityProviderConfig.getName ()Ljava/lang/String;
      // 061: aastore
      // 062: dup
      // 063: bipush 1
      // 064: aload 4
      // 066: invokeinterface com/l7tech/identity/User.getLogin ()Ljava/lang/String; 1
      // 06b: invokestatic org/apache/commons/lang3/StringUtils.isNotEmpty (Ljava/lang/CharSequence;)Z
      // 06e: ifeq 086
      // 071: goto 078
      // 074: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 077: athrow
      // 078: aload 4
      // 07a: invokeinterface com/l7tech/identity/User.getLogin ()Ljava/lang/String; 1
      // 07f: goto 09c
      // 082: invokestatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 085: athrow
      // 086: aload 4
      // 088: invokeinterface com/l7tech/identity/User.getName ()Ljava/lang/String; 1
      // 08d: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // 090: astore 5
      // 092: aload 5
      // 094: bipush 1
      // 095: aaload
      // 096: swap
      // 097: 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" ]
      // 09c: aastore
      // 09d: areturn
      // 09e: new java/lang/IllegalArgumentException
      // 0a1: dup
      // 0a2: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // 0a5: astore 5
      // 0a7: aload 5
      // 0a9: bipush 4
      // 0aa: aaload
      // 0ab: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // 0ae: athrow
      // 0af: bipush 2
      // 0b0: anewarray 107
      // 0b3: dup
      // 0b4: bipush 0
      // 0b5: aload 3
      // 0b6: invokeinterface com/l7tech/identity/IdentityProvider.getConfig ()Lcom/l7tech/identity/IdentityProviderConfig; 1
      // 0bb: invokevirtual com/l7tech/identity/IdentityProviderConfig.getName ()Ljava/lang/String;
      // 0be: aastore
      // 0bf: dup
      // 0c0: bipush 1
      // 0c1: aload 2
      // 0c2: aastore
      // 0c3: areturn
      // 0c4: new java/lang/IllegalArgumentException
      // 0c7: dup
      // 0c8: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // 0cb: astore 5
      // 0cd: aload 5
      // 0cf: bipush 7
      // 0d1: aaload
      // 0d2: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // 0d5: athrow
      // 0d6: astore 3
      // 0d7: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.a Ljava/util/logging/Logger;
      // 0da: getstatic java/util/logging/Level.INFO Ljava/util/logging/Level;
      // 0dd: getstatic com/l7tech/external/assertions/gatewaygraphql/server/data/IdentityProviderHelper.d [Ljava/lang/String;
      // 0e0: bipush 5
      // 0e1: aaload
      // 0e2: bipush 3
      // 0e3: anewarray 107
      // 0e6: dup
      // 0e7: bipush 0
      // 0e8: aload 1
      // 0e9: invokevirtual com/l7tech/objectmodel/Goid.toHexString ()Ljava/lang/String;
      // 0ec: aastore
      // 0ed: dup
      // 0ee: bipush 1
      // 0ef: aload 2
      // 0f0: aastore
      // 0f1: dup
      // 0f2: bipush 2
      // 0f3: aload 3
      // 0f4: invokevirtual java/lang/Exception.getMessage ()Ljava/lang/String;
      // 0f7: aastore
      // 0f8: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;[Ljava/lang/Object;)V
      // 0fb: bipush 2
      // 0fc: anewarray 107
      // 0ff: dup
      // 100: bipush 0
      // 101: aconst_null
      // 102: aastore
      // 103: dup
      // 104: bipush 1
      // 105: aconst_null
      // 106: aastore
      // 107: areturn
      // try (32 -> 52): 52 java/lang/Exception
      // try (30 -> 46): 47 java/lang/Exception
      // try (7 -> 22): 23 java/lang/Exception
      // try (5 -> 13): 14 java/lang/Exception
      // try (0 -> 64): 96 java/lang/Exception
      // try (65 -> 86): 96 java/lang/Exception
      // try (87 -> 96): 96 java/lang/Exception
   }

   private User a(IdentityProvider var1, String var2) throws FindException {
      String[] var5 = d;
      if (var2.startsWith(var5[3])) {
         EntityHeaderSet var3 = var1.getUserManager().search(var2.substring(var5[3].length()));

         IdentityHeader var10000;
         label33: {
            try {
               if (var3.isEmpty()) {
                  var10000 = null;
                  break label33;
               }
            } catch (FindException var7) {
               throw a(var7);
            }

            var10000 = (IdentityHeader)var3.iterator().next();
         }

         IdentityHeader var4 = var10000;

         try {
            if (var4 != null) {
               return var1.getUserManager().headerToUser(var4);
            }
         } catch (FindException var6) {
            throw a(var6);
         }

         return null;
      } else {
         return var1.getUserManager().findByLogin(var2);
      }
   }

   static {
      String[] var5 = new String[8];
      int var3 = 0;
      String var2 = "R_\b\u001a\u0017kH'B\u0002\u001c\u0017p^tC\u0001\u001eRf\u0005iM\u0000\r\n!NH\b\u0006CkO~\f\u001d\u001aXtRcI\u001fH^q\u001biC\u0019HEgHh@\u001b\rS\u0005iM\u0000\r\n\u0014R_\b\u001a\u0017kH'B\u0002\u001c\u0017p^tC\u0001\u001eRfAB^\u001f\u0007E\"^iO\u0002\u001dYv^uI\tH@jRkIM\u001aRqTkZ\u0004\u0006P\"NtI\u001fH^f^iX\u0004\u000e^gI'\u0004\u0016XJ.\u001b|\u001d\u0010A\u001b\"@5Q";
      int var4 = "R_\b\u001a\u0017kH'B\u0002\u001c\u0017p^tC\u0001\u001eRf\u0005iM\u0000\r\n!NH\b\u0006CkO~\f\u001d\u001aXtRcI\u001fH^q\u001biC\u0019HEgHh@\u001b\rS\u0005iM\u0000\r\n\u0014R_\b\u001a\u0017kH'B\u0002\u001c\u0017p^tC\u0001\u001eRfAB^\u001f\u0007E\"^iO\u0002\u001dYv^uI\tH@jRkIM\u001aRqTkZ\u0004\u0006P\"NtI\u001fH^f^iX\u0004\u000e^gI'\u0004\u0016XJ.\u001b|\u001d\u0010A\u001b\"@5Q"
         .length();
      char var1 = 20;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 18;
         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) {
                     d = var5;
                     b = d[3];
                     a = Logger.getLogger(IdentityProviderHelper.class.getName());
                     return;
                  }

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

                  var2 = "|`!9{\u001c`Wq<#gH`Kw7v~TlUws$lOjUd:8n\u001cpJw!v`X`Wf:0`Yw\u0019:(ft\u0010%B#.\u007f%\u001c~\u000bo!pv68}Uq@2#$fJl]w!v`O%W}'v{YvV~%3m";
                  var4 = "|`!9{\u001c`Wq<#gH`Kw7v~TlUws$lOjUd:8n\u001cpJw!v`X`Wf:0`Yw\u0019:(ft\u0010%B#.\u007f%\u001c~\u000bo!pv68}Uq@2#$fJl]w!v`O%W}'v{YvV~%3m"
                     .length();
                  var1 = 'A';
                  var7 = -1;
            }

            var10000 = 44;
            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] ^ 41);
      }

      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 -> 21;
            case 1 -> 62;
            case 2 -> 127;
            case 3 -> 122;
            case 4 -> 37;
            case 5 -> 16;
            default -> 41;
         });
      }

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