Package org.passay
Class UsernameRule
- java.lang.Object
-
- org.passay.UsernameRule
-
- All Implemented Interfaces:
Rule
public class UsernameRule extends Object implements Rule
Rule for determining if a password contains the username associated with that password. This rule returns true if a suppliedPasswordData
returns a null or empty username.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_CODE
Error code for matching username.static String
ERROR_CODE_REVERSED
Error code for matching reversed dictionary word.
-
Constructor Summary
Constructors Constructor Description UsernameRule()
Default constructor.UsernameRule(boolean mb, boolean ic)
Create a new username rule.UsernameRule(boolean mb, boolean ic, MatchBehavior behavior)
Create a new username rule.UsernameRule(MatchBehavior behavior)
Create a new username rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createRuleResultDetailParameters(String username)
Creates the parameter data for the rule result detail.boolean
isIgnoreCase()
Returns whether to ignore the case of the username.boolean
isMatchBackwards()
Returns whether to match the username backwards.void
setIgnoreCase(boolean b)
Sets whether the verify method will ignore case when searching the for a username.void
setMatchBackwards(boolean b)
Sets whether the verify method will search the password for the username spelled backwards as well as forwards.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 matching username.- See Also:
- Constant Field Values
-
ERROR_CODE_REVERSED
public static final String ERROR_CODE_REVERSED
Error code for matching reversed dictionary word.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UsernameRule
public UsernameRule()
Default constructor.
-
UsernameRule
public UsernameRule(MatchBehavior behavior)
Create a new username rule.- Parameters:
behavior
- how to match username
-
UsernameRule
public UsernameRule(boolean mb, boolean ic)
Create a new username rule.- Parameters:
mb
- whether to match backwardsic
- whether to ignore case
-
UsernameRule
public UsernameRule(boolean mb, boolean ic, MatchBehavior behavior)
Create a new username rule.- Parameters:
mb
- whether to match backwardsic
- whether to ignore casebehavior
- how to match username
-
-
Method Detail
-
setMatchBackwards
public void setMatchBackwards(boolean b)
Sets whether the verify method will search the password for the username spelled backwards as well as forwards.- Parameters:
b
- whether to match username backwards
-
isMatchBackwards
public boolean isMatchBackwards()
Returns whether to match the username backwards.- Returns:
- whether to match username backwards
-
setIgnoreCase
public void setIgnoreCase(boolean b)
Sets whether the verify method will ignore case when searching the for a username.- Parameters:
b
- whether to ignore case
-
isIgnoreCase
public boolean isIgnoreCase()
Returns whether to ignore the case of the username.- Returns:
- whether to ignore case
-
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(String username)
Creates the parameter data for the rule result detail.- Parameters:
username
- matching username- Returns:
- map of parameter name to value
-
-