Class RepeatCharactersRule

java.lang.Object
org.passay.rule.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).

  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for regex validation failures.
      See Also:
    • DEFAULT_SEQUENCE_LENGTH

      protected static final int DEFAULT_SEQUENCE_LENGTH
      Default length of sequence, value is 5.
      See Also:
    • DEFAULT_SEQUENCE_COUNT

      protected static final int DEFAULT_SEQUENCE_COUNT
      Default number of sequences, value is 1.
      See Also:
    • sequenceLength

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

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

    • RepeatCharactersRule

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

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

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

      public int getSequenceLength()
      Returns the sequence length for this rule.
      Returns:
      sequence length
    • getSequenceCount

      public int getSequenceCount()
      Returns the sequence count for this rule.
      Returns:
      sequence count
    • toString

      public String toString()
      Overrides:
      toString in class Object