Package org.passay.rule
Class LengthComplexityRule
java.lang.Object
org.passay.rule.LengthComplexityRule
- All Implemented Interfaces:
Rule
Rule for determining if a password contains the desired complexity for a certain length. In order to meet the
criteria of this rule, passwords must meet all the supplied rules for a given password length.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to contain a tuple of interval string to rules.static classClass that represents an interval of numbers and parses interval notation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError code for insufficient complexity.static final StringError code for missing complexity rules.private final booleanWhether to report the details of this rule failure.private final booleanWhether to report the details of each complexity rule failure.private final Map<LengthComplexityRule.Interval,List<Rule>> Rules to apply when checking a password. -
Constructor Summary
ConstructorsConstructorDescriptionLengthComplexityRule(boolean reportFailure, boolean reportRuleFailures, Collection<LengthComplexityRule.Entry> intervals) Creates a new length complexity rule.LengthComplexityRule(boolean reportFailure, boolean reportRuleFailures, LengthComplexityRule.Entry... intervals) Creates a new length complexity rule.LengthComplexityRule(Collection<LengthComplexityRule.Entry> intervals) Creates a new length complexity rule.LengthComplexityRule(LengthComplexityRule.Entry... intervals) Creates a new length complexity rule. -
Method Summary
Modifier and TypeMethodDescriptioncreateRuleResultDetailParameters(int length, int success, int ruleCount) Creates the parameter data for the rule result detail.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 rule that fails to validate to the rule result.Map<LengthComplexityRule.Interval,List<? extends Rule>> getRules()Returns the password rules for this complexity rule.getRulesByLength(int length) Returns the rules that apply to the supplied password length.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE
Error code for insufficient complexity.- See Also:
-
ERROR_CODE_RULES
Error code for missing complexity rules.- See Also:
-
rules
Rules to apply when checking a password. -
reportFailure
private final boolean reportFailureWhether to report the details of this rule failure. -
reportRuleFailures
private final boolean reportRuleFailuresWhether to report the details of each complexity rule failure.
-
-
Constructor Details
-
LengthComplexityRule
Creates a new length complexity rule.- Parameters:
intervals- interval string to rules
-
LengthComplexityRule
Creates a new length complexity rule.- Parameters:
intervals- interval string to rules
-
LengthComplexityRule
public LengthComplexityRule(boolean reportFailure, boolean reportRuleFailures, LengthComplexityRule.Entry... intervals) Creates a new length complexity rule.- Parameters:
reportFailure- whether to report failuresreportRuleFailures- whether to report rule failuresintervals- interval string to rules
-
LengthComplexityRule
public LengthComplexityRule(boolean reportFailure, boolean reportRuleFailures, Collection<LengthComplexityRule.Entry> intervals) Creates a new length complexity rule.- Parameters:
reportFailure- whether to report failuresreportRuleFailures- whether to report rule failuresintervals- interval string to rules
-
-
Method Details
-
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
-
getReportRuleFailures
public boolean getReportRuleFailures()Returns whether to add the rule result detail for each rule that fails to validate to the rule result.- Returns:
- whether to add rule result details
-
getRules
Returns the password rules for this complexity rule.- Returns:
- unmodifiable map of password rules
-
validate
Description copied from interface:RuleValidates the supplied password data per the requirements of this rule. -
getRulesByLength
Returns the rules that apply to the supplied password length.- Parameters:
length- of the password- Returns:
- rules or null if length is not included in any interval
-
createRuleResultDetailParameters
protected Map<String,Object> createRuleResultDetailParameters(int length, int success, int ruleCount) Creates the parameter data for the rule result detail.- Parameters:
length- of the passwordsuccess- number of successful rulesruleCount- number of total rules- Returns:
- map of parameter name to value
-
toString
-