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.StringListProperty;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;

@Plugin(description = "A SAML 2.0 attribute that has fixed value(s).", displayName = "Static SAML 2.0 Attribute")
@PluginLicenseRestriction(moduleAffiliation = "SamlIdp")
public class StaticSamlAttributeConfig extends SamlIdpAttributeConfigWithNameFormat implements SamlFlowIdpAttributeConfig {
   @StringProperty(
      displayName = "Attribute Name",
      description = "The name of the attribute to add to the assertion.",
      exampleValues = {"SpecialAttribute", "user_type"},
      optional = false
   )
   private String samlAttributeName;
   @StringListProperty(description = "The value(s) to set for this attribute.", optional = false)
   private List<String> staticValues;

   public StaticSamlAttributeConfig(String samlAttributeName, List<String> staticValues, String nameFormat) {
      super(nameFormat);
      this.samlAttributeName = samlAttributeName;
      this.staticValues = staticValues;
   }

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

   public List<String> getStaticValues() {
      return this.staticValues;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class StaticSamlAttributeConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String samlAttributeName;
      @SuppressFBWarnings(justification = "generated code")
      private List<String> staticValues;
      @SuppressFBWarnings(justification = "generated code")
      private String nameFormat;

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

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

      @SuppressFBWarnings(justification = "generated code")
      public StaticSamlAttributeConfig.StaticSamlAttributeConfigBuilder staticValues(List<String> staticValues) {
         this.staticValues = staticValues;
         return this;
      }

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

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

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