package com.airlock.iam.saml2.application.configuration.assertion.attribute;

import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.license.PluginLicenseRestriction;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(description = "A SAML 2.0 attribute containing the Authentication Token ID.", displayName = "Auth Token ID SAML 2.0 Attribute")
@PluginLicenseRestriction(moduleAffiliation = "SamlIdp")
public class AuthTokenIdAttributeConfig extends SamlIdpAttributeConfigWithNameFormat implements SamlFlowIdpAttributeConfig {
   @StringProperty(
      displayName = "Attribute Name",
      description = "The name of the attribute to add to the assertion. If there is no Auth Token in the session, the attribute will not be included in the assertion.",
      exampleValues = "Auth-Token",
      optional = false
   )
   private String samlAttributeName;

   public AuthTokenIdAttributeConfig(String samlAttributeName, String nameFormat) {
      super(nameFormat);
      this.samlAttributeName = samlAttributeName;
   }

   @Override
   public String getSamlAttributeName() {
      return this.samlAttributeName;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static AuthTokenIdAttributeConfig.AuthTokenIdAttributeConfigBuilder builder() {
      return new AuthTokenIdAttributeConfig.AuthTokenIdAttributeConfigBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public AuthTokenIdAttributeConfig() {
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class AuthTokenIdAttributeConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String samlAttributeName;
      @SuppressFBWarnings(justification = "generated code")
      private String nameFormat;

      @SuppressFBWarnings(justification = "generated code")
      AuthTokenIdAttributeConfigBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public AuthTokenIdAttributeConfig.AuthTokenIdAttributeConfigBuilder samlAttributeName(String samlAttributeName) {
         this.samlAttributeName = samlAttributeName;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AuthTokenIdAttributeConfig.AuthTokenIdAttributeConfigBuilder nameFormat(String nameFormat) {
         this.nameFormat = nameFormat;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AuthTokenIdAttributeConfig build() {
         return new AuthTokenIdAttributeConfig(this.samlAttributeName, this.nameFormat);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "AuthTokenIdAttributeConfig.AuthTokenIdAttributeConfigBuilder(samlAttributeName="
            + this.samlAttributeName
            + ", nameFormat="
            + this.nameFormat
            + ")";
      }
   }
}
