Package org.passay

Class 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
    • Constructor Detail

      • LengthComplexityRule

        public LengthComplexityRule()
    • 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 to
        l - 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 to
        r - 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
      • validate

        public RuleResult validate​(PasswordData passwordData)
        Description copied from interface: Rule
        Validates the supplied password data per the requirements of this rule.
        Specified by:
        validate in interface Rule
        Parameters:
        passwordData - to verify (not null).
        Returns:
        details on password verification
      • 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 password
        success - number of successful rules
        ruleCount - number of total rules
        Returns:
        map of parameter name to value