Package org.passay.rule
Class RepeatCharactersRule
java.lang.Object
org.passay.rule.RepeatCharactersRule
- All Implemented Interfaces:
Rule
Rule for determining if a password contains multiple sequences of repeating characters.
For example, the password "11a22b333xyz" will fail validation of this rule with a sequence length of 2 and sequence count of 3, since it contains 3 sequences (or more) of 2 repeating characters (or more).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault number of sequences, value is 1.protected static final intDefault length of sequence, value is 5.static final StringError code for regex validation failures.protected final intNumber of sequences of repeating characters to match.protected final intNumber of repeating characters to match in each sequence. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new repeat characters rule for a single sequence of the default sequence length.RepeatCharactersRule(int length) Creates a new repeat characters rule for a single sequence of the given length.RepeatCharactersRule(int length, int count) Creates a new repeat characters rule for the given number of sequences of the given length. -
Method Summary
Modifier and TypeMethodDescriptioncreateRuleResultDetailParameters(List<CharSequence> matches) Creates the parameter data for the rule result detail.intReturns the sequence count for this rule.intReturns the sequence length for this rule.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
ERROR_CODE
Error code for regex validation failures.- See Also:
-
DEFAULT_SEQUENCE_LENGTH
protected static final int DEFAULT_SEQUENCE_LENGTHDefault length of sequence, value is 5.- See Also:
-
DEFAULT_SEQUENCE_COUNT
protected static final int DEFAULT_SEQUENCE_COUNTDefault number of sequences, value is 1.- See Also:
-
sequenceLength
protected final int sequenceLengthNumber of repeating characters to match in each sequence. -
sequenceCount
protected final int sequenceCountNumber of sequences of repeating characters to match.
-
-
Constructor Details
-
RepeatCharactersRule
public RepeatCharactersRule()Creates a new repeat characters rule for a single sequence of the default sequence length. -
RepeatCharactersRule
public RepeatCharactersRule(int length) Creates a new repeat characters rule for a single sequence of the given length.- Parameters:
length- sequence length
-
RepeatCharactersRule
public RepeatCharactersRule(int length, int count) Creates a new repeat characters rule for the given number of sequences of the given length.- Parameters:
length- sequence lengthcount- sequence count
-
-
Method Details
-
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:
matches- the illegal matched sequences- Returns:
- map of parameter name to value
-
getSequenceLength
public int getSequenceLength()Returns the sequence length for this rule.- Returns:
- sequence length
-
getSequenceCount
public int getSequenceCount()Returns the sequence count for this rule.- Returns:
- sequence count
-
toString
-