Package org.passay.rule
Class CharacterCharacteristicsRule
java.lang.Object
org.passay.rule.CharacterCharacteristicsRule
- All Implemented Interfaces:
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError code for insufficient number of characteristics.private final intNumber of rules to enforce.private final booleanWhether to report the details of this rule failure.private final booleanWhether to report the details of each character rule failure.private final List<CharacterRule>Rules to apply when checking a password. -
Constructor Summary
ConstructorsConstructorDescriptionCharacterCharacteristicsRule(boolean reportFailure, boolean reportRuleFailures, int numCharacteristics, List<CharacterRule> rules) Creates a new character characteristics rule.CharacterCharacteristicsRule(boolean reportFailure, boolean reportRuleFailures, int numCharacteristics, CharacterRule... rules) Creates a new character characteristics rule.CharacterCharacteristicsRule(int numCharacteristics, List<CharacterRule> rules) Creates a new character characteristics rule.CharacterCharacteristicsRule(int numCharacteristics, CharacterRule... rules) Creates a new character characteristics rule.Creates a new character characteristics rule.CharacterCharacteristicsRule(CharacterRule... rules) Creates a new character characteristics rule. -
Method Summary
Modifier and TypeMethodDescriptioncreateRuleResultDetailParameters(int success) Creates the parameter data for the rule result detail.intReturns the number of characteristics which currently must be satisfied in order for a password to meet the requirements of this rule.booleanReturns whether to add the rule result detail of this rule to the rule result.booleanReturns whether to add the rule result detail for each character rule that fails to validate to the rule result.getRules()Returns the character rules used by this rule.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE
Error code for insufficient number of characteristics.- See Also:
-
rules
Rules to apply when checking a password. -
numCharacteristics
private final int numCharacteristicsNumber of rules to enforce. Default value is 1. -
reportFailure
private final boolean reportFailureWhether to report the details of this rule failure. -
reportRuleFailures
private final boolean reportRuleFailuresWhether to report the details of each character rule failure.
-
-
Constructor Details
-
CharacterCharacteristicsRule
Creates a new character characteristics rule.- Parameters:
rules- character rules to set
-
CharacterCharacteristicsRule
Creates a new character characteristics rule.- Parameters:
rules- character rules to set
-
CharacterCharacteristicsRule
Creates a new character characteristics rule.- Parameters:
numCharacteristics- number of characteristics to enforce, where n > 0rules- character rules to set
-
CharacterCharacteristicsRule
Creates a new character characteristics rule.- Parameters:
numCharacteristics- number of characteristics to enforce, where n > 0rules- character rules to set
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(boolean reportFailure, boolean reportRuleFailures, int numCharacteristics, CharacterRule... rules) Creates a new character characteristics rule.- Parameters:
reportFailure- whether to report failuresreportRuleFailures- whether to report rule failuresnumCharacteristics- number of characteristics to enforce, where n > 0rules- character rules to set
-
CharacterCharacteristicsRule
public CharacterCharacteristicsRule(boolean reportFailure, boolean reportRuleFailures, int numCharacteristics, List<CharacterRule> rules) Creates a new character characteristics rule.- Parameters:
reportFailure- whether to report failuresreportRuleFailures- whether to report rule failuresnumCharacteristics- number of characteristics to enforce, where n > 0rules- character rules to set
-
-
Method Details
-
getRules
Returns the character rules used by this rule.- Returns:
- list of character rules
-
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
-
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
-
validate
Description copied from interface:RuleValidates the supplied password data per the requirements of this rule. -
createRuleResultDetailParameters
Creates the parameter data for the rule result detail.- Parameters:
success- number of successful rules- Returns:
- map of parameter name to value
-
toString
-