package com.l7tech.gateway.common.siteminder;

import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.imp.ZoneableNamedEntityImp;
import com.l7tech.search.Dependency;
import com.l7tech.search.Dependency.DependencyType;
import com.l7tech.search.Dependency.MethodReturnType;
import com.l7tech.security.rbac.RbacAttribute;
import com.l7tech.util.DeserializeSafe;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Type;

@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement
@Entity
@Proxy(lazy = false)
@Table(name = "siteminder_configuration")
@DeserializeSafe
public class SiteMinderConfiguration extends ZoneableNamedEntityImp implements Comparable {
   private String address;
   private String secret;
   private Boolean ipcheck;
   private boolean enabled;
   private String hostname;
   private int fipsmode;
   private boolean nonClusterFailover;
   private int clusterThreshold;
   private String hostConfiguration;
   private String userName;
   private Goid passwordGoid;
   private boolean updateSSOToken;
   private Map<String, String> properties;
   static final long serialVersionUID = -8581725012575093112L;
   private static final String[] b;

   public SiteMinderConfiguration() {
      this._name = "";
      this.address = "";
      this.secret = "";
      this.ipcheck = false;
      this.hostname = "";
      this.fipsmode = 0;
      this.nonClusterFailover = false;
      this.clusterThreshold = 50;
      this.enabled = true;
      this.hostConfiguration = "";
      this.userName = "";
      this.passwordGoid = null;
      this.updateSSOToken = false;
   }

   @RbacAttribute
   @Size(min = 1, max = 128)
   @Transient
   public String getName() {
      return super.getName();
   }

   @RbacAttribute
   @NotNull
   @Size(min = 0, max = 128)
   @Column(name = "address", nullable = true)
   public String getAddress() {
      return this.address;
   }

   public void setAddress(String var1) {
      this.address = var1;
   }

   @NotNull
   @Size(min = 1, max = 4096)
   @Column(name = "secret", nullable = false)
   public String getSecret() {
      return this.secret;
   }

   public void setSecret(String var1) {
      this.secret = var1;
   }

   @Column(name = "ipcheck")
   public boolean isIpcheck() {
      return this.ipcheck;
   }

   public void setIpcheck(boolean var1) {
      this.ipcheck = var1;
   }

   @RbacAttribute
   @Column(name = "enabled")
   public boolean isEnabled() {
      return this.enabled;
   }

   public void setEnabled(boolean var1) {
      this.enabled = var1;
   }

   @RbacAttribute
   @NotNull
   @Size(min = 1, max = 255)
   @Column(name = "hostname", nullable = false)
   public String getHostname() {
      return this.hostname;
   }

   public void setHostname(String var1) {
      this.hostname = var1;
   }

   @NotNull
   @Min(1L)
   @Max(3L)
   @Column(name = "fipsmode", nullable = false)
   public int getFipsmode() {
      return this.fipsmode;
   }

   public void setFipsmode(int var1) {
      this.fipsmode = var1;
   }

   @Column(name = "noncluster_failover")
   public boolean isNonClusterFailover() {
      return this.nonClusterFailover;
   }

   public void setNonClusterFailover(boolean var1) {
      this.nonClusterFailover = var1;
   }

   @Transient
   public List<String> getPropertyNames() {
      return new ArrayList<>(this.properties.keySet());
   }

   public void putProperty(String var1, String var2) {
      this.checkLocked();
      this.properties.put(var1, var2);
   }

   public void removeProperty(String var1) {
      this.checkLocked();
      this.properties.remove(var1);
   }

   @Column(name = "cluster_threshold")
   public int getClusterThreshold() {
      return this.clusterThreshold;
   }

   public void setClusterThreshold(int var1) {
      this.clusterThreshold = var1;
   }

   @Size(min = 0, max = 256)
   @Column(name = "host_configuration")
   public String getHostConfiguration() {
      return this.hostConfiguration;
   }

   public void setHostConfiguration(String var1) {
      this.hostConfiguration = var1;
   }

   @Column(name = "update_sso_token")
   public boolean isUpdateSSOToken() {
      return this.updateSSOToken;
   }

   public void setUpdateSSOToken(boolean var1) {
      this.updateSSOToken = var1;
   }

   @RbacAttribute
   @Size(min = 0, max = 256)
   @Column(name = "user_name")
   public String getUserName() {
      return this.userName;
   }

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

   @Column(name = "password_goid")
   @Type(type = "com.l7tech.server.util.GoidType")
   @Dependency(type = DependencyType.SECURE_PASSWORD, methodReturnType = MethodReturnType.GOID)
   public Goid getPasswordGoid() {
      return this.passwordGoid;
   }

   public void setPasswordGoid(Goid var1) {
      this.checkLocked();
      this.passwordGoid = var1;
   }

   @Fetch(FetchMode.SUBSELECT)
   @ElementCollection(fetch = FetchType.EAGER)
   @JoinTable(name = "siteminder_configuration_property", joinColumns = @JoinColumn(name = "siteminder_configuration_goid", referencedColumnName = "goid"))
   @MapKeyColumn(name = "name", length = 128)
   @Column(name = "value", nullable = false, length = 32672)
   public Map<String, String> getProperties() {
      return this.properties;
   }

   public void setProperties(Map<String, String> var1) {
      this.checkLocked();
      this.properties = var1;
   }

   @Override
   public int compareTo(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 1
      // 01: ifnull 12
      // 04: aload 1
      // 05: instanceof com/l7tech/gateway/common/siteminder/SiteMinderConfiguration
      // 08: ifne 23
      // 0b: goto 12
      // 0e: invokestatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 11: athrow
      // 12: new java/lang/IllegalArgumentException
      // 15: dup
      // 16: getstatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b [Ljava/lang/String;
      // 19: bipush 1
      // 1a: aaload
      // 1b: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // 1e: athrow
      // 1f: invokestatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 22: athrow
      // 23: aload 0
      // 24: invokevirtual com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.getName ()Ljava/lang/String;
      // 27: astore 2
      // 28: aload 1
      // 29: checkcast com/l7tech/gateway/common/siteminder/SiteMinderConfiguration
      // 2c: invokevirtual com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.getName ()Ljava/lang/String;
      // 2f: astore 3
      // 30: aload 2
      // 31: ifnull 3f
      // 34: aload 3
      // 35: ifnonnull 50
      // 38: goto 3f
      // 3b: invokestatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 3e: athrow
      // 3f: new java/lang/NullPointerException
      // 42: dup
      // 43: getstatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b [Ljava/lang/String;
      // 46: bipush 0
      // 47: aaload
      // 48: invokespecial java/lang/NullPointerException.<init> (Ljava/lang/String;)V
      // 4b: athrow
      // 4c: invokestatic com/l7tech/gateway/common/siteminder/SiteMinderConfiguration.b (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 4f: athrow
      // 50: aload 2
      // 51: aload 3
      // 52: invokevirtual java/lang/String.compareToIgnoreCase (Ljava/lang/String;)I
      // 55: ireturn
      // try (0 -> 5): 6 java/lang/IllegalArgumentException
      // try (2 -> 15): 15 java/lang/IllegalArgumentException
      // try (24 -> 28): 29 java/lang/IllegalArgumentException
      // try (26 -> 38): 38 java/lang/IllegalArgumentException
   }

   public void copyFrom(SiteMinderConfiguration var1) {
      this.setGoid(var1.getGoid());
      this.setName(var1.getName());
      this.setAddress(var1.getAddress());
      this.setSecret(var1.getSecret());
      this.setIpcheck(var1.isIpcheck());
      this.setEnabled(var1.isEnabled());
      this.setHostname(var1.getHostname());
      this.setFipsmode(var1.getFipsmode());
      this.setNonClusterFailover(var1.isNonClusterFailover());
      this.setClusterThreshold(var1.getClusterThreshold());
      this.setUpdateSSOToken(var1.isUpdateSSOToken());
      this.setHostConfiguration(var1.getHostConfiguration());
      this.setUserName(var1.getUserName());
      this.setPasswordGoid(var1.getPasswordGoid());
      this.setSecurityZone(var1.getSecurityZone());
      this.setProperties(var1.getProperties());
   }

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

   static {
      String[] var5 = new String[2];
      int var3 = 0;
      String var2 = "#a\u0012(*\u0011U\u0014m\u0014\u000e\b\u0016]\u0019o\u0013?\u0006\fR\u001ffF#\u0006\u0015^Pe\u0013>\u0013XU\u001f|F/\u0002XU\u0005d\nc6$`\u0003m\u0004\u0017V\u0000i\u0014(\u0003XT\u0012b\u0003.\u0013XV\u0005{\u0012m\u0005\u001d\u001b\u0011(5$\u0013\u001dv\u0019f\u0002(\u0015;T\u001en\u000f*\u0012\nZ\u0004a\t#I";
      int var4 = "#a\u0012(*\u0011U\u0014m\u0014\u000e\b\u0016]\u0019o\u0013?\u0006\fR\u001ffF#\u0006\u0015^Pe\u0013>\u0013XU\u001f|F/\u0002XU\u0005d\nc6$`\u0003m\u0004\u0017V\u0000i\u0014(\u0003XT\u0012b\u0003.\u0013XV\u0005{\u0012m\u0005\u001d\u001b\u0011(5$\u0013\u001dv\u0019f\u0002(\u0015;T\u001en\u000f*\u0012\nZ\u0004a\t#I"
         .length();
      char var1 = '.';
      int var0 = -1;

      while (true) {
         String var10002 = b(14, b(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            b = var5;
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

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

      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 -> 126;
            case 1 -> 6;
            case 2 -> 104;
            case 3 -> 67;
            case 4 -> 105;
            case 5 -> 118;
            default -> 53;
         });
      }

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