Package org.passay.rule
Class IllegalSequenceRule
java.lang.Object
org.passay.rule.IllegalSequenceRule
- All Implemented Interfaces:
Rule
Password validation rule that prevents illegal sequences of characters, e.g. keyboard, alphabetical, numeric.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault length of keyboard sequence, value is 5.protected static final intMinimum length of keyboard sequence, value is 3.protected final booleanWhether to report all sequence matches or just the first.protected final SequenceDataSequence data for this rule.protected final intNumber of characters in sequence to match.protected final booleanWhether to wrap a sequence when searching for matches. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new sequence rule with the supplied list of characters.IllegalSequenceRule(SequenceData data, int length) Creates a new sequence rule with the supplied list of characters.IllegalSequenceRule(SequenceData data, int length, boolean wrap) Creates a new sequence rule with the supplied list of characters.IllegalSequenceRule(SequenceData data, int length, boolean wrap, boolean reportAll) Creates a new sequence rule with the supplied list of characters. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddError(List<RuleResultDetail> details, String match) Adds a validation error to a result.booleanReturns whether to report all matches or just the first.Returns the sequence data for this rule.intReturns the sequence length for this rule.private intindexOf(CharacterSequence sequence, int cp) Returns the index of the given character within the given sequence, or -1 if it is not found.toString()validate(PasswordData passwordData) Validates the supplied password data per the requirements of this rule.
-
Field Details
-
DEFAULT_SEQUENCE_LENGTH
protected static final int DEFAULT_SEQUENCE_LENGTHDefault length of keyboard sequence, value is 5.- See Also:
-
MINIMUM_SEQUENCE_LENGTH
protected static final int MINIMUM_SEQUENCE_LENGTHMinimum length of keyboard sequence, value is 3.- See Also:
-
sequenceData
Sequence data for this rule. -
sequenceLength
protected final int sequenceLengthNumber of characters in sequence to match. -
wrapSequence
protected final boolean wrapSequenceWhether to wrap a sequence when searching for matches. -
reportAllFailures
protected final boolean reportAllFailuresWhether to report all sequence matches or just the first.
-
-
Constructor Details
-
IllegalSequenceRule
Creates a new sequence rule with the supplied list of characters.- Parameters:
data- sequence data for this rule
-
IllegalSequenceRule
Creates a new sequence rule with the supplied list of characters.- Parameters:
data- sequence data for this rulelength- sequence length
-
IllegalSequenceRule
Creates a new sequence rule with the supplied list of characters.- Parameters:
data- sequence data for this rulelength- sequence lengthwrap- whether to wrap sequences
-
IllegalSequenceRule
Creates a new sequence rule with the supplied list of characters.- Parameters:
data- sequence data for this rulelength- sequence lengthwrap- whether to wrap sequencesreportAll- whether to report all sequence matches or just the first
-
-
Method Details
-
getReportAllFailures
public boolean getReportAllFailures()Returns whether to report all matches or just the first.- Returns:
- whether to report all matches or just the first
-
getSequenceLength
public int getSequenceLength()Returns the sequence length for this rule.- Returns:
- sequence length
-
getSequenceData
Returns the sequence data for this rule.- Returns:
- sequence data
-
validate
Description copied from interface:RuleValidates the supplied password data per the requirements of this rule. -
toString
-
indexOf
Returns the index of the given character within the given sequence, or -1 if it is not found.- Parameters:
sequence- a sequence of characterscp- the code point to find in the character sequence- Returns:
- the index of the character within the sequence, or -1
-
addError
Adds a validation error to a result.- Parameters:
details- list of rule results to add a new rule result errormatch- the illegal sequence in the password that caused the error
-