|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.util.PasswordGenerator
public class PasswordGenerator
A utility class that can be used to generate secure random password values. Also contains methods to check the quality of a password.
Copyright 2005 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
private static char[] |
PASSWORD_CHARACTERS
The default characters that are allowed in a password value. |
private static SecureRandom |
random
The random number generator. |
| Constructor Summary | |
|---|---|
PasswordGenerator()
Default constructor. |
|
| Method Summary | |
|---|---|
protected int |
byteToInt(byte byteValue)
Convert a byte value into a postive integer. |
boolean |
checkComplex(char[] password)
Check the specified password value for quality. |
boolean |
checkSimple(char[] password)
Check the specified password value for quality using simple rules. |
char[] |
generate(int length)
Generate a random password of the specified length. |
char[] |
generate(int length,
char[] characters)
Generate a random password of the specified length and restricted to the characters specified. |
protected int |
getIntFromByte(byte[] bytes)
Convert a byte value returned by the random number generator ( random) to an integer that may be used to index into
the allowable characters array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final char[] PASSWORD_CHARACTERS
private static final SecureRandom random
| Constructor Detail |
|---|
public PasswordGenerator()
| Method Detail |
|---|
public char[] generate(int length)
length - The desired length of the password.
generate( int, char[] )
public char[] generate(int length,
char[] characters)
checkSimple(char[]) and to ensure that the generated value is good
enough.
Note: There is a possibility that this method can go into
an infinite loop. This can happen if the characters
array contains only those characters that make checkComplex(char[]) always return false.
length - The desired length of the password.characters - The array of valid characters thay may be used
in the password.
checkComplex(char[])public boolean checkSimple(char[] password)
password - The password that is to be checked.
true if the specified password
satisfies the requirements.checkComplex(char[])public boolean checkComplex(char[] password)
Note: There is no guarantee that the password generated
by the generate( int, char[] ) method will satisfy
these rules.
password - The password that is to be checked.
true if the specified password
satisfies the requirements.checkSimple(char[])protected int getIntFromByte(byte[] bytes)
random) to an integer that may be used to index into
the allowable characters array.
bytes - The byte values returned by the random number
generator.protected int byteToInt(byte byteValue)
byteValue - The byte that is to be converted into an integer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||