org.opengts.db
Class GeneralPasswordHandler

java.lang.Object
  extended by org.opengts.db.GeneralPasswordHandler
All Implemented Interfaces:
PasswordHandler

public class GeneralPasswordHandler
extends java.lang.Object
implements PasswordHandler


Nested Class Summary
static class GeneralPasswordHandler.PasswordEncodingException
           
 
Field Summary
static java.lang.String[] ARG_ENCODING
           
static java.lang.String[] ARG_MINALPHA
           
static java.lang.String[] ARG_MINDIGIT
           
static java.lang.String[] ARG_MINLEN
           
static java.lang.String[] ARG_MINLOWER
           
static java.lang.String[] ARG_MINSPEC
           
static java.lang.String[] ARG_MINUPPER
           
static java.lang.String[] ARG_PASSWORD
           
static java.lang.String[] ARG_TBLPASS
           
static java.lang.String ENC_MD5
           
static java.lang.String ENC_MD5PLAIN
           
static java.lang.String ENC_PLAIN
           
static java.lang.String ENC_PLAINMD5
           
static int MD5_HASH_LEN
           
static java.lang.String PROP_debugCheckPassword
           
static java.lang.String PROP_maximumPasswordAgeSeconds
           
static java.lang.String PROP_minimumAlphaChars
           
static java.lang.String PROP_minimumCategories
           
static java.lang.String PROP_minimumDigitChars
           
static java.lang.String PROP_minimumLowerAlphaChars
           
static java.lang.String PROP_minimumNonAlphaChars
           
static java.lang.String PROP_minimumPasswordLength
           
static java.lang.String PROP_minimumSpecialChars
           
static java.lang.String PROP_minimumUpperAlphaChars
           
static java.lang.String PROP_passwordEncoding
           
static java.lang.String PROP_passwordFormatDescription
           
static java.lang.String PROP_specialCharacters
           
 
Constructor Summary
GeneralPasswordHandler()
          Default Constructor
GeneralPasswordHandler(RTProperties rtp)
          Constructor
GeneralPasswordHandler(java.lang.String name, RTProperties rtp)
          Constructor
 
Method Summary
 boolean checkHash()
          Returns true if encoding if "md5" should be checked
 boolean checkPassword(java.lang.String enteredPass, java.lang.String tablePass)
          Check entered password against stored password
 boolean checkPlain()
          Returns true if plain-text password should be checked
 java.lang.String decodePassword(java.lang.String pass)
          Decode password
 java.lang.String encodePassword(java.lang.String pass)
          Encode password
protected  boolean getBoolean(java.lang.String key, boolean dft)
          Returns the value of the Long property key
 boolean getDebugCheckPassword()
          Gets debug logging for "checkPassword"
 java.lang.String getEncoding()
          Returns the encoding used for this PasswordHandler
 java.lang.String getEncodingString()
          Returns the encoding as a displayable string (this differs from "getEncoding()" in that if the encoding was originally "md5plain", then the returned string will be "md5plain" - where "getEncoding()" would just return "md5")
protected  int getInt(java.lang.String key, int dft)
          Returns the value of the Long property key
protected  long getLong(java.lang.String key, long dft)
          Returns the value of the Long property key
 java.lang.String getName()
          Gets the name of this PasswordHandler
 java.lang.String getPasswordFormatDescription(java.util.Locale locale)
          Returns a text description of the valid characters alowed for a password
protected  java.lang.Object getProperty(java.lang.String key, java.lang.Object dft)
          Returns the value of the Object property key
protected  java.lang.String getString(java.lang.String key, java.lang.String dft)
          Returns the value of the String property key
 boolean hasPasswordExpired(long lastChangedTime)
          Returns true if the password has passed its expiration date
protected  boolean hasProperty(java.lang.String key)
          Returns true if the property is defined
static void main(java.lang.String[] argv)
           
 void setDebugCheckPassword(boolean debugLog)
          Sets debug logging for "checkPassword"
 java.lang.String toString()
          Return String representation of this instance
 boolean validateNewPassword(java.lang.String newPass)
          Checks new password and returns true if the password passes the policy for newly created password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_debugCheckPassword

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

PROP_passwordEncoding

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

PROP_minimumPasswordLength

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

PROP_maximumPasswordAgeSeconds

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

PROP_specialCharacters

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

PROP_minimumLowerAlphaChars

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

PROP_minimumUpperAlphaChars

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

PROP_minimumAlphaChars

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

PROP_minimumDigitChars

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

PROP_minimumSpecialChars

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

PROP_minimumNonAlphaChars

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

PROP_minimumCategories

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

PROP_passwordFormatDescription

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

MD5_HASH_LEN

public static final int MD5_HASH_LEN
See Also:
Constant Field Values

ENC_MD5

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

ENC_PLAIN

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

ENC_MD5PLAIN

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

ENC_PLAINMD5

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

ARG_PASSWORD

public static final java.lang.String[] ARG_PASSWORD

ARG_ENCODING

public static final java.lang.String[] ARG_ENCODING

ARG_MINLEN

public static final java.lang.String[] ARG_MINLEN

ARG_MINLOWER

public static final java.lang.String[] ARG_MINLOWER

ARG_MINUPPER

public static final java.lang.String[] ARG_MINUPPER

ARG_MINALPHA

public static final java.lang.String[] ARG_MINALPHA

ARG_MINDIGIT

public static final java.lang.String[] ARG_MINDIGIT

ARG_MINSPEC

public static final java.lang.String[] ARG_MINSPEC

ARG_TBLPASS

public static final java.lang.String[] ARG_TBLPASS
Constructor Detail

GeneralPasswordHandler

public GeneralPasswordHandler()
                       throws GeneralPasswordHandler.PasswordEncodingException
Default Constructor

Throws:
GeneralPasswordHandler.PasswordEncodingException

GeneralPasswordHandler

public GeneralPasswordHandler(RTProperties rtp)
                       throws GeneralPasswordHandler.PasswordEncodingException
Constructor

Parameters:
rtp - The property settings for this instance
Throws:
GeneralPasswordHandler.PasswordEncodingException

GeneralPasswordHandler

public GeneralPasswordHandler(java.lang.String name,
                              RTProperties rtp)
                       throws GeneralPasswordHandler.PasswordEncodingException
Constructor

Parameters:
name - This password handler name
rtp - The property settings for this instance
Throws:
GeneralPasswordHandler.PasswordEncodingException
Method Detail

getName

public java.lang.String getName()
Gets the name of this PasswordHandler

Specified by:
getName in interface PasswordHandler
Returns:
The name of this PasswordHandler

getEncoding

public java.lang.String getEncoding()
Returns the encoding used for this PasswordHandler


getEncodingString

public java.lang.String getEncodingString()
Returns the encoding as a displayable string (this differs from "getEncoding()" in that if the encoding was originally "md5plain", then the returned string will be "md5plain" - where "getEncoding()" would just return "md5")


checkPlain

public boolean checkPlain()
Returns true if plain-text password should be checked

Returns:
True if plain-text passwords should be checked

checkHash

public boolean checkHash()
Returns true if encoding if "md5" should be checked

Returns:
True if "md5" passwords should be checked

getProperty

protected java.lang.Object getProperty(java.lang.String key,
                                       java.lang.Object dft)
Returns the value of the Object property key


hasProperty

protected boolean hasProperty(java.lang.String key)
Returns true if the property is defined

Parameters:
key - The property to check

getString

protected java.lang.String getString(java.lang.String key,
                                     java.lang.String dft)
Returns the value of the String property key


getLong

protected long getLong(java.lang.String key,
                       long dft)
Returns the value of the Long property key


getInt

protected int getInt(java.lang.String key,
                     int dft)
Returns the value of the Long property key


getBoolean

protected boolean getBoolean(java.lang.String key,
                             boolean dft)
Returns the value of the Long property key


encodePassword

public java.lang.String encodePassword(java.lang.String pass)
Encode password

Specified by:
encodePassword in interface PasswordHandler
Parameters:
pass - The password to encode
Returns:
The encoded password

decodePassword

public java.lang.String decodePassword(java.lang.String pass)
Decode password

Specified by:
decodePassword in interface PasswordHandler
Parameters:
pass - The password to decode
Returns:
The decoded password, or null if the password cannot be decoded

setDebugCheckPassword

public void setDebugCheckPassword(boolean debugLog)
Sets debug logging for "checkPassword"

Parameters:
debugLog - True to enable debug logging, false to disable

getDebugCheckPassword

public boolean getDebugCheckPassword()
Gets debug logging for "checkPassword"

Returns:
True if "checkPassword" debug logging enabled, false otherwise

checkPassword

public boolean checkPassword(java.lang.String enteredPass,
                             java.lang.String tablePass)
Check entered password against stored password

Specified by:
checkPassword in interface PasswordHandler
Parameters:
enteredPass - The User entered password
tablePass - The password value from the Account/User table
Returns:
True if the passwords match

validateNewPassword

public boolean validateNewPassword(java.lang.String newPass)
Checks new password and returns true if the password passes the policy for newly created password.

Specified by:
validateNewPassword in interface PasswordHandler
Parameters:
newPass - The password to validate as acceptable
Returns:
True if the specified password is acceptable

getPasswordFormatDescription

public java.lang.String getPasswordFormatDescription(java.util.Locale locale)
Returns a text description of the valid characters alowed for a password

Specified by:
getPasswordFormatDescription in interface PasswordHandler
Parameters:
locale - The locale
Returns:
The text description of the password format requirements

hasPasswordExpired

public boolean hasPasswordExpired(long lastChangedTime)
Returns true if the password has passed its expiration date

Specified by:
hasPasswordExpired in interface PasswordHandler
Parameters:
lastChangedTime - The Epoch timestamp when the password was last changed
Returns:
True is the password has passed its expiration date

toString

public java.lang.String toString()
Return String representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
String representation of this instance

main

public static void main(java.lang.String[] argv)