Package org.passay

Class 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.
    Author:
    Amichai Rothman
    • Field Detail

      • ERROR_CODE

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

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

      • CharacterOccurrencesRule

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

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