Package org.passay.rule
Class UsernameRule
java.lang.Object
org.passay.rule.UsernameRule
- All Implemented Interfaces:
Rule
Rule for determining if a password contains the username associated with that password. This rule returns true if a
supplied
PasswordData returns a null or empty username.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError code for matching username.static final StringError code for matching reversed dictionary word.private final booleanWhether to ignore case when checking for usernames.private final booleanWhether to search for username backwards.private final MatchBehaviorWhere to match username. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.UsernameRule(boolean matchBackwards, boolean ignoreCase) Create a new username rule.UsernameRule(boolean matchBackwards, boolean ignoreCase, MatchBehavior behavior) Create a new username rule.UsernameRule(MatchBehavior behavior) Create a new username rule. -
Method Summary
Modifier and TypeMethodDescriptioncreateRuleResultDetailParameters(CharSequence username) Creates the parameter data for the rule result detail.Returns the match behavior for this rule.booleanReturns whether to ignore the case of the username.booleanReturns whether to match the username backwards.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE
Error code for matching username.- See Also:
-
ERROR_CODE_REVERSED
Error code for matching reversed dictionary word.- See Also:
-
matchBackwards
private final boolean matchBackwardsWhether to search for username backwards. -
ignoreCase
private final boolean ignoreCaseWhether to ignore case when checking for usernames. -
matchBehavior
Where to match username.
-
-
Constructor Details
-
UsernameRule
public UsernameRule()Default constructor. -
UsernameRule
Create a new username rule.- Parameters:
behavior- how to match username
-
UsernameRule
public UsernameRule(boolean matchBackwards, boolean ignoreCase) Create a new username rule.- Parameters:
matchBackwards- whether to match backwardsignoreCase- whether to ignore case
-
UsernameRule
Create a new username rule.- Parameters:
matchBackwards- whether to match backwardsignoreCase- whether to ignore casebehavior- how to match username
-
-
Method Details
-
isMatchBackwards
public boolean isMatchBackwards()Returns whether to match the username backwards.- Returns:
- whether to match username backwards
-
isIgnoreCase
public boolean isIgnoreCase()Returns whether to ignore the case of the username.- Returns:
- whether to ignore case
-
getMatchBehavior
Returns the match behavior for this rule.- Returns:
- match behavior
-
validate
Description copied from interface:RuleValidates the supplied password data per the requirements of this rule. -
createRuleResultDetailParameters
Creates the parameter data for the rule result detail.- Parameters:
username- matching username- Returns:
- map of parameter name to value
-
toString
-