Class WhitespaceRule

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

public class WhitespaceRule extends Object implements Rule
Rule for determining if a password contains whitespace characters. Whitespace is defined as tab (0x09), line feed (0x0A), vertical tab (0x0B), form feed (0x0C), carriage return (0x0D), and space (0x20).
  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for whitespace rule violation.
      See Also:
    • CHARS

      protected static final UnicodeString CHARS
      Characters: TAB,LF,VT,FF,CR,Space.
    • reportAllFailures

      protected final boolean reportAllFailures
      Whether to report all whitespace matches or just the first.
    • whitespaceCharacters

      private final int[] whitespaceCharacters
      Stores the whitespace characters that are allowed.
    • matchBehavior

      private final MatchBehavior matchBehavior
      Where to match whitespace.
  • Constructor Details

    • WhitespaceRule

      public WhitespaceRule()
      Creates a new whitespace rule.
    • WhitespaceRule

      public WhitespaceRule(MatchBehavior behavior)
      Creates a new whitespace rule.
      Parameters:
      behavior - how to match whitespace
    • WhitespaceRule

      public WhitespaceRule(UnicodeString unicodeString)
      Creates a new whitespace rule.
      Parameters:
      unicodeString - character code points that are whitespace
    • WhitespaceRule

      public WhitespaceRule(MatchBehavior behavior, boolean reportAll)
      Creates a new whitespace rule.
      Parameters:
      behavior - how to match whitespace
      reportAll - whether to report all matches or just the first
    • WhitespaceRule

      public WhitespaceRule(UnicodeString unicodeString, MatchBehavior behavior)
      Creates a new whitespace rule.
      Parameters:
      unicodeString - whitespace character code points
      behavior - how to match whitespace
    • WhitespaceRule

      public WhitespaceRule(UnicodeString unicodeString, boolean reportAll)
      Creates a new whitespace rule.
      Parameters:
      unicodeString - whitespace character code points
      reportAll - whether to report all matches or just the first
    • WhitespaceRule

      public WhitespaceRule(UnicodeString unicodeString, MatchBehavior behavior, boolean reportAll)
      Creates a new whitespace rule.
      Parameters:
      unicodeString - whitespace characters
      behavior - how to match whitespace
      reportAll - whether to report all 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
    • getWhitespaceCharacters

      public UnicodeString getWhitespaceCharacters()
      Returns the whitespace characters for this rule.
      Returns:
      whitespace characters
    • getMatchBehavior

      public MatchBehavior getMatchBehavior()
      Returns the match behavior for this rule.
      Returns:
      match behavior
    • 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(int cp)
      Creates the parameter data for the rule result detail.
      Parameters:
      cp - whitespace character code point
      Returns:
      map of parameter name to value
    • createRuleResultMetadata

      protected RuleResultMetadata createRuleResultMetadata(PasswordData password)
      Creates the rule result metadata.
      Parameters:
      password - data used for metadata creation
      Returns:
      rule result metadata
    • toString

      public String toString()
      Overrides:
      toString in class Object