package com.l7tech.gateway.common.security.rbac;

import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.imp.PersistentEntityImp;
import com.l7tech.util.DeserializeSafe;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Type;

@Entity
@Proxy(lazy = false)
@Table(name = "rbac_assignment", uniqueConstraints = @UniqueConstraint(columnNames = {"provider_goid", "role_goid", "identity_id", "entity_type"}))
@DeserializeSafe
public class RoleAssignment extends PersistentEntityImp {
   protected Goid providerId;
   protected String identityId;
   private Role role;
   private String entityType;
   private boolean inherited;
   static final long serialVersionUID = 5024096590927240795L;
   private static final String b;

   public RoleAssignment(Role var1, Goid var2, String var3, EntityType var4) {
      if (var1 == null) {
         throw new IllegalArgumentException(b);
      }

      this.role = var1;
      this.providerId = var2;
      this.identityId = var3;
      this.entityType = var4.getName();
   }

   protected RoleAssignment() {
   }

   @NotNull
   @Size(min = 1, max = 255)
   @Column(name = "identity_id", nullable = false, length = 255)
   public String getIdentityId() {
      return this.identityId;
   }

   public void setIdentityId(String var1) {
      this.identityId = var1;
   }

   @NotNull
   @Column(name = "provider_goid", nullable = false)
   @Type(type = "com.l7tech.server.util.GoidType")
   public Goid getProviderId() {
      return this.providerId;
   }

   public void setProviderId(Goid var1) {
      this.providerId = var1;
   }

   @ManyToOne(optional = false)
   @JoinColumn(name = "role_goid", nullable = false)
   public Role getRole() {
      return this.role;
   }

   protected void setRole(Role var1) {
      this.role = var1;
   }

   @NotNull
   @Size(min = 1, max = 50)
   @Column(name = "entity_type", nullable = false, length = 50)
   public String getEntityType() {
      return this.entityType;
   }

   public void setEntityType(String var1) {
      this.entityType = var1;
   }

   @Transient
   public boolean isInherited() {
      return this.inherited;
   }

   public void setInherited(boolean var1) {
      this.inherited = var1;
   }

   public boolean equals(Object 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:
      // 00: aload 0
      // 01: aload 1
      // 02: if_acmpne 0b
      // 05: bipush 1
      // 06: ireturn
      // 07: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 0a: athrow
      // 0b: aload 1
      // 0c: ifnull 21
      // 0f: aload 0
      // 10: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 13: aload 1
      // 14: invokevirtual java/lang/Object.getClass ()Ljava/lang/Class;
      // 17: if_acmpeq 27
      // 1a: goto 21
      // 1d: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 20: athrow
      // 21: bipush 0
      // 22: ireturn
      // 23: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 26: athrow
      // 27: aload 0
      // 28: aload 1
      // 29: invokespecial com/l7tech/objectmodel/imp/PersistentEntityImp.equals (Ljava/lang/Object;)Z
      // 2c: ifne 35
      // 2f: bipush 0
      // 30: ireturn
      // 31: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 34: athrow
      // 35: aload 1
      // 36: checkcast com/l7tech/gateway/common/security/rbac/RoleAssignment
      // 39: astore 2
      // 3a: aload 0
      // 3b: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 3e: ifnull 5d
      // 41: aload 0
      // 42: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 45: aload 2
      // 46: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 49: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 4c: ifne 6a
      // 4f: goto 56
      // 52: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 55: athrow
      // 56: goto 64
      // 59: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 5c: athrow
      // 5d: aload 2
      // 5e: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 61: ifnull 6a
      // 64: bipush 0
      // 65: ireturn
      // 66: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 69: athrow
      // 6a: aload 0
      // 6b: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 6e: ifnull 8d
      // 71: aload 0
      // 72: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 75: aload 2
      // 76: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 79: invokevirtual com/l7tech/objectmodel/Goid.equals (Ljava/lang/Object;)Z
      // 7c: ifne 9a
      // 7f: goto 86
      // 82: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 85: athrow
      // 86: goto 94
      // 89: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 8c: athrow
      // 8d: aload 2
      // 8e: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 91: ifnull 9a
      // 94: bipush 0
      // 95: ireturn
      // 96: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 99: athrow
      // 9a: aload 0
      // 9b: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // 9e: ifnonnull a9
      // a1: bipush 1
      // a2: goto aa
      // a5: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // a8: athrow
      // a9: bipush 0
      // aa: aload 2
      // ab: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // ae: ifnonnull b9
      // b1: bipush 1
      // b2: goto ba
      // b5: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // b8: athrow
      // b9: bipush 0
      // ba: if_icmpeq c3
      // bd: bipush 0
      // be: ireturn
      // bf: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // c2: athrow
      // c3: aload 0
      // c4: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // c7: ifnull eb
      // ca: aload 0
      // cb: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // ce: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // d1: aload 2
      // d2: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // d5: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // d8: invokestatic com/l7tech/objectmodel/Goid.equals (Lcom/l7tech/objectmodel/Goid;Lcom/l7tech/objectmodel/Goid;)Z
      // db: ifne eb
      // de: goto e5
      // e1: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // e4: athrow
      // e5: bipush 0
      // e6: ireturn
      // e7: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // ea: athrow
      // eb: bipush 1
      // ec: ireturn
      // try (0 -> 5): 5 java/lang/IllegalArgumentException
      // try (7 -> 14): 15 java/lang/IllegalArgumentException
      // try (9 -> 19): 19 java/lang/IllegalArgumentException
      // try (21 -> 27): 27 java/lang/IllegalArgumentException
      // try (32 -> 41): 42 java/lang/IllegalArgumentException
      // try (35 -> 45): 45 java/lang/IllegalArgumentException
      // try (47 -> 52): 52 java/lang/IllegalArgumentException
      // try (54 -> 63): 64 java/lang/IllegalArgumentException
      // try (57 -> 67): 67 java/lang/IllegalArgumentException
      // try (69 -> 74): 74 java/lang/IllegalArgumentException
      // try (76 -> 81): 81 java/lang/IllegalArgumentException
      // try (84 -> 89): 89 java/lang/IllegalArgumentException
      // try (92 -> 95): 95 java/lang/IllegalArgumentException
      // try (97 -> 108): 109 java/lang/IllegalArgumentException
      // try (100 -> 113): 113 java/lang/IllegalArgumentException
   }

   public int hashCode() {
      // $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: invokespecial com/l7tech/objectmodel/imp/PersistentEntityImp.hashCode ()I
      // 04: istore 1
      // 05: bipush 31
      // 07: iload 1
      // 08: imul
      // 09: aload 0
      // 0a: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 0d: ifnull 1e
      // 10: aload 0
      // 11: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.providerId Lcom/l7tech/objectmodel/Goid;
      // 14: invokevirtual com/l7tech/objectmodel/Goid.hashCode ()I
      // 17: goto 1f
      // 1a: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 1d: athrow
      // 1e: bipush 0
      // 1f: iadd
      // 20: istore 1
      // 21: bipush 31
      // 23: iload 1
      // 24: imul
      // 25: aload 0
      // 26: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 29: ifnull 3a
      // 2c: aload 0
      // 2d: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.identityId Ljava/lang/String;
      // 30: invokevirtual java/lang/String.hashCode ()I
      // 33: goto 3b
      // 36: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 39: athrow
      // 3a: bipush 0
      // 3b: iadd
      // 3c: istore 1
      // 3d: bipush 31
      // 3f: iload 1
      // 40: imul
      // 41: aload 0
      // 42: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // 45: ifnull 6a
      // 48: aload 0
      // 49: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // 4c: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 4f: ifnull 6a
      // 52: goto 59
      // 55: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 58: athrow
      // 59: aload 0
      // 5a: getfield com/l7tech/gateway/common/security/rbac/RoleAssignment.role Lcom/l7tech/gateway/common/security/rbac/Role;
      // 5d: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 60: invokevirtual com/l7tech/objectmodel/Goid.hashCode ()I
      // 63: goto 6b
      // 66: invokestatic com/l7tech/gateway/common/security/rbac/RoleAssignment.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 69: athrow
      // 6a: bipush 0
      // 6b: iadd
      // 6c: istore 1
      // 6d: iload 1
      // 6e: ireturn
      // try (3 -> 13): 13 java/lang/IllegalArgumentException
      // try (18 -> 28): 28 java/lang/IllegalArgumentException
      // try (33 -> 43): 44 java/lang/IllegalArgumentException
      // try (39 -> 51): 51 java/lang/IllegalArgumentException
   }

   private static IllegalArgumentException b(IllegalArgumentException var0) {
      return var0;
   }

   static {
      String var10002 = b(47, b("'`N)?r\u0004\u001baM8?s\u0000UaW s"));
      byte var10001 = -1;
      b = var10002;
   }

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

      return var10000;
   }

   private static String b(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 -> 90;
            case 1 -> 32;
            case 2 -> 13;
            case 3 -> 99;
            case 4 -> 48;
            case 5 -> 62;
            default -> 74;
         });
      }

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