com.ibm.passwordrules.standard
Class RuleSet

java.lang.Object
  |
  +--com.ibm.passwordrules.standard.RuleSet
All Implemented Interfaces:
java.lang.Cloneable, Rule, java.io.Serializable

public class RuleSet
extends java.lang.Object
implements Rule, java.lang.Cloneable, java.io.Serializable

The RuleSet class represents a set of password rules. A RuleSet can be used to generate a random password that conforms to all password rules in the set. The RuleSet can also be used to test a given password for conformity to all rules present in the RuleSet. Additional rules may be added to the RuleSet using the join method. Note, that since RuleSet is a specialization of Rule, another RuleSet can be added to a this RuleSet.

See Also:
Serialized Form

Field Summary
static int ITERATION_LIMIT
          This constant is the hardcoded value for the maximum number of times during which a valid password is expected to be randomly generated by the standard generator.
 
Constructor Summary
RuleSet(PasswordRulesInfo rulesInfo)
          Constructor accepting PasswordRulesInfo parameter
 
Method Summary
 void constrain(PasswordGenerator generator)
          This Rule interface method in is not valid in the context of this class
 java.lang.String generate()
          Generate a random password compatible with all rules known to this object.
 int getLastIterationCount()
          Used for testing only.
 java.lang.String getParameter()
          This Rule interface method in is not valid in the context of this class
 java.util.Collection getRules()
          Return all rules contained in this RuleSet object.
 PasswordRulesInfo getRulesInfo()
          Get PasswordRulesInfo object associated with this RuleSet object.
 ValidationInfo getValidationInfo()
          Get ValidationInfo object containing the context of the validation.
 boolean join(Rule rule)
          Join given rule object with this RuleSet object.
 void join(RuleSet ruleSet)
          Join two RuleSet objects together.
static RuleSet loadFromXML(java.io.InputStream is)
          Generate a RuleSet object from the XML representation
static void saveToXML(RuleSet ruleSet, java.io.OutputStream os, java.lang.String title)
          Generate an XML representation from the given RuleSet object.
 void setParameter(java.lang.String parameter)
          This Rule interface method in is not valid in the context of this class
 void setRulesInfo(PasswordRulesInfo rulesInfo)
          Add rules from the given PasswordRulesInfo object on this RuleSet object.
 void setValidationInfo(ValidationInfo validationInfo)
          Set ValidationInfo object containing the context of the validation.
 boolean validate(java.lang.String password, ValidationInfo validationInfo)
          Validate the given password using the given validation info.
 boolean validateSafe(java.lang.String password, ValidationInfo validationInfo)
          Validate the given password using the given validation info.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITERATION_LIMIT

public static final int ITERATION_LIMIT
This constant is the hardcoded value for the maximum number of times during which a valid password is expected to be randomly generated by the standard generator.

See Also:
Constant Field Values
Constructor Detail

RuleSet

public RuleSet(PasswordRulesInfo rulesInfo)
Constructor accepting PasswordRulesInfo parameter

Parameters:
rulesInfo - PasswordRulesInfo value object containing the password rules.
Method Detail

loadFromXML

public static RuleSet loadFromXML(java.io.InputStream is)
                           throws java.lang.Exception
Generate a RuleSet object from the XML representation

Parameters:
is - InputStream to read the XML document from
Returns:
RuleSet object created from XMl data.
Throws:
java.lang.Exception - if any error occurs during XML processing.

saveToXML

public static void saveToXML(RuleSet ruleSet,
                             java.io.OutputStream os,
                             java.lang.String title)
                      throws java.lang.Exception
Generate an XML representation from the given RuleSet object.

Parameters:
ruleSet - RuleSet object t ocovnert to XML
os - OutputStream to write XML document to
title - of the XML document
Throws:
java.lang.Exception - Any exception thrown when converting ruleSet to XML.

setRulesInfo

public void setRulesInfo(PasswordRulesInfo rulesInfo)
Add rules from the given PasswordRulesInfo object on this RuleSet object.

Parameters:
rulesInfo - PasswordRulesInfo value object containing the password rules.

getRulesInfo

public PasswordRulesInfo getRulesInfo()
Get PasswordRulesInfo object associated with this RuleSet object.

Returns:
PasswordRulesInfo value object containing rules set on this object

getValidationInfo

public ValidationInfo getValidationInfo()
Get ValidationInfo object containing the context of the validation.

Returns:
ValidationInfo object.

setValidationInfo

public void setValidationInfo(ValidationInfo validationInfo)
Set ValidationInfo object containing the context of the validation.

Parameters:
validationInfo - ValidationInfo object

getRules

public java.util.Collection getRules()
Return all rules contained in this RuleSet object.

Returns:
Collection of Rule objects.

join

public void join(RuleSet ruleSet)
          throws IncompatibleRulesException
Join two RuleSet objects together.

Parameters:
ruleSet - RuleSet to join
Throws:
IncompatibleRulesException - when RuleSet object to join contains incompatible rules.

join

public boolean join(Rule rule)
             throws IncompatibleRulesException
Join given rule object with this RuleSet object.

Specified by:
join in interface Rule
Parameters:
rule - Rule object to join
Returns:
always returns true
Throws:
IncompatibleRulesException - when the Rule object to join contains an incompatible rule.

validate

public boolean validate(java.lang.String password,
                        ValidationInfo validationInfo)
                 throws InvalidPasswordException
Validate the given password using the given validation info.

Specified by:
validate in interface Rule
Parameters:
validationInfo - ValidationInfo object
password - Password to validate.
Returns:
always returns true
Throws:
InvalidPasswordException - Thrown when given password violates one of the rules.

generate

public java.lang.String generate()
                          throws IterationsExceededException
Generate a random password compatible with all rules known to this object.

Returns:
String object representing the generated password in plain text.
Throws:
IterationsExceededException - when a maximum number of iterations allowed before generating a valid password is exceeded.
See Also:
ITERATION_LIMIT

validateSafe

public boolean validateSafe(java.lang.String password,
                            ValidationInfo validationInfo)
Validate the given password using the given validation info. This version will never throw an exception, but will return false if the password is invalid. It is not possible to get any more information about why the password failed when using this version.

Specified by:
validateSafe in interface Rule
Parameters:
password - Password to validate.
validationInfo - ValidationInfo object
Returns:
true if the password validates false otherwise.

constrain

public void constrain(PasswordGenerator generator)
This Rule interface method in is not valid in the context of this class

Specified by:
constrain in interface Rule
Parameters:
generator - PasswordGenerator object to be constrained.

getParameter

public java.lang.String getParameter()
This Rule interface method in is not valid in the context of this class

Specified by:
getParameter in interface Rule
Returns:
String representing the parameter value.
Throws:
java.lang.RuntimeException - always

setParameter

public void setParameter(java.lang.String parameter)
This Rule interface method in is not valid in the context of this class

Specified by:
setParameter in interface Rule
Parameters:
parameter -
Throws:
java.lang.RuntimeException - always

getLastIterationCount

public int getLastIterationCount()
Used for testing only.

Returns:
int


IBM Tivoli Identity Manager 4.6
© Copyright International Business Machines Corporation 2005. All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.