Package fr.becpg.repo.authentication
Class SecurePasswordGenerator
java.lang.Object
fr.becpg.repo.authentication.SecurePasswordGenerator
Utility class that generates a random password using a cryptographically strong
random source (
SecureRandom).
The generated password has the following characteristics:
- Length: 15 characters.
- Contains at least one uppercase letter (
A-ZbutI O). - Contains at least one lowercase letter (
a-zbutl). - Contains at least one digit (
2-9). - Contains at least one special character from:
@%*-_=+!.
The password is sent by mail and typed back by the user, so the alphabet excludes characters that
alter or blur it: & and # start HTML character references a mail client decodes,
I l 1 O 0 look alike, ^ is a dead key on AZERTY keyboards and punctuation such as
. ( ) [ ] stops a double-click selection.
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringConstantALL="UPPER + LOWER + DIGIT + SPECIAL"private static final StringConstantDIGIT="23456789"private static final StringConstantLOWER="abcdefghijkmnopqrstuvwxyz"private static final SecureRandomConstantRANDOMprivate static final intNumber of characters drawn fromALLonce each character class holds one: 15 characters in all, one more than the policy minimum, to make up for the smaller alphabet (about 90 bits of entropy).(package private) static final StringConstantSPECIAL="@%*-_=+!"private static final StringConstantUPPER="ABCDEFGHJKLMNPQRSTUVWXYZ" -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstructor for SecurePasswordGenerator. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgeneratePassword.private static charrandomChar(String chars) randomChar.private static StringshuffleString(String input) shuffleString.
-
Field Details
-
RANDOM
ConstantRANDOM -
UPPER
ConstantUPPER="ABCDEFGHJKLMNPQRSTUVWXYZ"- See Also:
-
LOWER
ConstantLOWER="abcdefghijkmnopqrstuvwxyz"- See Also:
-
DIGIT
ConstantDIGIT="23456789"- See Also:
-
SPECIAL
ConstantSPECIAL="@%*-_=+!"- See Also:
-
ALL
ConstantALL="UPPER + LOWER + DIGIT + SPECIAL"- See Also:
-
RANDOM_CHAR_COUNT
private static final int RANDOM_CHAR_COUNTNumber of characters drawn fromALLonce each character class holds one: 15 characters in all, one more than the policy minimum, to make up for the smaller alphabet (about 90 bits of entropy).- See Also:
-
-
Constructor Details
-
SecurePasswordGenerator
private SecurePasswordGenerator()Constructor for SecurePasswordGenerator.
-
-
Method Details