Package org.passay

Class 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 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 > 0
        r - 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 > 0
        l - 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.
        Specified by:
        validate in interface Rule
        Parameters:
        passwordData - to verify (not null).
        Returns:
        details on password verification
      • 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