package com.airlock.iam.servicecontainer.app.application.configuration.radius;

import com.airlock.iam.core.misc.authen.Authenticator;
import com.airlock.iam.core.misc.authen.PasswordPolicy;
import com.airlock.iam.core.misc.authen.PasswordService;
import com.airlock.iam.core.misc.authen.PasswordSettings;
import com.airlock.iam.core.misc.authen.UsernameTransformer;
import com.airlock.iam.core.misc.authen.locking.TemporaryLockingSettings;
import com.airlock.iam.core.misc.persistency.UserPersister;
import com.airlock.iam.plugin.api.annotation.config.ConfigurationValidator;
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 com.airlock.iam.plugin.api.annotation.property.BooleanProperty;
import com.airlock.iam.plugin.api.annotation.property.GroupProperty;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import com.airlock.iam.plugin.api.config.ConfigurationContext;
import com.airlock.iam.plugin.api.config.ConfigurationEnvironment;
import com.airlock.iam.plugin.api.config.Environment;
import com.airlock.iam.plugin.api.config.PluginConfiguration;
import com.airlock.iam.plugin.api.exception.ConfigurationException;
import com.airlock.iam.plugin.api.exception.PropertyConstraintViolationException;
import com.airlock.iam.plugin.api.exception.PropertyTypeMismatchException;
import com.airlock.iam.plugin.api.valuereader.BooleanPropertyValueReader;
import com.airlock.iam.plugin.api.valuereader.PluginPropertyValueReader;
import com.airlock.iam.servicecontainer.app.application.service.radius.RadiusResponseModifier;
import com.airlock.iam.servicecontainer.app.application.service.radius.service.RadiusRolesConfiguration;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Optional;

@Plugin(
   description = "A RADIUS server implementation that provides the authentication scheme defined by a configurable underlying authenticator as RADIUS service.",
   displayName = "Radius Authentication Service"
)
@PluginLicenseRestriction(moduleAffiliation = "RadiusServer")
@Groups(groupSequence = {"Basic Settings", "Optional Authentication Settings", "Reply Message Settings", "Advanced Settings"}, openGroups = "Basic Settings")
public final class RadiusServiceConfig extends RadiusServiceConfigBase {
   @PluginProperty(
      description = "The password settings. If defined, password change is enabled over the RADIUS interface.",
      optional = true,
      globalPluginReference = "globalPasswordSettings"
   )
   @GroupProperty(groupIdentifier = "Optional Authentication Settings")
   private PasswordSettings passwordSettings;
   private static final String PASSWORD_SETTINGS_FIELD = "passwordSettings";
   @BooleanProperty(
      description = "If enabled, password change is enabled over the RADIUS interface (requires password settings).",
      optional = true,
      defaultValue = "false"
   )
   @GroupProperty(groupIdentifier = "Optional Authentication Settings")
   private boolean enablePasswordChange;
   private static final String ENABLE_PASSWORD_CHANGE_FIELD = "enablePasswordChange";

   @Override
   Optional<PasswordService> getPasswordService() {
      return !this.enablePasswordChange ? Optional.empty() : Optional.ofNullable(this.passwordSettings).map(PasswordSettings::getPasswordService);
   }

   @Override
   Optional<PasswordPolicy> getPasswordPolicy() {
      return !this.enablePasswordChange ? Optional.empty() : Optional.ofNullable(this.passwordSettings).map(PasswordSettings::getPasswordPolicy);
   }

   @ConfigurationValidator
   static void validateRadiusServerConfig(
      PluginConfiguration config, ConfigurationEnvironment env, ConfigurationContext context, Environment validationEnvironment
   ) throws ConfigurationException {
      if (isPasswordChangeEnabled(config, env, context) && isPasswordSettingsFieldIsSet(config, env, context)) {
         throw new PropertyConstraintViolationException(
            "passwordSettings", config, env, context, "Password settings are required if password change is enabled."
         );
      }
   }

   private static boolean isPasswordChangeEnabled(PluginConfiguration config, ConfigurationEnvironment env, ConfigurationContext context) throws PropertyConstraintViolationException, PropertyTypeMismatchException {
      return Boolean.TRUE.equals(BooleanPropertyValueReader.effectiveBooleanPropertyValue(config, "enablePasswordChange", env, context));
   }

   private static boolean isPasswordSettingsFieldIsSet(PluginConfiguration config, ConfigurationEnvironment env, ConfigurationContext context) throws PropertyTypeMismatchException {
      return PluginPropertyValueReader.effectivePluginPropertyValue(config, "passwordSettings", env, context) == null;
   }

   public RadiusServiceConfig(
      int port,
      String interfaceIp,
      boolean enforceMessageAuthenticator,
      String sharedSecret,
      Authenticator authenticator,
      TemporaryLockingSettings temporaryLockingSettings,
      UserPersister userPersister,
      RadiusAuthorizationConfig authorizationSettings,
      String charsetForPassword,
      boolean blockingIfAsynchronous,
      int authenticatorPollingIntervalMillis,
      int authenticatorPollingTimeoutSecs,
      boolean airlock2FAPasscodeFallback,
      String ssoAttribute,
      RadiusRolesConfiguration radiusRolesConfiguration,
      boolean logRadiusRequests,
      int sessionTableSize,
      int retransmissionTableSize,
      long retransmissionIntervalMillis,
      int packetBufferSize,
      boolean useRsaAceCompatibilityMode,
      String staticRejectedUser,
      String accessAcceptReplyMessage,
      String accessAcceptPasswordChangedReplyMessage,
      String accessDeniedReplyMessage,
      String userLockedReplyMessage,
      String userTemporarilyLockedReplyMessage,
      String notAuthorizedReplyMessage,
      String nextTokenModeReplyMessage,
      String newPinReplyMessage,
      String pinAcceptedReplyMessage,
      String tokenRequiredReplyMessage,
      String credentialUnassignedReplyMessage,
      String indexChallengeReplyMessage,
      String matrixChallengeReplyMessage,
      String changePasswordReplyMessage,
      String confirmPasswordReplyMessage,
      String passwordsDoNotMatchReplyMessage,
      String passwordNotAcceptedReplyMessage,
      String asynchronousReplyMessage,
      List<UsernameTransformer> usernameTransformers,
      String tokenSelectionChoiceMessage,
      boolean usePasswordAsToken,
      List<RadiusResponseModifier> acceptModifiers,
      PasswordSettings passwordSettings,
      boolean enablePasswordChange
   ) {
      super(
         port,
         interfaceIp,
         enforceMessageAuthenticator,
         sharedSecret,
         authenticator,
         temporaryLockingSettings,
         userPersister,
         authorizationSettings,
         charsetForPassword,
         blockingIfAsynchronous,
         authenticatorPollingIntervalMillis,
         authenticatorPollingTimeoutSecs,
         airlock2FAPasscodeFallback,
         ssoAttribute,
         radiusRolesConfiguration,
         logRadiusRequests,
         sessionTableSize,
         retransmissionTableSize,
         retransmissionIntervalMillis,
         packetBufferSize,
         useRsaAceCompatibilityMode,
         staticRejectedUser,
         accessAcceptReplyMessage,
         accessAcceptPasswordChangedReplyMessage,
         accessDeniedReplyMessage,
         userLockedReplyMessage,
         userTemporarilyLockedReplyMessage,
         notAuthorizedReplyMessage,
         nextTokenModeReplyMessage,
         newPinReplyMessage,
         pinAcceptedReplyMessage,
         tokenRequiredReplyMessage,
         credentialUnassignedReplyMessage,
         indexChallengeReplyMessage,
         matrixChallengeReplyMessage,
         changePasswordReplyMessage,
         confirmPasswordReplyMessage,
         passwordsDoNotMatchReplyMessage,
         passwordNotAcceptedReplyMessage,
         asynchronousReplyMessage,
         usernameTransformers,
         tokenSelectionChoiceMessage,
         usePasswordAsToken,
         acceptModifiers
      );
      this.passwordSettings = passwordSettings;
      this.enablePasswordChange = enablePasswordChange;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class RadiusServiceConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private int port;
      @SuppressFBWarnings(justification = "generated code")
      private String interfaceIp;
      @SuppressFBWarnings(justification = "generated code")
      private boolean enforceMessageAuthenticator;
      @SuppressFBWarnings(justification = "generated code")
      private String sharedSecret;
      @SuppressFBWarnings(justification = "generated code")
      private Authenticator authenticator;
      @SuppressFBWarnings(justification = "generated code")
      private TemporaryLockingSettings temporaryLockingSettings;
      @SuppressFBWarnings(justification = "generated code")
      private UserPersister userPersister;
      @SuppressFBWarnings(justification = "generated code")
      private RadiusAuthorizationConfig authorizationSettings;
      @SuppressFBWarnings(justification = "generated code")
      private String charsetForPassword;
      @SuppressFBWarnings(justification = "generated code")
      private boolean blockingIfAsynchronous;
      @SuppressFBWarnings(justification = "generated code")
      private int authenticatorPollingIntervalMillis;
      @SuppressFBWarnings(justification = "generated code")
      private int authenticatorPollingTimeoutSecs;
      @SuppressFBWarnings(justification = "generated code")
      private boolean airlock2FAPasscodeFallback;
      @SuppressFBWarnings(justification = "generated code")
      private String ssoAttribute;
      @SuppressFBWarnings(justification = "generated code")
      private RadiusRolesConfiguration radiusRolesConfiguration;
      @SuppressFBWarnings(justification = "generated code")
      private boolean logRadiusRequests;
      @SuppressFBWarnings(justification = "generated code")
      private int sessionTableSize;
      @SuppressFBWarnings(justification = "generated code")
      private int retransmissionTableSize;
      @SuppressFBWarnings(justification = "generated code")
      private long retransmissionIntervalMillis;
      @SuppressFBWarnings(justification = "generated code")
      private int packetBufferSize;
      @SuppressFBWarnings(justification = "generated code")
      private boolean useRsaAceCompatibilityMode;
      @SuppressFBWarnings(justification = "generated code")
      private String staticRejectedUser;
      @SuppressFBWarnings(justification = "generated code")
      private String accessAcceptReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String accessAcceptPasswordChangedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String accessDeniedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String userLockedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String userTemporarilyLockedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String notAuthorizedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String nextTokenModeReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String newPinReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String pinAcceptedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String tokenRequiredReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String credentialUnassignedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String indexChallengeReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String matrixChallengeReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String changePasswordReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String confirmPasswordReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String passwordsDoNotMatchReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String passwordNotAcceptedReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private String asynchronousReplyMessage;
      @SuppressFBWarnings(justification = "generated code")
      private List<UsernameTransformer> usernameTransformers;
      @SuppressFBWarnings(justification = "generated code")
      private String tokenSelectionChoiceMessage;
      @SuppressFBWarnings(justification = "generated code")
      private boolean usePasswordAsToken;
      @SuppressFBWarnings(justification = "generated code")
      private List<RadiusResponseModifier> acceptModifiers;
      @SuppressFBWarnings(justification = "generated code")
      private PasswordSettings passwordSettings;
      @SuppressFBWarnings(justification = "generated code")
      private boolean enablePasswordChange;

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

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder port(int port) {
         this.port = port;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder interfaceIp(String interfaceIp) {
         this.interfaceIp = interfaceIp;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder enforceMessageAuthenticator(boolean enforceMessageAuthenticator) {
         this.enforceMessageAuthenticator = enforceMessageAuthenticator;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder sharedSecret(String sharedSecret) {
         this.sharedSecret = sharedSecret;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder authenticator(Authenticator authenticator) {
         this.authenticator = authenticator;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder temporaryLockingSettings(TemporaryLockingSettings temporaryLockingSettings) {
         this.temporaryLockingSettings = temporaryLockingSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder userPersister(UserPersister userPersister) {
         this.userPersister = userPersister;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder authorizationSettings(RadiusAuthorizationConfig authorizationSettings) {
         this.authorizationSettings = authorizationSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder charsetForPassword(String charsetForPassword) {
         this.charsetForPassword = charsetForPassword;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder blockingIfAsynchronous(boolean blockingIfAsynchronous) {
         this.blockingIfAsynchronous = blockingIfAsynchronous;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder authenticatorPollingIntervalMillis(int authenticatorPollingIntervalMillis) {
         this.authenticatorPollingIntervalMillis = authenticatorPollingIntervalMillis;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder authenticatorPollingTimeoutSecs(int authenticatorPollingTimeoutSecs) {
         this.authenticatorPollingTimeoutSecs = authenticatorPollingTimeoutSecs;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder airlock2FAPasscodeFallback(boolean airlock2FAPasscodeFallback) {
         this.airlock2FAPasscodeFallback = airlock2FAPasscodeFallback;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder ssoAttribute(String ssoAttribute) {
         this.ssoAttribute = ssoAttribute;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder radiusRolesConfiguration(RadiusRolesConfiguration radiusRolesConfiguration) {
         this.radiusRolesConfiguration = radiusRolesConfiguration;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder logRadiusRequests(boolean logRadiusRequests) {
         this.logRadiusRequests = logRadiusRequests;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder sessionTableSize(int sessionTableSize) {
         this.sessionTableSize = sessionTableSize;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder retransmissionTableSize(int retransmissionTableSize) {
         this.retransmissionTableSize = retransmissionTableSize;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder retransmissionIntervalMillis(long retransmissionIntervalMillis) {
         this.retransmissionIntervalMillis = retransmissionIntervalMillis;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder packetBufferSize(int packetBufferSize) {
         this.packetBufferSize = packetBufferSize;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder useRsaAceCompatibilityMode(boolean useRsaAceCompatibilityMode) {
         this.useRsaAceCompatibilityMode = useRsaAceCompatibilityMode;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder staticRejectedUser(String staticRejectedUser) {
         this.staticRejectedUser = staticRejectedUser;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder accessAcceptReplyMessage(String accessAcceptReplyMessage) {
         this.accessAcceptReplyMessage = accessAcceptReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder accessAcceptPasswordChangedReplyMessage(String accessAcceptPasswordChangedReplyMessage) {
         this.accessAcceptPasswordChangedReplyMessage = accessAcceptPasswordChangedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder accessDeniedReplyMessage(String accessDeniedReplyMessage) {
         this.accessDeniedReplyMessage = accessDeniedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder userLockedReplyMessage(String userLockedReplyMessage) {
         this.userLockedReplyMessage = userLockedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder userTemporarilyLockedReplyMessage(String userTemporarilyLockedReplyMessage) {
         this.userTemporarilyLockedReplyMessage = userTemporarilyLockedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder notAuthorizedReplyMessage(String notAuthorizedReplyMessage) {
         this.notAuthorizedReplyMessage = notAuthorizedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder nextTokenModeReplyMessage(String nextTokenModeReplyMessage) {
         this.nextTokenModeReplyMessage = nextTokenModeReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder newPinReplyMessage(String newPinReplyMessage) {
         this.newPinReplyMessage = newPinReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder pinAcceptedReplyMessage(String pinAcceptedReplyMessage) {
         this.pinAcceptedReplyMessage = pinAcceptedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder tokenRequiredReplyMessage(String tokenRequiredReplyMessage) {
         this.tokenRequiredReplyMessage = tokenRequiredReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder credentialUnassignedReplyMessage(String credentialUnassignedReplyMessage) {
         this.credentialUnassignedReplyMessage = credentialUnassignedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder indexChallengeReplyMessage(String indexChallengeReplyMessage) {
         this.indexChallengeReplyMessage = indexChallengeReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder matrixChallengeReplyMessage(String matrixChallengeReplyMessage) {
         this.matrixChallengeReplyMessage = matrixChallengeReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder changePasswordReplyMessage(String changePasswordReplyMessage) {
         this.changePasswordReplyMessage = changePasswordReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder confirmPasswordReplyMessage(String confirmPasswordReplyMessage) {
         this.confirmPasswordReplyMessage = confirmPasswordReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder passwordsDoNotMatchReplyMessage(String passwordsDoNotMatchReplyMessage) {
         this.passwordsDoNotMatchReplyMessage = passwordsDoNotMatchReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder passwordNotAcceptedReplyMessage(String passwordNotAcceptedReplyMessage) {
         this.passwordNotAcceptedReplyMessage = passwordNotAcceptedReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder asynchronousReplyMessage(String asynchronousReplyMessage) {
         this.asynchronousReplyMessage = asynchronousReplyMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder usernameTransformers(List<UsernameTransformer> usernameTransformers) {
         this.usernameTransformers = usernameTransformers;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder tokenSelectionChoiceMessage(String tokenSelectionChoiceMessage) {
         this.tokenSelectionChoiceMessage = tokenSelectionChoiceMessage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder usePasswordAsToken(boolean usePasswordAsToken) {
         this.usePasswordAsToken = usePasswordAsToken;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder acceptModifiers(List<RadiusResponseModifier> acceptModifiers) {
         this.acceptModifiers = acceptModifiers;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder passwordSettings(PasswordSettings passwordSettings) {
         this.passwordSettings = passwordSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig.RadiusServiceConfigBuilder enablePasswordChange(boolean enablePasswordChange) {
         this.enablePasswordChange = enablePasswordChange;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public RadiusServiceConfig build() {
         return new RadiusServiceConfig(
            this.port,
            this.interfaceIp,
            this.enforceMessageAuthenticator,
            this.sharedSecret,
            this.authenticator,
            this.temporaryLockingSettings,
            this.userPersister,
            this.authorizationSettings,
            this.charsetForPassword,
            this.blockingIfAsynchronous,
            this.authenticatorPollingIntervalMillis,
            this.authenticatorPollingTimeoutSecs,
            this.airlock2FAPasscodeFallback,
            this.ssoAttribute,
            this.radiusRolesConfiguration,
            this.logRadiusRequests,
            this.sessionTableSize,
            this.retransmissionTableSize,
            this.retransmissionIntervalMillis,
            this.packetBufferSize,
            this.useRsaAceCompatibilityMode,
            this.staticRejectedUser,
            this.accessAcceptReplyMessage,
            this.accessAcceptPasswordChangedReplyMessage,
            this.accessDeniedReplyMessage,
            this.userLockedReplyMessage,
            this.userTemporarilyLockedReplyMessage,
            this.notAuthorizedReplyMessage,
            this.nextTokenModeReplyMessage,
            this.newPinReplyMessage,
            this.pinAcceptedReplyMessage,
            this.tokenRequiredReplyMessage,
            this.credentialUnassignedReplyMessage,
            this.indexChallengeReplyMessage,
            this.matrixChallengeReplyMessage,
            this.changePasswordReplyMessage,
            this.confirmPasswordReplyMessage,
            this.passwordsDoNotMatchReplyMessage,
            this.passwordNotAcceptedReplyMessage,
            this.asynchronousReplyMessage,
            this.usernameTransformers,
            this.tokenSelectionChoiceMessage,
            this.usePasswordAsToken,
            this.acceptModifiers,
            this.passwordSettings,
            this.enablePasswordChange
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "RadiusServiceConfig.RadiusServiceConfigBuilder(port="
            + this.port
            + ", interfaceIp="
            + this.interfaceIp
            + ", enforceMessageAuthenticator="
            + this.enforceMessageAuthenticator
            + ", sharedSecret="
            + this.sharedSecret
            + ", authenticator="
            + this.authenticator
            + ", temporaryLockingSettings="
            + this.temporaryLockingSettings
            + ", userPersister="
            + this.userPersister
            + ", authorizationSettings="
            + this.authorizationSettings
            + ", charsetForPassword="
            + this.charsetForPassword
            + ", blockingIfAsynchronous="
            + this.blockingIfAsynchronous
            + ", authenticatorPollingIntervalMillis="
            + this.authenticatorPollingIntervalMillis
            + ", authenticatorPollingTimeoutSecs="
            + this.authenticatorPollingTimeoutSecs
            + ", airlock2FAPasscodeFallback="
            + this.airlock2FAPasscodeFallback
            + ", ssoAttribute="
            + this.ssoAttribute
            + ", radiusRolesConfiguration="
            + this.radiusRolesConfiguration
            + ", logRadiusRequests="
            + this.logRadiusRequests
            + ", sessionTableSize="
            + this.sessionTableSize
            + ", retransmissionTableSize="
            + this.retransmissionTableSize
            + ", retransmissionIntervalMillis="
            + this.retransmissionIntervalMillis
            + ", packetBufferSize="
            + this.packetBufferSize
            + ", useRsaAceCompatibilityMode="
            + this.useRsaAceCompatibilityMode
            + ", staticRejectedUser="
            + this.staticRejectedUser
            + ", accessAcceptReplyMessage="
            + this.accessAcceptReplyMessage
            + ", accessAcceptPasswordChangedReplyMessage="
            + this.accessAcceptPasswordChangedReplyMessage
            + ", accessDeniedReplyMessage="
            + this.accessDeniedReplyMessage
            + ", userLockedReplyMessage="
            + this.userLockedReplyMessage
            + ", userTemporarilyLockedReplyMessage="
            + this.userTemporarilyLockedReplyMessage
            + ", notAuthorizedReplyMessage="
            + this.notAuthorizedReplyMessage
            + ", nextTokenModeReplyMessage="
            + this.nextTokenModeReplyMessage
            + ", newPinReplyMessage="
            + this.newPinReplyMessage
            + ", pinAcceptedReplyMessage="
            + this.pinAcceptedReplyMessage
            + ", tokenRequiredReplyMessage="
            + this.tokenRequiredReplyMessage
            + ", credentialUnassignedReplyMessage="
            + this.credentialUnassignedReplyMessage
            + ", indexChallengeReplyMessage="
            + this.indexChallengeReplyMessage
            + ", matrixChallengeReplyMessage="
            + this.matrixChallengeReplyMessage
            + ", changePasswordReplyMessage="
            + this.changePasswordReplyMessage
            + ", confirmPasswordReplyMessage="
            + this.confirmPasswordReplyMessage
            + ", passwordsDoNotMatchReplyMessage="
            + this.passwordsDoNotMatchReplyMessage
            + ", passwordNotAcceptedReplyMessage="
            + this.passwordNotAcceptedReplyMessage
            + ", asynchronousReplyMessage="
            + this.asynchronousReplyMessage
            + ", usernameTransformers="
            + this.usernameTransformers
            + ", tokenSelectionChoiceMessage="
            + this.tokenSelectionChoiceMessage
            + ", usePasswordAsToken="
            + this.usePasswordAsToken
            + ", acceptModifiers="
            + this.acceptModifiers
            + ", passwordSettings="
            + this.passwordSettings
            + ", enablePasswordChange="
            + this.enablePasswordChange
            + ")";
      }
   }
}
