Class CharacterOccurrencesRule

java.lang.Object
org.passay.rule.CharacterOccurrencesRule
All Implemented Interfaces:
Rule

public class CharacterOccurrencesRule extends Object implements Rule
Validates that a password does not contain too many occurrences of the same character.
  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for too many occurrences of a character.
      See Also:
    • maxOccurrences

      protected final int maxOccurrences
      Maximum umber of occurrences to allow.
  • Constructor Details

    • CharacterOccurrencesRule

      public CharacterOccurrencesRule(int maxAllowedOccurrences)
      Creates a new character occurrences rule.
      Parameters:
      maxAllowedOccurrences - the maximum allowed number of occurrences of any character
  • Method Details

    • getMaxOccurrences

      public int getMaxOccurrences()
      Returns the max occurrences.
      Returns:
      max occurrences
    • 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(String character, int occurrences)
      Creates the parameter data for the rule result detail.
      Parameters:
      character - the character that occurred too many times
      occurrences - the number of times the character occurred
      Returns:
      map of parameter name to value
    • toString

      public String toString()
      Overrides:
      toString in class Object