com.unearthedjava.passwordPress
Class UnearthedPassword

java.lang.Object
  extended bycom.unearthedjava.passwordPress.UnearthedPassword

public class UnearthedPassword
extends java.lang.Object

Author:
Lary Bullock

UnearthedPassword can be integrated into other applications. Note: This will throw an exception if you do not follow the rules which match the program (only 1 type (between numeric, alphabetic, and alphanumeric), required length does not exceed maximum possible based on the options selected, etc.).


Field Summary
static java.lang.String IS_ALPHA
           
static java.lang.String IS_ALPHANUM
           
static java.lang.String IS_NUMERIC
           
 
Constructor Summary
UnearthedPassword()
          base constructor
UnearthedPassword(int passwordLength, boolean allowDups, boolean mixCase, java.lang.String type)
          constructor for using class as a factory for other applications. uses the following parameters:
int passwordLength requested length of the password.
 
Method Summary
 int getMaxLength()
          calculate the max length that a password can be.
 java.lang.String getNewPassword()
          randomly builds a new password string for the user.
 int getPasswordLength()
           
 boolean isAllowDups()
           
 boolean isAlpha()
           
 boolean isAlphanum()
           
 boolean isMixCase()
           
 boolean isNumeric()
           
 void setAllowDups(boolean allowDups)
           
 void setAlpha(boolean isAlpha)
           
 void setAlphanum(boolean isAlphanum)
           
 void setMixCase(boolean mixCase)
           
 void setNumeric(boolean isNumeric)
           
 void setPasswordLength(int passwordLength)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IS_NUMERIC

public static final java.lang.String IS_NUMERIC
See Also:
Constant Field Values

IS_ALPHA

public static final java.lang.String IS_ALPHA
See Also:
Constant Field Values

IS_ALPHANUM

public static final java.lang.String IS_ALPHANUM
See Also:
Constant Field Values
Constructor Detail

UnearthedPassword

public UnearthedPassword()
base constructor


UnearthedPassword

public UnearthedPassword(int passwordLength,
                         boolean allowDups,
                         boolean mixCase,
                         java.lang.String type)
                  throws java.lang.Exception
constructor for using class as a factory for other applications. uses the following parameters:
int passwordLength
requested length of the password.
boolean allowDups
true allows characters to be repeated in the results
mixCase
if alpha or alphanumeric, allows mixing of letter case if true.
type
isNumeric - numeric only
isAlpha - alpha character passwords only.
isAplhanum - for passwords containing both numeric and character data

Example of use:

 try {
 	PasswordPress test = new UnearthedPassword(10, // length required
 			false, // allow duplicate characters
 			false, // mix letter case
 			PasswordPress.IS_ALPHANUM); // alphanumeric
 	String password = test.getNewPassword();
 	System.out.println(password);
 } catch (Exception e) {
 	System.out.println(e.getMessage());
 }
 

Method Detail

getMaxLength

public int getMaxLength()
calculate the max length that a password can be.


getNewPassword

public java.lang.String getNewPassword()
randomly builds a new password string for the user.


isAllowDups

public boolean isAllowDups()
Returns:
Returns the allowDups.

setAllowDups

public void setAllowDups(boolean allowDups)
Parameters:
allowDups - The allowDups to set.

isAlpha

public boolean isAlpha()
Returns:
Returns the isAlpha.

setAlpha

public void setAlpha(boolean isAlpha)
Parameters:
isAlpha - The isAlpha to set.

isAlphanum

public boolean isAlphanum()
Returns:
Returns the isAlphanum.

setAlphanum

public void setAlphanum(boolean isAlphanum)
Parameters:
isAlphanum - The isAlphanum to set.

isNumeric

public boolean isNumeric()
Returns:
Returns the isNumeric.

setNumeric

public void setNumeric(boolean isNumeric)
Parameters:
isNumeric - The isNumeric to set.

isMixCase

public boolean isMixCase()
Returns:
Returns the mixCase.

setMixCase

public void setMixCase(boolean mixCase)
Parameters:
mixCase - The mixCase to set.

getPasswordLength

public int getPasswordLength()
Returns:
Returns the passwordLength.

setPasswordLength

public void setPasswordLength(int passwordLength)
Parameters:
passwordLength - The passwordLength to set.