org.opends.server.extensions
Class LengthBasedPasswordValidator

java.lang.Object
  extended by org.opends.server.api.PasswordValidator<LengthBasedPasswordValidatorCfg>
      extended by org.opends.server.extensions.LengthBasedPasswordValidator
All Implemented Interfaces:
ConfigurationChangeListener<LengthBasedPasswordValidatorCfg>

public class LengthBasedPasswordValidator
extends PasswordValidator<LengthBasedPasswordValidatorCfg>
implements ConfigurationChangeListener<LengthBasedPasswordValidatorCfg>

This class provides a password validator that can ensure that the provided password meets minimum and/or maximum length requirements.


Constructor Summary
LengthBasedPasswordValidator()
          Creates a new instance of this password validator.
 
Method Summary
 ConfigChangeResult applyConfigurationChange(LengthBasedPasswordValidatorCfg configuration)
          Applies the configuration changes to this change listener.
 void finalizePasswordValidator()
          Performs any finalization that might be required when this password validator is unloaded.
 void initializePasswordValidator(LengthBasedPasswordValidatorCfg configuration)
          Initializes this password validator based on the information in the provided configuration entry.
 boolean isConfigurationAcceptable(PasswordValidatorCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the provided configuration is acceptable for this password validator.
 boolean isConfigurationChangeAcceptable(LengthBasedPasswordValidatorCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 boolean passwordIsAcceptable(ByteString newPassword, java.util.Set<ByteString> currentPasswords, Operation operation, Entry userEntry, MessageBuilder invalidReason)
          Indicates whether the provided password is acceptable for use by the specified user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LengthBasedPasswordValidator

public LengthBasedPasswordValidator()
Creates a new instance of this password validator.

Method Detail

initializePasswordValidator

public void initializePasswordValidator(LengthBasedPasswordValidatorCfg configuration)
                                 throws ConfigException,
                                        InitializationException
Initializes this password validator based on the information in the provided configuration entry.

Specified by:
initializePasswordValidator in class PasswordValidator<LengthBasedPasswordValidatorCfg>
Parameters:
configuration - The configuration to use to initialize this password validator.
Throws:
ConfigException - If an unrecoverable problem arises in the process of performing the initialization.
InitializationException - If a problem occurs during initialization that is not related to the server configuration.

finalizePasswordValidator

public void finalizePasswordValidator()
Performs any finalization that might be required when this password validator is unloaded. No action is taken in the default implementation.

Overrides:
finalizePasswordValidator in class PasswordValidator<LengthBasedPasswordValidatorCfg>

passwordIsAcceptable

public boolean passwordIsAcceptable(ByteString newPassword,
                                    java.util.Set<ByteString> currentPasswords,
                                    Operation operation,
                                    Entry userEntry,
                                    MessageBuilder invalidReason)
Indicates whether the provided password is acceptable for use by the specified user. If the password is determined to be unacceptable, then a human-readable explanation should be appended to the provided buffer.

Specified by:
passwordIsAcceptable in class PasswordValidator<LengthBasedPasswordValidatorCfg>
Parameters:
newPassword - The proposed clear-text password that should be validated.
currentPasswords - The set of clear-text current passwords for the user (if available). Note that the current passwords may not always be available, and this may not comprise entire set of passwords currently for the user.
operation - The operation that is being used to set the password. It may be an add, a modify, or a password modify operation.
userEntry - The entry for the user whose password is being changed.
invalidReason - The buffer to which the human-readable explanation should be appended if it is determined that the password is not acceptable.
Returns:
true if the password is acceptable, or false if not.

isConfigurationAcceptable

public boolean isConfigurationAcceptable(PasswordValidatorCfg configuration,
                                         java.util.List<Message> unacceptableReasons)
Indicates whether the provided configuration is acceptable for this password validator. It should be possible to call this method on an uninitialized password validator instance in order to determine whether the password validator would be able to use the provided configuration.

Note that implementations which use a subclass of the provided configuration class will likely need to cast the configuration to the appropriate subclass type.

Overrides:
isConfigurationAcceptable in class PasswordValidator<LengthBasedPasswordValidatorCfg>
Parameters:
configuration - The password validator configuration for which to make the determination.
unacceptableReasons - A list that may be used to hold the reasons that the provided configuration is not acceptable.
Returns:
true if the provided configuration is acceptable for this password validator, or false if not.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(LengthBasedPasswordValidatorCfg configuration,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<LengthBasedPasswordValidatorCfg>
Parameters:
configuration - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(LengthBasedPasswordValidatorCfg configuration)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<LengthBasedPasswordValidatorCfg>
Parameters:
configuration - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.