public class CustomPasswordEvaluator extends Object implements PasswordEvaluator, Serializable
PasswordEvaluator
containing all possibilities I can think of. DefaultPasswordEvaluator
is a "typical" implmentation.DefaultPasswordEvaluator
,
Serialized FormConstructor and Description |
---|
CustomPasswordEvaluator(String acceptedAlphaCharacters,
String acceptedNumericCharacters,
String acceptedSpecialCharacters,
int mininumLength,
int maximumLength,
int mininumLowercaseCharacters,
int mininumUppercaseCharacters,
int mininumNumericCharacters,
int mininumSpecialCharacters)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(String password)
Evaluate if the password is "strong" enough.
|
protected boolean |
doStringContainCharacter(String s,
char aChar) |
String |
generatePassword()
Generates a new password using the rules stated in the constructor.
|
String |
generatePassword(String useAsAvailableSpecialCharacters)
Generates a new password, with the ability to override what special characters to use in a new random password.
|
String |
getAcceptedAlphaCharacters() |
String |
getAcceptedNumericCharacters() |
String |
getAcceptedSpecialCharacters() |
String |
getDescription()
A description of the implementation of the
PasswordEvaluator . |
org.apache.commons.logging.Log |
getLogger() |
int |
getMaximumLength() |
int |
getMininumLength() |
int |
getMininumLowercaseCharacters() |
int |
getMininumNumericCharacters() |
int |
getMininumSpecialCharacters() |
int |
getMininumUppercaseCharacters() |
List<String> |
getRestrictions()
A list of strings describing the restrictions the evalutor has.
|
public CustomPasswordEvaluator(String acceptedAlphaCharacters, String acceptedNumericCharacters, String acceptedSpecialCharacters, int mininumLength, int maximumLength, int mininumLowercaseCharacters, int mininumUppercaseCharacters, int mininumNumericCharacters, int mininumSpecialCharacters)
acceptedAlphaCharacters
- a string containing the accepted alpha numeric characters in lower case.acceptedNumericCharacters
- a string containing the accepted numeric characters.acceptedSpecialCharacters
- a string containing the accepted special characters.mininumLength
- the minimum length of the password (inclusive), if less than or equal zero, no minimum length is imposed.maximumLength
- the maximum length of the password (inclusive), if less than or equal zero or if it is a lower value than minimum length, no maximum length is imposed.mininumLowercaseCharacters
- the minimum number of lower case characters the password must contain. If less than or equal zero than no minimum number of lower case characters restriction is imposed.mininumUppercaseCharacters
- the minimum number of upper case characters the password must contain. If less than or equal zero than no minimum number of upper case characters restriction is imposed.mininumNumericCharacters
- the minimum number of numeric characters the password must contain. If less than or equal zero than no minimum number of numeric characters restriction is imposed.mininumSpecialCharacters
- the minimum number of special characters the password must contain. If less than or equal zero than no minimum number of special characters restriction is imposed.public boolean accept(String password)
PasswordEvaluator
accept
in interface PasswordEvaluator
password
- the passwordtrue
if the password is strong enough otherwise false
.protected boolean doStringContainCharacter(String s, char aChar)
public String getDescription()
PasswordEvaluator
PasswordEvaluator
. getDescription
in interface PasswordEvaluator
PasswordEvaluator.getRestrictions()
public List<String> getRestrictions()
PasswordEvaluator
getRestrictions
in interface PasswordEvaluator
public String getAcceptedAlphaCharacters()
public String getAcceptedNumericCharacters()
public String getAcceptedSpecialCharacters()
public int getMininumLength()
public int getMaximumLength()
public int getMininumLowercaseCharacters()
public int getMininumNumericCharacters()
public int getMininumSpecialCharacters()
public int getMininumUppercaseCharacters()
public final String generatePassword()
generatePassword
in interface PasswordEvaluator
null
than has not be able to constructor a password which accept
will verify, something wrong with the rules in the constructor.public final String generatePassword(String useAsAvailableSpecialCharacters)
useAsAvailableSpecialCharacters
- override what special characters there shall be random choose from. Since some of the valid special character migth be to special for a new random password.null
than has not be able to constructor a password which accept
will verify, something wrong with the rules in the constructor or the overiden special characters.public org.apache.commons.logging.Log getLogger()