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 AuthnContextClassRef URI if an explicit Authentication Context Mapping (or a default Authentication Context) has been configured in the IdP config.",
   displayName = "AuthnContextClassRef URI SAML 2.0 Attribute"
)
@PluginLicenseRestriction(moduleAffiliation = "SamlIdp")
public class AuthnClassRefAttributeConfig extends SamlIdpAttributeConfigWithNameFormat implements SamlFlowIdpAttributeConfig {
   @StringProperty(
      displayName = "Attribute Name",
      description = "The name of the attribute to add to the assertion.",
      exampleValues = "AuthnContextClassRef",
      optional = false
   )
   private String samlAttributeName;

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

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

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

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

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

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

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

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

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

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