Package org.passay
Class PasswordValidator
- java.lang.Object
-
- org.passay.PasswordValidator
-
-
Constructor Summary
Constructors Constructor Description PasswordValidator(List<? extends Rule> rules)
Creates a new password validator with aPropertiesMessageResolver
.PasswordValidator(MessageResolver resolver, List<? extends Rule> rules)
Creates a new password validator.PasswordValidator(MessageResolver resolver, Rule... rules)
PasswordValidator(Rule... rules)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
estimateEntropy(PasswordData passwordData)
Calculates the entropy of the givenPasswordData
based on the specified password rules specified.MessageResolver
getMessageResolver()
Returns the message resolver for this validator.List<String>
getMessages(RuleResult result)
Returns a list of human-readable messages by iterating over the details in a failed rule result.List<? extends Rule>
getRules()
Returns the password rules for this validator.String
toString()
RuleResult
validate(PasswordData passwordData)
Validates the supplied password data against the rules in this validator.
-
-
-
Constructor Detail
-
PasswordValidator
public PasswordValidator(Rule... rules)
- Parameters:
rules
- to validate
-
PasswordValidator
public PasswordValidator(List<? extends Rule> rules)
Creates a new password validator with aPropertiesMessageResolver
.- Parameters:
rules
- to validate
-
PasswordValidator
public PasswordValidator(MessageResolver resolver, Rule... rules)
- Parameters:
resolver
- message resolver.rules
- to validate
-
PasswordValidator
public PasswordValidator(MessageResolver resolver, List<? extends Rule> rules)
Creates a new password validator.- Parameters:
resolver
- message resolver.rules
- to validate
-
-
Method Detail
-
getRules
public List<? extends Rule> getRules()
Returns the password rules for this validator.- Returns:
- unmodifiable list of password rules
-
getMessageResolver
public MessageResolver getMessageResolver()
Returns the message resolver for this validator.- Returns:
- message resolver
-
validate
public RuleResult validate(PasswordData passwordData)
Validates the supplied password data against the rules in this validator.
-
estimateEntropy
public double estimateEntropy(PasswordData passwordData)
Calculates the entropy of the givenPasswordData
based on the specified password rules specified. It's important to note that this method does NOT take into accountIllegalRegexRule
orAllowedRegexRule
as the regular expressions driving the rules may be negative matches.- Parameters:
passwordData
- to estimate entropy for- Returns:
- entropy estimate
- Throws:
IllegalArgumentException
- for unknownPasswordData.Origin
or if the requiredCharacterRule
instances are unavailable in thepasswordRules
of this validator instance.- See Also:
- PDF Publication
-
getMessages
public List<String> getMessages(RuleResult result)
Returns a list of human-readable messages by iterating over the details in a failed rule result.- Parameters:
result
- failed rule result.- Returns:
- list of human-readable messages describing the reason(s) for validation failure.
-
-