package com.airlock.iam.common.application.configuration.event;

import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.RegexProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.regex.Pattern;

@Plugin(description = "Event that is triggered when a user's account is locked.", displayName = "User Locked")
public class UserLockedSubscribedEventConfig implements LoginappUserSubscribedEventConfig, AdminappUserSubscribedEventConfig {
   @RegexProperty(
      description = "A pattern for matching the lock reason. If the lock reason does not match, the event will not be handled.",
      optional = true,
      defaultValue = ".*",
      exampleValues = {
            ".*",
            "LockReason\\.TooManyLoginFailed",
            "LockReason\\.MaxWrongOldPassword",
            "LockReason\\.MaxUnlockAttemptsExceeded",
            "LockReason\\.FraudReportedByUser"
      }
   )
   private Pattern lockReason;

   public Pattern getLockReason() {
      return this.lockReason;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public UserLockedSubscribedEventConfig(Pattern lockReason) {
      this.lockReason = lockReason;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class UserLockedSubscribedEventConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Pattern lockReason;

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

      @SuppressFBWarnings(justification = "generated code")
      public UserLockedSubscribedEventConfig.UserLockedSubscribedEventConfigBuilder lockReason(Pattern lockReason) {
         this.lockReason = lockReason;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "UserLockedSubscribedEventConfig.UserLockedSubscribedEventConfigBuilder(lockReason=" + this.lockReason + ")";
      }
   }
}
