package com.airlock.iam.publicselfservice.application.configuration.steps;

import com.airlock.iam.core.misc.renderer.TokenListRenderer;
import com.airlock.iam.core.misc.tanserver.service.TanService;
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.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.application.configuration.matrix.CommonMatrixCheckingStepConfig;
import com.airlock.iam.flow.types.api.application.configuration.step.StepConfigForPublicSelfServiceFlows;
import com.airlock.iam.plugin.api.annotation.config.Groups;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.license.PluginLicenseRestriction;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import java.util.List;
import java.util.Map;

@Plugin(
   description = "Configuration for a matrix approval step for public self-service flows.<p>Note that unlike identity verification steps, approval steps require an existing user and cannot prevent username enumeration (no stealth mode). It is therefore important that approval steps are only used <em>after</em> an identity verification step.</p>",
   displayName = "Matrix Public Self-Service Approval Step"
)
@Groups(openGroups = "Basic Settings", groupSequence = {"Basic Settings", "Tags/Guards", "Flow Control", "Advanced Settings"})
@PluginLicenseRestriction(moduleAffiliation = "Matrixcard")
public final class MatrixCardPublicSelfServiceApprovalStepConfig extends CommonMatrixCheckingStepConfig implements StepConfigForPublicSelfServiceFlows {
   private MatrixCardPublicSelfServiceApprovalStepConfig(
      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,
      TanService tanService,
      CommonMatrixCheckingStepConfig.MatrixCardType tanListType,
      TokenListRenderer tokenListRenderer,
      String authenticationMethodId,
      int startIndex,
      Integer responseValidityMillis,
      int maxRetries,
      boolean newChallengeOnRetry,
      boolean countUnansweredChallenges,
      int unansweredChallengeTimeout,
      int maxUnansweredChallenges
   ) {
      super(
         skipCondition,
         preCondition,
         requiresActivation,
         tagsOnSuccess,
         stepId,
         interactiveGotoTargets,
         dynamicStepActivations,
         onFailureGotos,
         customResponseAttributes,
         customFailureResponseAttributes,
         tanService,
         tanListType,
         tokenListRenderer,
         authenticationMethodId,
         startIndex,
         responseValidityMillis,
         maxRetries,
         newChallengeOnRetry,
         countUnansweredChallenges,
         unansweredChallengeTimeout,
         maxUnansweredChallenges
      );
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class MatrixCardPublicSelfServiceApprovalStepConfigBuilder {
      @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 TanService tanService;
      @SuppressFBWarnings(justification = "generated code")
      private CommonMatrixCheckingStepConfig.MatrixCardType tanListType;
      @SuppressFBWarnings(justification = "generated code")
      private TokenListRenderer tokenListRenderer;
      @SuppressFBWarnings(justification = "generated code")
      private String authenticationMethodId;
      @SuppressFBWarnings(justification = "generated code")
      private int startIndex;
      @SuppressFBWarnings(justification = "generated code")
      private Integer responseValidityMillis;
      @SuppressFBWarnings(justification = "generated code")
      private int maxRetries;
      @SuppressFBWarnings(justification = "generated code")
      private boolean newChallengeOnRetry;
      @SuppressFBWarnings(justification = "generated code")
      private boolean countUnansweredChallenges;
      @SuppressFBWarnings(justification = "generated code")
      private int unansweredChallengeTimeout;
      @SuppressFBWarnings(justification = "generated code")
      private int maxUnansweredChallenges;

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

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

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

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

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

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

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder tanService(TanService tanService) {
         this.tanService = tanService;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder tanListType(
         CommonMatrixCheckingStepConfig.MatrixCardType tanListType
      ) {
         this.tanListType = tanListType;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder tokenListRenderer(
         TokenListRenderer tokenListRenderer
      ) {
         this.tokenListRenderer = tokenListRenderer;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder authenticationMethodId(
         String authenticationMethodId
      ) {
         this.authenticationMethodId = authenticationMethodId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder startIndex(int startIndex) {
         this.startIndex = startIndex;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder responseValidityMillis(
         Integer responseValidityMillis
      ) {
         this.responseValidityMillis = responseValidityMillis;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder maxRetries(int maxRetries) {
         this.maxRetries = maxRetries;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder newChallengeOnRetry(boolean newChallengeOnRetry) {
         this.newChallengeOnRetry = newChallengeOnRetry;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder countUnansweredChallenges(
         boolean countUnansweredChallenges
      ) {
         this.countUnansweredChallenges = countUnansweredChallenges;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder unansweredChallengeTimeout(
         int unansweredChallengeTimeout
      ) {
         this.unansweredChallengeTimeout = unansweredChallengeTimeout;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder maxUnansweredChallenges(
         int maxUnansweredChallenges
      ) {
         this.maxUnansweredChallenges = maxUnansweredChallenges;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MatrixCardPublicSelfServiceApprovalStepConfig build() {
         return new MatrixCardPublicSelfServiceApprovalStepConfig(
            this.skipCondition,
            this.preCondition,
            this.requiresActivation,
            this.tagsOnSuccess,
            this.stepId,
            this.interactiveGotoTargets,
            this.dynamicStepActivations,
            this.onFailureGotos,
            this.customResponseAttributes,
            this.customFailureResponseAttributes,
            this.tanService,
            this.tanListType,
            this.tokenListRenderer,
            this.authenticationMethodId,
            this.startIndex,
            this.responseValidityMillis,
            this.maxRetries,
            this.newChallengeOnRetry,
            this.countUnansweredChallenges,
            this.unansweredChallengeTimeout,
            this.maxUnansweredChallenges
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "MatrixCardPublicSelfServiceApprovalStepConfig.MatrixCardPublicSelfServiceApprovalStepConfigBuilder(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
            + ", tanService="
            + this.tanService
            + ", tanListType="
            + this.tanListType
            + ", tokenListRenderer="
            + this.tokenListRenderer
            + ", authenticationMethodId="
            + this.authenticationMethodId
            + ", startIndex="
            + this.startIndex
            + ", responseValidityMillis="
            + this.responseValidityMillis
            + ", maxRetries="
            + this.maxRetries
            + ", newChallengeOnRetry="
            + this.newChallengeOnRetry
            + ", countUnansweredChallenges="
            + this.countUnansweredChallenges
            + ", unansweredChallengeTimeout="
            + this.unansweredChallengeTimeout
            + ", maxUnansweredChallenges="
            + this.maxUnansweredChallenges
            + ")";
      }
   }
}
