net.sf.jguard.authentication
Class CryptUtils

java.lang.Object
  extended by net.sf.jguard.authentication.CryptUtils

public class CryptUtils
extends java.lang.Object

this class is done originally by andy tagish, with his great jaas modules. you can reach it on his website the licence of the code provided by andy tagish is also the LGPL. this class is loaded by the application server classloader.

Author:
Andy Armstrong, andy@tagish.com, Charles Gay

Field Summary
static java.lang.String NONE_ALGORITHM
           
static char[] salt
           
 
Constructor Summary
CryptUtils()
           
 
Method Summary
static char[] cryptPassword(char[] pwd)
          Perform message digest hashing on the supplied password and return a char array containing the encrypted password as a printable string.
static java.lang.String getDigestAlgorithm()
           
static char[] getSalt()
           
static void setDigestAlgorithm(java.lang.String algorithm)
          set the message digest algorithm.
static boolean setSalt(char[] saltCandidate)
           
static void smudge(byte[] pwd)
          Zero the contents of the specified array.
static void smudge(char[] pwd)
          Zero the contents of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE_ALGORITHM

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

salt

public static char[] salt
Constructor Detail

CryptUtils

public CryptUtils()
Method Detail

smudge

public static void smudge(char[] pwd)
Zero the contents of the specified array. Typically used to erase temporary storage that has held plaintext passwords so that we don't leave them lying around in memory.

Parameters:
pwd - the array to zero

smudge

public static void smudge(byte[] pwd)
Zero the contents of the specified array.

Parameters:
pwd - the array to zero

cryptPassword

public static char[] cryptPassword(char[] pwd)
                            throws java.security.NoSuchAlgorithmException
Perform message digest hashing on the supplied password and return a char array containing the encrypted password as a printable string. The hash is computed on the low 8 bits of each character.

Parameters:
pwd - The password to encrypt
Returns:
a character array containing a 32 character long hex encoded MD5 hash of the password
Throws:
java.security.NoSuchAlgorithmException

getDigestAlgorithm

public static java.lang.String getDigestAlgorithm()
Returns:

setDigestAlgorithm

public static void setDigestAlgorithm(java.lang.String algorithm)
                               throws java.security.NoSuchAlgorithmException
set the message digest algorithm. before to set, we verify if the algorithm is available with the current jvm.

Parameters:
string -
Throws:
java.security.NoSuchAlgorithmException

setSalt

public static boolean setSalt(char[] saltCandidate)

getSalt

public static char[] getSalt()