package com.l7tech.policy.assertion.identity;

import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.IdentityHeader;
import com.l7tech.objectmodel.migration.Migration;
import com.l7tech.objectmodel.migration.MigrationMappingSelection;
import com.l7tech.objectmodel.migration.PropertyResolver;
import com.l7tech.policy.assertion.AssertionMetadata;
import com.l7tech.policy.assertion.DefaultAssertionMetadata;
import com.l7tech.policy.assertion.IdentityTarget;

public class SpecificUser extends IdentityAssertion {
   private final Goid INTERNAL_IDENTITY_PROVIDER = new Goid(0L, -2L);
   protected String userLogin;
   protected String userUid;
   private String userName;
   private static final String META_INITIALIZED;
   static final long serialVersionUID = 3350915337474968298L;
   private static final String[] c;

   public SpecificUser() {
   }

   public SpecificUser(Goid var1, String var2, String var3, String var4) {
      super(var1);
      this.userLogin = var2;
      this.userName = var4;
      this.userUid = var3;
   }

   public void setUserLogin(String var1) {
      this.userLogin = var1;
   }

   public String getUserLogin() {
      return this.userLogin;
   }

   public String getUserUid() {
      return this.userUid;
   }

   public void setUserUid(String var1) {
      this.userUid = var1;
      this.mapUserId();
   }

   public String getUserName() {
      return this.userName;
   }

   public void setUserName(String var1) {
      this.userName = var1;
   }

   @Override
   public void setIdentityProviderOid(long var1) {
      super.setIdentityProviderOid(var1);
      this.mapUserId();
   }

   @Migration(mapName = MigrationMappingSelection.NONE, mapValue = MigrationMappingSelection.NONE, export = false, resolver = PropertyResolver.Type.USERGROUP)
   @Override
   public EntityHeader[] getEntitiesUsed() {
      EntityHeader[] var1 = super.getEntitiesUsed();
      EntityHeader[] var2 = new EntityHeader[var1.length + 1];
      System.arraycopy(var1, 0, var2, 0, var1.length);
      var2[var1.length] = new IdentityHeader(super.getIdentityProviderOid(), this.userUid, EntityType.USER, this.userLogin, null, this.userName, null);
      return var2;
   }

   private void mapUserId() {
      // $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: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getUserUid ()Ljava/lang/String;
      // 04: ifnull ab
      // 07: aload 0
      // 08: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getUserUid ()Ljava/lang/String;
      // 0b: invokevirtual java/lang/String.length ()I
      // 0e: bipush 32
      // 10: if_icmpeq ab
      // 13: goto 1a
      // 16: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 19: athrow
      // 1a: aload 0
      // 1b: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getIdentityProviderOid ()Lcom/l7tech/objectmodel/Goid;
      // 1e: ifnull ab
      // 21: goto 28
      // 24: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 27: athrow
      // 28: aload 0
      // 29: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getIdentityProviderOid ()Lcom/l7tech/objectmodel/Goid;
      // 2c: getstatic com/l7tech/objectmodel/PersistentEntity.DEFAULT_GOID Lcom/l7tech/objectmodel/Goid;
      // 2f: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 32: ifne ab
      // 35: goto 3c
      // 38: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 3b: athrow
      // 3c: aload 0
      // 3d: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getUserUid ()Ljava/lang/String;
      // 40: invokestatic java/lang/Long.parseLong (Ljava/lang/String;)J
      // 43: invokestatic java/lang/Long.valueOf (J)Ljava/lang/Long;
      // 46: astore 1
      // 47: aload 0
      // 48: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.getIdentityProviderOid ()Lcom/l7tech/objectmodel/Goid;
      // 4b: aload 0
      // 4c: getfield com/l7tech/policy/assertion/identity/SpecificUser.INTERNAL_IDENTITY_PROVIDER Lcom/l7tech/objectmodel/Goid;
      // 4f: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 52: ifeq 96
      // 55: aload 1
      // 56: invokevirtual java/lang/Long.longValue ()J
      // 59: ldc2_w 3
      // 5c: lcmp
      // 5d: ifne 80
      // 60: goto 67
      // 63: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 66: athrow
      // 67: aload 0
      // 68: new com/l7tech/objectmodel/Goid
      // 6b: dup
      // 6c: lconst_0
      // 6d: ldc2_w 3
      // 70: invokespecial com/l7tech/objectmodel/Goid.<init> (JJ)V
      // 73: invokestatic com/l7tech/objectmodel/Goid.toString (Lcom/l7tech/objectmodel/Goid;)Ljava/lang/String;
      // 76: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.setUserUid (Ljava/lang/String;)V
      // 79: goto a7
      // 7c: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 7f: athrow
      // 80: aload 0
      // 81: getstatic com/l7tech/policy/assertion/identity/SpecificUser.c [Ljava/lang/String;
      // 84: astore 2
      // 85: aload 2
      // 86: bipush 8
      // 88: aaload
      // 89: aload 1
      // 8a: invokestatic com/l7tech/util/GoidUpgradeMapper.mapOidFromTableName (Ljava/lang/String;Ljava/lang/Long;)Lcom/l7tech/objectmodel/Goid;
      // 8d: invokevirtual com/l7tech/objectmodel/Goid.toString ()Ljava/lang/String;
      // 90: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.setUserUid (Ljava/lang/String;)V
      // 93: goto a7
      // 96: aload 0
      // 97: getstatic com/l7tech/policy/assertion/identity/SpecificUser.c [Ljava/lang/String;
      // 9a: bipush 6
      // 9c: aaload
      // 9d: aload 1
      // 9e: invokestatic com/l7tech/util/GoidUpgradeMapper.mapOidFromTableName (Ljava/lang/String;Ljava/lang/Long;)Lcom/l7tech/objectmodel/Goid;
      // a1: invokevirtual com/l7tech/objectmodel/Goid.toString ()Ljava/lang/String;
      // a4: invokevirtual com/l7tech/policy/assertion/identity/SpecificUser.setUserUid (Ljava/lang/String;)V
      // a7: goto ab
      // aa: astore 1
      // ab: return
      // try (36 -> 53): 53 java/lang/NumberFormatException
      // try (30 -> 41): 42 java/lang/NumberFormatException
      // try (11 -> 22): 23 java/lang/NumberFormatException
      // try (3 -> 14): 15 java/lang/NumberFormatException
      // try (0 -> 8): 9 java/lang/NumberFormatException
      // try (25 -> 74): 75 java/lang/NumberFormatException
   }

   @Override
   public void replaceEntity(EntityHeader param1, EntityHeader 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 1
      // 01: invokevirtual com/l7tech/objectmodel/EntityHeader.getType ()Lcom/l7tech/objectmodel/EntityType;
      // 04: aload 2
      // 05: invokevirtual com/l7tech/objectmodel/EntityHeader.getType ()Lcom/l7tech/objectmodel/EntityType;
      // 08: invokevirtual com/l7tech/objectmodel/EntityType.equals (Ljava/lang/Object;)Z
      // 0b: ifne 13
      // 0e: return
      // 0f: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 12: athrow
      // 13: aload 1
      // 14: instanceof com/l7tech/objectmodel/IdentityHeader
      // 17: ifeq 7f
      // 1a: aload 2
      // 1b: instanceof com/l7tech/objectmodel/IdentityHeader
      // 1e: ifeq 7f
      // 21: goto 28
      // 24: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 27: athrow
      // 28: aload 1
      // 29: checkcast com/l7tech/objectmodel/IdentityHeader
      // 2c: astore 3
      // 2d: aload 2
      // 2e: checkcast com/l7tech/objectmodel/IdentityHeader
      // 31: astore 4
      // 33: aload 3
      // 34: invokevirtual com/l7tech/objectmodel/IdentityHeader.getProviderGoid ()Lcom/l7tech/objectmodel/Goid;
      // 37: aload 0
      // 38: getfield com/l7tech/policy/assertion/identity/SpecificUser._identityProviderOid Lcom/l7tech/objectmodel/Goid;
      // 3b: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 3e: ifeq 7f
      // 41: aload 3
      // 42: invokevirtual com/l7tech/objectmodel/IdentityHeader.getStrId ()Ljava/lang/String;
      // 45: aload 0
      // 46: getfield com/l7tech/policy/assertion/identity/SpecificUser.userUid Ljava/lang/String;
      // 49: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 4c: ifeq 7f
      // 4f: goto 56
      // 52: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 55: athrow
      // 56: aload 0
      // 57: aload 4
      // 59: invokevirtual com/l7tech/objectmodel/IdentityHeader.getProviderGoid ()Lcom/l7tech/objectmodel/Goid;
      // 5c: putfield com/l7tech/policy/assertion/identity/SpecificUser._identityProviderOid Lcom/l7tech/objectmodel/Goid;
      // 5f: aload 0
      // 60: aload 4
      // 62: invokevirtual com/l7tech/objectmodel/IdentityHeader.getStrId ()Ljava/lang/String;
      // 65: putfield com/l7tech/policy/assertion/identity/SpecificUser.userUid Ljava/lang/String;
      // 68: aload 0
      // 69: aload 4
      // 6b: invokevirtual com/l7tech/objectmodel/IdentityHeader.getName ()Ljava/lang/String;
      // 6e: putfield com/l7tech/policy/assertion/identity/SpecificUser.userLogin Ljava/lang/String;
      // 71: aload 0
      // 72: aload 4
      // 74: invokevirtual com/l7tech/objectmodel/IdentityHeader.getCommonName ()Ljava/lang/String;
      // 77: putfield com/l7tech/policy/assertion/identity/SpecificUser.userName Ljava/lang/String;
      // 7a: return
      // 7b: invokestatic com/l7tech/policy/assertion/identity/SpecificUser.a (Ljava/lang/NumberFormatException;)Ljava/lang/NumberFormatException;
      // 7e: athrow
      // 7f: aload 0
      // 80: aload 1
      // 81: aload 2
      // 82: invokespecial com/l7tech/policy/assertion/identity/IdentityAssertion.replaceEntity (Lcom/l7tech/objectmodel/EntityHeader;Lcom/l7tech/objectmodel/EntityHeader;)V
      // 85: return
      // try (0 -> 7): 7 java/lang/NumberFormatException
      // try (9 -> 15): 16 java/lang/NumberFormatException
      // try (24 -> 36): 37 java/lang/NumberFormatException
      // try (30 -> 56): 56 java/lang/NumberFormatException
   }

   @Override
   public String loggingIdentity() {
      String var1 = this.getUserLogin();

      label33: {
         try {
            if (var1 != null && var1.trim().length() >= 1) {
               break label33;
            }
         } catch (NumberFormatException var3) {
            throw a(var3);
         }

         var1 = this.getUserName();
      }

      try {
         if (var1 != null && var1.trim().length() >= 1) {
            return var1;
         }
      } catch (NumberFormatException var2) {
         throw a(var2);
      }

      return this.getUserUid();
   }

   @Override
   public IdentityTarget getIdentityTarget() {
      return new IdentityTarget(IdentityTarget.TargetIdentityType.USER, this.getIdentityProviderOid(), this.getUserUid(), this.loggingIdentity());
   }

   @Override
   public AssertionMetadata meta() {
      DefaultAssertionMetadata var1 = (DefaultAssertionMetadata)super.meta();

      try {
         if (var1.get(META_INITIALIZED) != null) {
            return var1;
         }
      } catch (NumberFormatException var3) {
         throw a(var3);
      }

      String[] var2 = c;
      var1.put(var2[0], var2[2]);
      var1.put(var2[9], var2[1]);
      var1.put(var2[5], new String[]{var2[10]});
      var1.put(var2[7], var2[4]);
      var1.put(META_INITIALIZED, Boolean.TRUE);
      return var1;
   }

   @Override
   public String toString() {
      StringBuffer var1 = new StringBuffer(super.toString());

      try {
         var1.append(" ");
         if (this.userName != null) {
            var1.append(this.userName);
            return var1.toString();
         }
      } catch (NumberFormatException var4) {
         throw a(var4);
      }

      try {
         if (this.userLogin != null) {
            var1.append(this.userLogin);
            return var1.toString();
         }
      } catch (NumberFormatException var3) {
         throw a(var3);
      }

      try {
         if (this.userUid != null) {
            var1.append(this.userUid);
         }
      } catch (NumberFormatException var2) {
         throw a(var2);
      }

      return var1.toString();
   }

   static {
      String[] var5 = new String[11];
      int var3 = 0;
      String var2 = "\u001dhDUPxN\u000b]VVYz_\nCX^Y@J\u0002h$\fbZ\u0014P9_\nn_\u0014_aE\u001cb[_\u0012zY\nh\u0019sXkE\u001bdCCraO\n\u0011.xCRY`_\u0006nVNY.~\u001chE\u0014A`RN]jJ\u001bl~TUzB\u000ea^@Yj2=hFOU|NOxD_N.B\u000bhYNUzB\n~\u0017\\NaFOlY\u001aUjN\u0001y^NE.[\u001dbASXkYA\u000e\u001fl[_HzN)b[^Y|X\b\thSeI}N\u001d\u0013\u001dhDUPxN\u000bIRI_|B\u001fy^UR\r\u0006cC_N`J\u0003RBIY|";
      int var4 = "\u001dhDUPxN\u000b]VVYz_\nCX^Y@J\u0002h$\fbZ\u0014P9_\nn_\u0014_aE\u001cb[_\u0012zY\nh\u0019sXkE\u001bdCCraO\n\u0011.xCRY`_\u0006nVNY.~\u001chE\u0014A`RN]jJ\u001bl~TUzB\u000ea^@Yj2=hFOU|NOxD_N.B\u000bhYNUzB\n~\u0017\\NaFOlY\u001aUjN\u0001y^NE.[\u001dbASXkYA\u000e\u001fl[_HzN)b[^Y|X\b\thSeI}N\u001d\u0013\u001dhDUPxN\u000bIRI_|B\u001fy^UR\r\u0006cC_N`J\u0003RBIY|"
         .length();
      char var1 = 23;
      int var7 = -1;

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

         while (true) {
            String var8 = c(var10000, c(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     c = var5;
                     META_INITIALIZED = SpecificUser.class.getName() + c[3];
                     return;
                  }

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

                  var2 = "'TcgpBv\u0019ZkgGZr$FaciS\r6VlgwEP8[{pkZ";
                  var4 = "'TcgpBv\u0019ZkgGZr$FaciS\r6VlgwEP8[{pkZ".length();
                  var1 = 20;
                  var7 = -1;
            }

            var10000 = 98;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

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

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

      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 -> 53;
            case 1 -> 87;
            case 2 -> 109;
            case 3 -> 96;
            case 4 -> 102;
            case 5 -> 84;
            default -> 113;
         });
      }

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