Package org.passay
Class LengthComplexityRule
- java.lang.Object
-
- org.passay.LengthComplexityRule
-
- All Implemented Interfaces:
Rule
public class LengthComplexityRule extends Object implements 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.- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LengthComplexityRule.Interval
Class that represents an interval of numbers and parses interval notation.
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_CODE
Error code for insufficient complexity.static String
ERROR_CODE_RULES
Error code for missing complexity rules.
-
Constructor Summary
Constructors Constructor Description LengthComplexityRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRules(String interval, List<Rule> l)
Adds the rules to invoke for the supplied interval.void
addRules(String interval, Rule... r)
Adds the rules to invoke for the supplied interval.protected Map<String,Object>
createRuleResultDetailParameters(int length, int success, int ruleCount)
Creates the parameter data for the rule result detail.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 rule that fails to validate to the rule result.Map<LengthComplexityRule.Interval,List<? extends Rule>>
getRules()
Returns the password rules for this complexity 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 rule that fails to validate to the rule result.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 complexity.- See Also:
- Constant Field Values
-
ERROR_CODE_RULES
public static final String ERROR_CODE_RULES
Error code for missing complexity rules.- See Also:
- Constant Field Values
-
-
Method Detail
-
addRules
public void addRules(String interval, List<Rule> l)
Adds the rules to invoke for the supplied interval.- Parameters:
interval
- of integers that the supplied rules apply tol
- list of rules- Throws:
IllegalArgumentException
- if the supplied rules are empty or null or if interval is invalid or intersects with an existing interval
-
addRules
public void addRules(String interval, Rule... r)
Adds the rules to invoke for the supplied interval.- Parameters:
interval
- of integers that the supplied rules apply tor
- list of 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
-
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
-
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
-
setReportRuleFailures
public void setReportRuleFailures(boolean b)
Sets whether to add the rule result detail for each rule that fails to validate to the rule result.- Parameters:
b
- whether to add rule result details
-
getRules
public Map<LengthComplexityRule.Interval,List<? extends Rule>> getRules()
Returns the password rules for this complexity rule.- Returns:
- unmodifiable map of password rules
-
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 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
-
-