com.ibm.passwordrules
Interface Rule

All Known Implementing Classes:
BehavioralRule, LexicalRule, RuleSet

public interface Rule

This interface needs to be implemented by all standard and custom password rule classes.

Author:
mbraksator

Method Summary
 void constrain(PasswordGenerator generator)
          Method will constrain the character set in the given password generator to values we know are valid.
 java.lang.String getParameter()
          Gets the constraining parameter set on a rule object
 boolean join(Rule rule)
          Try to join the specified rule with this one.
 void setParameter(java.lang.String parameter)
          Sets the constraining parameter on a rule object
 boolean validate(java.lang.String password, ValidationInfo validationInfo)
          Method will validate the given password using given validation info.
 boolean validateSafe(java.lang.String password, ValidationInfo validationInfo)
          Method will validate the given password using given validation info.
 

Method Detail

validate

public boolean validate(java.lang.String password,
                        ValidationInfo validationInfo)
                 throws InvalidPasswordException
Method will validate the given password using given validation info.
Parameters:
validationInfo - contains contextual information about the password being validated.
password - Password to validate.
Returns:
true if password is valid
Throws:
InvalidPasswordException - thrown when password is invalid.

validateSafe

public boolean validateSafe(java.lang.String password,
                            ValidationInfo validationInfo)
Method will validate the given password using given validation info. This version will never throw an exception, but will return false if the password is invalid or if it couldn't be validated. It is not possible to get any more information about why the password or password validation failed when using this method.
Parameters:
validationInfo - contains contextual information about the password being validated.
password - Password to validate.
Returns:
true if password is valid - false it isn't

constrain

public void constrain(PasswordGenerator generator)
Method will constrain the character set in the given password generator to values we know are valid.
Parameters:
generator - password generator, whose character set will be constrained. NOTE: Constraining a generator only offers a hint. Implementor of a Rule class may choose not to constrain the generator at all, in which case it may take more iterations for the generator to come up with a candidate password compliant with the rule. When constraints are not implemented, IterationsExceededException may be thrown from the generate method of the PasswordGenerator more often. Skipping a constraint should be tested first by attempting to generate a large number of passwords without encountering IterationsExceededException.

join

public boolean join(Rule rule)
             throws IncompatibleRulesException
Try to join the specified rule with this one. The more restrictive rule takes precedence.
Parameters:
rule - The rule to be joined with this one.
Returns:
True if the rule was successfully joined.
Throws:
IncompatibleRulesException - Thrown when given rule cannot be joined because it or its parameter is not compatible.

getParameter

public java.lang.String getParameter()
Gets the constraining parameter set on a rule object
Returns:
parameter String representing the constraining parameter

setParameter

public void setParameter(java.lang.String parameter)
Sets the constraining parameter on a rule object
Parameters:
parameter - String representing the constraining parameter