Package org.passay
Class CharacterRule
- java.lang.Object
-
- org.passay.CharacterRule
-
-
Field Summary
Fields Modifier and Type Field Description protected CharacterData
characterData
Character data for this rule.protected int
numCharacters
Number of characters to require.
-
Constructor Summary
Constructors Constructor Description CharacterRule(CharacterData data)
Creates a new character rule.CharacterRule(CharacterData data, int num)
Creates a new character rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createRuleResultDetailParameters(String matchingChars)
Creates the parameter data for the rule result detail.protected RuleResultMetadata
createRuleResultMetadata(PasswordData password)
Creates the rule result metadata.CharacterData
getCharacterData()
Returns the character data for this rule.int
getNumberOfCharacters()
Returns the number of characters which must exist in order for a password to meet the requirements of this rule.String
getValidCharacters()
Returns the characters that are considered valid for this rule.void
setNumberOfCharacters(int n)
Sets the number of characters to require in a password.String
toString()
RuleResult
validate(PasswordData passwordData)
Validates the supplied password data per the requirements of this rule.
-
-
-
Field Detail
-
characterData
protected final CharacterData characterData
Character data for this rule.
-
numCharacters
protected int numCharacters
Number of characters to require. Default value is 1.
-
-
Constructor Detail
-
CharacterRule
public CharacterRule(CharacterData data)
Creates a new character rule.- Parameters:
data
- character data for this rule
-
CharacterRule
public CharacterRule(CharacterData data, int num)
Creates a new character rule.- Parameters:
data
- character data for this rulenum
- of characters to enforce
-
-
Method Detail
-
setNumberOfCharacters
public void setNumberOfCharacters(int n)
Sets the number of characters to require in a password.- Parameters:
n
- number of characters to require where n > 0
-
getNumberOfCharacters
public int getNumberOfCharacters()
Returns the number of characters which must exist in order for a password to meet the requirements of this rule.- Returns:
- number of characters to require
-
getCharacterData
public CharacterData getCharacterData()
Returns the character data for this rule.- Returns:
- character data
-
getValidCharacters
public String getValidCharacters()
Returns the characters that are considered valid for this rule.- Returns:
- valid characters
-
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 matchingChars)
Creates the parameter data for the rule result detail.- Parameters:
matchingChars
- characters found in the password- 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
-
-