Package org.passay

Class CharacterOccurrencesRule

  • All Implemented Interfaces:

    public class CharacterOccurrencesRule
    extends Object
    implements Rule
    Validates that a password does not contain too many occurrences of the same character.
    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.
        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
        passwordData - to verify (not null).
        details on password verification
      • createRuleResultDetailParameters

        protected Map<String,​Object> createRuleResultDetailParameters​(char c,
                                                                            int occurrences)
        Creates the parameter data for the rule result detail.
        c - the character that occurred too many times
        occurrences - the number of times the character occurred
        map of parameter name to value