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

import com.airlock.iam.login.application.configuration.targetapp.ApplicationIdConfig;
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.PluginProperty;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(
   description = "A specific authentication flow can be started based on a Requested Authentication Context (<tt>RequestedAuthnContext</tt> element) in the Authentication Request. If the configured Authentication Context is requested in the Authentication Request, the configured application's authentication flow is started.",
   displayName = "Requested Authentication Context Mapping"
)
@PluginLicenseRestriction(moduleAffiliation = "SamlIdp")
public final class Saml2RequestedAuthnContextToApplicationIdConfig {
   @StringProperty(
      description = "If the configured value is requested in the Authentication Request,  the configured application's authentication flow is started. Note: The value is case sensitive.",
      displayName = "Requested Authentication Context",
      optional = false,
      suggestedValues = {
            "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocol",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocolPassword",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileOneFactorUnregistered",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorUnregistered",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileOneFactorContract",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:Password",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:X509",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:PGP",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:SPKI",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:XMLDSig",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:Smartcard",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:Telephony",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:NomadTelephony",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:PersonalTelephony",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:AuthenticatedTelephony",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:SecureRemotePassword",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:TLSClient",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken",
            "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"
      }
   )
   private String requestedAuthnContextValue;
   @PluginProperty(description = "Application Flow to start.", displayName = "Flow Application ID", optional = false)
   private ApplicationIdConfig flowApplicationId;
   public static final String FLOW_APPLICATION_ID_PROPERTY = "flowApplicationId";
   private static final String FLOW_APPLICATION_ID_DISPLAY_NAME = "Flow Application ID";

   public String getRequestedAuthnContextValue() {
      return this.requestedAuthnContextValue;
   }

   public ApplicationIdConfig getFlowApplicationId() {
      return this.flowApplicationId;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public Saml2RequestedAuthnContextToApplicationIdConfig(String requestedAuthnContextValue, ApplicationIdConfig flowApplicationId) {
      this.requestedAuthnContextValue = requestedAuthnContextValue;
      this.flowApplicationId = flowApplicationId;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class Saml2RequestedAuthnContextToApplicationIdConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String requestedAuthnContextValue;
      @SuppressFBWarnings(justification = "generated code")
      private ApplicationIdConfig flowApplicationId;

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

      @SuppressFBWarnings(justification = "generated code")
      public Saml2RequestedAuthnContextToApplicationIdConfig.Saml2RequestedAuthnContextToApplicationIdConfigBuilder requestedAuthnContextValue(
         String requestedAuthnContextValue
      ) {
         this.requestedAuthnContextValue = requestedAuthnContextValue;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Saml2RequestedAuthnContextToApplicationIdConfig.Saml2RequestedAuthnContextToApplicationIdConfigBuilder flowApplicationId(
         ApplicationIdConfig flowApplicationId
      ) {
         this.flowApplicationId = flowApplicationId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Saml2RequestedAuthnContextToApplicationIdConfig build() {
         return new Saml2RequestedAuthnContextToApplicationIdConfig(this.requestedAuthnContextValue, this.flowApplicationId);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Saml2RequestedAuthnContextToApplicationIdConfig.Saml2RequestedAuthnContextToApplicationIdConfigBuilder(requestedAuthnContextValue="
            + this.requestedAuthnContextValue
            + ", flowApplicationId="
            + this.flowApplicationId
            + ")";
      }
   }
}
