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

import com.airlock.iam.common.application.configuration.secretquestion.BasicSecretQuestionSettings;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(
   description = "<p>Does not allow users that cannot use secret questions to perform a public self-service and returns a corresponding feedback message. A user must have enough secret questions provisioned and they must be active for this user.</p><p>For public self-service flows using secret question identity verification, the purpose of this restriction is only to add an informative feedback message. This increases usability but could allow user enumeration since it makes it possible to find existing users without secret questions.</p><p>We recommend to configure this restriction as the last restriction to be checked.</p>"
)
public class DisabledOrMissingSecretQuestionsRestrictionConfig implements InternalPublicSelfServiceRestrictionConfig {
   @PluginProperty(description = "Settings related to secret questions.", optional = false)
   private BasicSecretQuestionSettings secretQuestionsSettings;

   public BasicSecretQuestionSettings getSecretQuestionsSettings() {
      return this.secretQuestionsSettings;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public DisabledOrMissingSecretQuestionsRestrictionConfig(BasicSecretQuestionSettings secretQuestionsSettings) {
      this.secretQuestionsSettings = secretQuestionsSettings;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class DisabledOrMissingSecretQuestionsRestrictionConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private BasicSecretQuestionSettings secretQuestionsSettings;

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

      @SuppressFBWarnings(justification = "generated code")
      public DisabledOrMissingSecretQuestionsRestrictionConfig.DisabledOrMissingSecretQuestionsRestrictionConfigBuilder secretQuestionsSettings(
         BasicSecretQuestionSettings secretQuestionsSettings
      ) {
         this.secretQuestionsSettings = secretQuestionsSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public DisabledOrMissingSecretQuestionsRestrictionConfig build() {
         return new DisabledOrMissingSecretQuestionsRestrictionConfig(this.secretQuestionsSettings);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "DisabledOrMissingSecretQuestionsRestrictionConfig.DisabledOrMissingSecretQuestionsRestrictionConfigBuilder(secretQuestionsSettings="
            + this.secretQuestionsSettings
            + ")";
      }
   }
}
