Class CharacterCharacteristicsRule

java.lang.Object
org.passay.rule.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.
  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for insufficient number of characteristics.
      See Also:
    • rules

      private final List<CharacterRule> rules
      Rules to apply when checking a password.
    • numCharacteristics

      private final int numCharacteristics
      Number of rules to enforce. Default value is 1.
    • reportFailure

      private final boolean reportFailure
      Whether to report the details of this rule failure.
    • reportRuleFailures

      private final boolean reportRuleFailures
      Whether to report the details of each character rule failure.
  • Constructor Details

    • CharacterCharacteristicsRule

      public CharacterCharacteristicsRule(CharacterRule... rules)
      Creates a new character characteristics rule.
      Parameters:
      rules - character rules to set
    • CharacterCharacteristicsRule

      public CharacterCharacteristicsRule(List<CharacterRule> rules)
      Creates a new character characteristics rule.
      Parameters:
      rules - character rules to set
    • CharacterCharacteristicsRule

      public CharacterCharacteristicsRule(int numCharacteristics, CharacterRule... rules)
      Creates a new character characteristics rule.
      Parameters:
      numCharacteristics - number of characteristics to enforce, where n > 0
      rules - character rules to set
    • CharacterCharacteristicsRule

      public CharacterCharacteristicsRule(int numCharacteristics, List<CharacterRule> rules)
      Creates a new character characteristics rule.
      Parameters:
      numCharacteristics - number of characteristics to enforce, where n > 0
      rules - 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 failures
      reportRuleFailures - whether to report rule failures
      numCharacteristics - number of characteristics to enforce, where n > 0
      rules - 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 failures
      reportRuleFailures - whether to report rule failures
      numCharacteristics - number of characteristics to enforce, where n > 0
      rules - character rules to set
  • Method Details

    • getRules

      public List<CharacterRule> 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

      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
    • toString

      public String toString()
      Overrides:
      toString in class Object