Package org.passay.rule
Class CharacterOccurrencesRule
java.lang.Object
org.passay.rule.CharacterOccurrencesRule
- All Implemented Interfaces:
Rule
Validates that a password does not contain too many occurrences of the same character.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError code for too many occurrences of a character.protected final intMaximum umber of occurrences to allow. -
Constructor Summary
ConstructorsConstructorDescriptionCharacterOccurrencesRule(int maxAllowedOccurrences) Creates a new character occurrences rule. -
Method Summary
Modifier and TypeMethodDescriptioncreateRuleResultDetailParameters(String character, int occurrences) Creates the parameter data for the rule result detail.intReturns the max occurrences.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE
Error code for too many occurrences of a character.- See Also:
-
maxOccurrences
protected final int maxOccurrencesMaximum umber of occurrences to allow.
-
-
Constructor Details
-
CharacterOccurrencesRule
public CharacterOccurrencesRule(int maxAllowedOccurrences) Creates a new character occurrences rule.- Parameters:
maxAllowedOccurrences- the maximum allowed number of occurrences of any character
-
-
Method Details
-
getMaxOccurrences
public int getMaxOccurrences()Returns the max occurrences.- Returns:
- max occurrences
-
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:
character- the character that occurred too many timesoccurrences- the number of times the character occurred- Returns:
- map of parameter name to value
-
toString
-