package com.airlock.iam.flow.shared.application.configuration.step;

import com.airlock.iam.factor.application.configuration.fido.FidoSettingsConfig;
import com.airlock.iam.flow.api.application.configuration.dynamicactivation.DynamicStepActivationConfig;
import com.airlock.iam.flow.api.application.configuration.selection.FlowConditionConfig;
import com.airlock.iam.flow.api.application.configuration.step.AbstractInteractiveFlowStepConfig;
import com.airlock.iam.flow.api.application.configuration.step.InteractiveGotoTargetConfig;
import com.airlock.iam.flow.api.application.configuration.step.StepIdConfig;
import com.airlock.iam.flow.api.application.configuration.tag.TagConfig;
import com.airlock.iam.flow.api.application.configuration.valueprovider.ValueMapProviderConfig;
import com.airlock.iam.flow.shared.domain.model.fido.FidoCredentialDisplayNameChangeStep;
import com.airlock.iam.flow.types.api.application.configuration.step.StepConfigForAuthenticationFlows;
import com.airlock.iam.flow.types.api.application.configuration.step.StepConfigForSelfServiceFlows;
import com.airlock.iam.plugin.api.annotation.config.Groups;
import com.airlock.iam.plugin.api.annotation.config.NextActions;
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.GroupProperty;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import java.util.List;
import java.util.Map;

@Plugin(
   description = "Step to change display name of a FIDO credential. This step must be preceeded by a FIDO Credential Selection Step to select the credential to be renamed. <br>If auto generate display name is enabled during the registration, it is also possible to configure this step after a FIDO Credential Registration Step.<br>The change is applied by a \"Apply Changes Step\" which requires an \"Apply FIDO Credential Display Name Change\" to persist the new name.",
   displayName = "FIDO Credential Display Name Change Step"
)
@Groups(groupSequence = {"Basic Settings", "Flow Control", "Tags/Guards"}, openGroups = "Basic Settings")
@PluginLicenseRestriction(moduleAffiliation = "FIDO")
@NextActions(FidoCredentialDisplayNameChangeStep.FidoCredentialDisplayNameChangeActions.class)
public final class FidoCredentialDisplayNameChangeStepConfig
   extends AbstractInteractiveFlowStepConfig
   implements StepConfigForSelfServiceFlows,
   StepConfigForAuthenticationFlows {
   public static final String FIDO_CREDENTIAL_RENAMING_STEP_NAME = "FIDO Credential Display Name Change Step";
   @PluginProperty(displayName = "FIDO Settings", description = "Settings for FIDO.", optional = false, globalPluginReference = "globalFidoSettings")
   @GroupProperty(groupIdentifier = "Basic Settings")
   private FidoSettingsConfig fidoSettings;

   public FidoCredentialDisplayNameChangeStepConfig(
      FlowConditionConfig skipCondition,
      FlowConditionConfig preCondition,
      boolean requiresActivation,
      List<TagConfig> tagsOnSuccess,
      @Nullable StepIdConfig stepId,
      List<InteractiveGotoTargetConfig> interactiveGotoTargets,
      List<DynamicStepActivationConfig> dynamicStepActivations,
      Map<String, StepIdConfig> onFailureGotos,
      List<ValueMapProviderConfig> customResponseAttributes,
      List<ValueMapProviderConfig> customFailureResponseAttributes,
      FidoSettingsConfig fidoSettings
   ) {
      super(
         skipCondition,
         preCondition,
         requiresActivation,
         tagsOnSuccess,
         stepId,
         interactiveGotoTargets,
         dynamicStepActivations,
         onFailureGotos,
         customResponseAttributes,
         customFailureResponseAttributes
      );
      this.fidoSettings = fidoSettings;
   }

   public FidoSettingsConfig getFidoSettings() {
      return this.fidoSettings;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class FidoCredentialDisplayNameChangeStepConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private FlowConditionConfig skipCondition;
      @SuppressFBWarnings(justification = "generated code")
      private FlowConditionConfig preCondition;
      @SuppressFBWarnings(justification = "generated code")
      private boolean requiresActivation;
      @SuppressFBWarnings(justification = "generated code")
      private List<TagConfig> tagsOnSuccess;
      @SuppressFBWarnings(justification = "generated code")
      private StepIdConfig stepId;
      @SuppressFBWarnings(justification = "generated code")
      private List<InteractiveGotoTargetConfig> interactiveGotoTargets;
      @SuppressFBWarnings(justification = "generated code")
      private List<DynamicStepActivationConfig> dynamicStepActivations;
      @SuppressFBWarnings(justification = "generated code")
      private Map<String, StepIdConfig> onFailureGotos;
      @SuppressFBWarnings(justification = "generated code")
      private List<ValueMapProviderConfig> customResponseAttributes;
      @SuppressFBWarnings(justification = "generated code")
      private List<ValueMapProviderConfig> customFailureResponseAttributes;
      @SuppressFBWarnings(justification = "generated code")
      private FidoSettingsConfig fidoSettings;

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

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder skipCondition(FlowConditionConfig skipCondition) {
         this.skipCondition = skipCondition;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder preCondition(FlowConditionConfig preCondition) {
         this.preCondition = preCondition;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder requiresActivation(boolean requiresActivation) {
         this.requiresActivation = requiresActivation;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder tagsOnSuccess(List<TagConfig> tagsOnSuccess) {
         this.tagsOnSuccess = tagsOnSuccess;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder stepId(@Nullable StepIdConfig stepId) {
         this.stepId = stepId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder interactiveGotoTargets(
         List<InteractiveGotoTargetConfig> interactiveGotoTargets
      ) {
         this.interactiveGotoTargets = interactiveGotoTargets;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder dynamicStepActivations(
         List<DynamicStepActivationConfig> dynamicStepActivations
      ) {
         this.dynamicStepActivations = dynamicStepActivations;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder onFailureGotos(Map<String, StepIdConfig> onFailureGotos) {
         this.onFailureGotos = onFailureGotos;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder customResponseAttributes(
         List<ValueMapProviderConfig> customResponseAttributes
      ) {
         this.customResponseAttributes = customResponseAttributes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder customFailureResponseAttributes(
         List<ValueMapProviderConfig> customFailureResponseAttributes
      ) {
         this.customFailureResponseAttributes = customFailureResponseAttributes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder fidoSettings(FidoSettingsConfig fidoSettings) {
         this.fidoSettings = fidoSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public FidoCredentialDisplayNameChangeStepConfig build() {
         return new FidoCredentialDisplayNameChangeStepConfig(
            this.skipCondition,
            this.preCondition,
            this.requiresActivation,
            this.tagsOnSuccess,
            this.stepId,
            this.interactiveGotoTargets,
            this.dynamicStepActivations,
            this.onFailureGotos,
            this.customResponseAttributes,
            this.customFailureResponseAttributes,
            this.fidoSettings
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "FidoCredentialDisplayNameChangeStepConfig.FidoCredentialDisplayNameChangeStepConfigBuilder(skipCondition="
            + this.skipCondition
            + ", preCondition="
            + this.preCondition
            + ", requiresActivation="
            + this.requiresActivation
            + ", tagsOnSuccess="
            + this.tagsOnSuccess
            + ", stepId="
            + this.stepId
            + ", interactiveGotoTargets="
            + this.interactiveGotoTargets
            + ", dynamicStepActivations="
            + this.dynamicStepActivations
            + ", onFailureGotos="
            + this.onFailureGotos
            + ", customResponseAttributes="
            + this.customResponseAttributes
            + ", customFailureResponseAttributes="
            + this.customFailureResponseAttributes
            + ", fidoSettings="
            + this.fidoSettings
            + ")";
      }
   }
}
