Package org.passay

Class 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).
    Author:
    Middleware Services
    • Field Detail

      • CHARS

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

        protected boolean reportAllFailures
        Whether to report all whitespace matches or just the first.
    • Constructor Detail

      • 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​(char[] chars)
        Creates a new whitespace rule.
        Parameters:
        chars - characters 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​(char[] chars,
                              MatchBehavior behavior)
        Creates a new whitespace rule.
        Parameters:
        chars - whitespace characters
        behavior - how to match whitespace
      • WhitespaceRule

        public WhitespaceRule​(char[] chars,
                              boolean reportAll)
        Creates a new whitespace rule.
        Parameters:
        chars - whitespace characters
        reportAll - whether to report all matches or just the first
      • WhitespaceRule

        public WhitespaceRule​(char[] chars,
                              MatchBehavior behavior,
                              boolean reportAll)
        Creates a new whitespace rule.
        Parameters:
        chars - whitespace characters
        behavior - how to match whitespace
        reportAll - whether to report all matches or just the first
    • Method Detail

      • getWhitespaceCharacters

        public char[] 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​(char c)
        Creates the parameter data for the rule result detail.
        Parameters:
        c - whitespace character
        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