Class IllegalSequenceRule

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

public class IllegalSequenceRule extends Object implements Rule
Password validation rule that prevents illegal sequences of characters, e.g. keyboard, alphabetical, numeric.
  • Field Details

    • DEFAULT_SEQUENCE_LENGTH

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

      protected static final int MINIMUM_SEQUENCE_LENGTH
      Minimum length of keyboard sequence, value is 3.
      See Also:
    • sequenceData

      protected final SequenceData sequenceData
      Sequence data for this rule.
    • sequenceLength

      protected final int sequenceLength
      Number of characters in sequence to match.
    • wrapSequence

      protected final boolean wrapSequence
      Whether to wrap a sequence when searching for matches.
    • reportAllFailures

      protected final boolean reportAllFailures
      Whether to report all sequence matches or just the first.
  • Constructor Details

    • IllegalSequenceRule

      public IllegalSequenceRule(SequenceData data)
      Creates a new sequence rule with the supplied list of characters.
      Parameters:
      data - sequence data for this rule
    • IllegalSequenceRule

      public IllegalSequenceRule(SequenceData data, int length)
      Creates a new sequence rule with the supplied list of characters.
      Parameters:
      data - sequence data for this rule
      length - sequence length
    • IllegalSequenceRule

      public IllegalSequenceRule(SequenceData data, int length, boolean wrap)
      Creates a new sequence rule with the supplied list of characters.
      Parameters:
      data - sequence data for this rule
      length - sequence length
      wrap - whether to wrap sequences
    • IllegalSequenceRule

      public IllegalSequenceRule(SequenceData data, int length, boolean wrap, boolean reportAll)
      Creates a new sequence rule with the supplied list of characters.
      Parameters:
      data - sequence data for this rule
      length - sequence length
      wrap - whether to wrap sequences
      reportAll - whether to report all sequence matches or just the first
  • Method Details

    • getReportAllFailures

      public boolean getReportAllFailures()
      Returns whether to report all matches or just the first.
      Returns:
      whether to report all matches or just the first
    • getSequenceLength

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

      public SequenceData getSequenceData()
      Returns the sequence data for this rule.
      Returns:
      sequence data
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • indexOf

      private int indexOf(CharacterSequence sequence, int cp)
      Returns the index of the given character within the given sequence, or -1 if it is not found.
      Parameters:
      sequence - a sequence of characters
      cp - the code point to find in the character sequence
      Returns:
      the index of the character within the sequence, or -1
    • addError

      private void addError(List<RuleResultDetail> details, String match)
      Adds a validation error to a result.
      Parameters:
      details - list of rule results to add a new rule result error
      match - the illegal sequence in the password that caused the error