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

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.types.api.application.configuration.step.StepConfigForAuthenticationFlows;
import com.airlock.iam.flow.types.api.application.configuration.step.StepConfigForTransactionApprovalFlows;
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 = "Step to verify a matrix card/index list challenge.", displayName = "Matrix Checking Step")
@PluginLicenseRestriction(moduleAffiliation = "Matrixcard")
@Groups(groupSequence = {"Basic Settings", "Tags/Guards", "Flow Control", "Advanced Settings"}, openGroups = "Basic Settings")
public final class MatrixAuthStepConfig
   extends CommonMatrixCheckingStepConfig
   implements StepConfigForAuthenticationFlows,
   StepConfigForTransactionApprovalFlows {
   private MatrixAuthStepConfig(
      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 MatrixAuthStepConfig.MatrixAuthStepConfigBuilder builder() {
      return new MatrixAuthStepConfig.MatrixAuthStepConfigBuilder();
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class MatrixAuthStepConfigBuilder {
      @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")
      MatrixAuthStepConfigBuilder() {
      }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public MatrixAuthStepConfig build() {
         return new MatrixAuthStepConfig(
            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 "MatrixAuthStepConfig.MatrixAuthStepConfigBuilder(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
            + ")";
      }
   }
}
