Package org.passay
Class CharacterCharacteristicsRule
- java.lang.Object
-
- org.passay.CharacterCharacteristicsRule
-
- All Implemented Interfaces:
Rule
public class CharacterCharacteristicsRule extends Object implements Rule
Rule for determining if a password contains the desired mix of character types. In order to meet the criteria of this rule, passwords must meet any number of supplied character rules.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_CODE
Error code for insufficient number of characteristics.
-
Constructor Summary
Constructors Constructor Description CharacterCharacteristicsRule()
Default constructor.CharacterCharacteristicsRule(int n, List<CharacterRule> l)
Creates a new character characteristics rule.CharacterCharacteristicsRule(int n, CharacterRule... r)
Creates a new character characteristics rule.CharacterCharacteristicsRule(List<CharacterRule> l)
Creates a new character characteristics rule.CharacterCharacteristicsRule(CharacterRule... r)
Creates a new character characteristics rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createRuleResultDetailParameters(int success)
Creates the parameter data for the rule result detail.int
getNumberOfCharacteristics()
Returns the number of characteristics which currently must be satisfied in order for a password to meet the requirements of this rule.boolean
getReportFailure()
Returns whether to add the rule result detail of this rule to the rule result.boolean
getReportRuleFailures()
Returns whether to add the rule result detail for each character rule that fails to validate to the rule result.List<CharacterRule>
getRules()
Returns the character rules used by this rule.void
setNumberOfCharacteristics(int n)
Sets the number of characteristics which must be satisfied in order for a password to meet the requirements of this rule.void
setReportFailure(boolean b)
Sets whether to add the rule result detail of this rule to the rule result.void
setReportRuleFailures(boolean b)
Sets whether to add the rule result detail for each character rule that fails to validate to the rule result.void
setRules(List<CharacterRule> l)
Sets the character rules used by this rule.void
setRules(CharacterRule... r)
Sets the character rules used by this rule.String
toString()
RuleResult
validate(PasswordData passwordData)
Validates the supplied password data per the requirements of this rule.
-
-
-
Field Detail
-
ERROR_CODE
public static final String ERROR_CODE
Error code for insufficient number of characteristics.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule()
Default constructor.
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(CharacterRule... r)
Creates a new character characteristics rule.- Parameters:
r
- character rules to set
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(List<CharacterRule> l)
Creates a new character characteristics rule.- Parameters:
l
- character rules to set
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(int n, CharacterRule... r)
Creates a new character characteristics rule.- Parameters:
n
- number of characteristics to enforce, where n > 0r
- character rules to set
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(int n, List<CharacterRule> l)
Creates a new character characteristics rule.- Parameters:
n
- number of characteristics to enforce, where n > 0l
- character rules to set
-
-
Method Detail
-
getRules
public List<CharacterRule> getRules()
Returns the character rules used by this rule.- Returns:
- list of character rules
-
setRules
public void setRules(List<CharacterRule> l)
Sets the character rules used by this rule.- Parameters:
l
- list of rules
-
setRules
public void setRules(CharacterRule... r)
Sets the character rules used by this rule.- Parameters:
r
- character rules to set
-
setNumberOfCharacteristics
public void setNumberOfCharacteristics(int n)
Sets the number of characteristics which must be satisfied in order for a password to meet the requirements of this rule. The default is one. i.e. you may wish to enforce any three of five supplied character rules.- Parameters:
n
- number of characteristics to enforce, where n > 0
-
getReportFailure
public boolean getReportFailure()
Returns whether to add the rule result detail of this rule to the rule result.- Returns:
- whether to add rule result detail of this rule
-
setReportFailure
public void setReportFailure(boolean b)
Sets whether to add the rule result detail of this rule to the rule result.- Parameters:
b
- whether to add rule result detail of this rule
-
getNumberOfCharacteristics
public int getNumberOfCharacteristics()
Returns the number of characteristics which currently must be satisfied in order for a password to meet the requirements of this rule.- Returns:
- number of characteristics to enforce
-
getReportRuleFailures
public boolean getReportRuleFailures()
Returns whether to add the rule result detail for each character rule that fails to validate to the rule result.- Returns:
- whether to add character rule result details
-
setReportRuleFailures
public void setReportRuleFailures(boolean b)
Sets whether to add the rule result detail for each character rule that fails to validate to the rule result.- Parameters:
b
- whether to add character rule result details
-
validate
public RuleResult validate(PasswordData passwordData)
Description copied from interface:Rule
Validates the supplied password data per the requirements of this rule.
-
createRuleResultDetailParameters
protected Map<String,Object> createRuleResultDetailParameters(int success)
Creates the parameter data for the rule result detail.- Parameters:
success
- number of successful rules- Returns:
- map of parameter name to value
-
-