Package org.passay

Class RepeatCharactersRule

  • All Implemented Interfaces:
    Rule

    public class RepeatCharactersRule
    extends Object
    implements Rule
    Rule for determining if a password contains multiple sequences of repeating characters.

    For example, the password "11a22b333xyz" will fail validation of this rule with a sequence length of 2 and sequence count of 3, since it contains 3 sequences (or more) of 2 repeating characters (or more).

    Author:
    Amichai Rothman
    • Field Detail

      • DEFAULT_SEQUENCE_LENGTH

        public static final int DEFAULT_SEQUENCE_LENGTH
        Default length of sequence, value is 5.
        See Also:
        Constant Field Values
      • DEFAULT_SEQUENCE_COUNT

        public static final int DEFAULT_SEQUENCE_COUNT
        Default number of sequences, value is 1.
        See Also:
        Constant Field Values
      • sequenceLength

        protected int sequenceLength
        Number of repeating characters to match in each sequence.
      • sequenceCount

        protected int sequenceCount
        Number of sequences of repeating characters to match.
    • Constructor Detail

      • RepeatCharactersRule

        public RepeatCharactersRule()
        Creates a new repeat characters rule for a single sequence of the default sequence length.
      • RepeatCharactersRule

        public RepeatCharactersRule​(int sl)
        Creates a new repeat characters rule for a single sequence of the given length.
        Parameters:
        sl - sequence length
      • RepeatCharactersRule

        public RepeatCharactersRule​(int sl,
                                    int sc)
        Creates a new repeat characters rule for the given number of sequences of the given length.
        Parameters:
        sl - sequence length
        sc - sequence count
    • 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​(List<String> matches)
        Creates the parameter data for the rule result detail.
        Parameters:
        matches - the illegal matched sequences
        Returns:
        map of parameter name to value