Package org.passay
Class WhitespaceRule
- java.lang.Object
-
- org.passay.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 Summary
Fields Modifier and Type Field Description protected static char[]
CHARS
Characters: TAB,LF,VT,FF,CR,Space.static String
ERROR_CODE
Error code for whitespace rule violation.protected boolean
reportAllFailures
Whether to report all whitespace matches or just the first.
-
Constructor Summary
Constructors Constructor Description WhitespaceRule()
Creates a new whitespace rule.WhitespaceRule(char[] chars)
Creates a new whitespace rule.WhitespaceRule(char[] chars, boolean reportAll)
Creates a new whitespace rule.WhitespaceRule(char[] chars, MatchBehavior behavior)
Creates a new whitespace rule.WhitespaceRule(char[] chars, MatchBehavior behavior, boolean reportAll)
Creates a new whitespace rule.WhitespaceRule(MatchBehavior behavior)
Creates a new whitespace rule.WhitespaceRule(MatchBehavior behavior, boolean reportAll)
Creates a new whitespace rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createRuleResultDetailParameters(char c)
Creates the parameter data for the rule result detail.protected RuleResultMetadata
createRuleResultMetadata(PasswordData password)
Creates the rule result metadata.MatchBehavior
getMatchBehavior()
Returns the match behavior for this rule.char[]
getWhitespaceCharacters()
Returns the whitespace characters for this rule.String
toString()
RuleResult
validate(PasswordData passwordData)
Validates the supplied password data per the requirements of this rule.
-
-
-
Field Detail
-
ERROR_CODE
public static final String ERROR_CODE
Error code for whitespace rule violation.- See Also:
- Constant Field Values
-
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 whitespacereportAll
- whether to report all matches or just the first
-
WhitespaceRule
public WhitespaceRule(char[] chars, MatchBehavior behavior)
Creates a new whitespace rule.- Parameters:
chars
- whitespace charactersbehavior
- how to match whitespace
-
WhitespaceRule
public WhitespaceRule(char[] chars, boolean reportAll)
Creates a new whitespace rule.- Parameters:
chars
- whitespace charactersreportAll
- 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 charactersbehavior
- how to match whitespacereportAll
- 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.
-
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
-
-