de.intarsys.tools.authenticate
Class PasswordTools

java.lang.Object
  extended by de.intarsys.tools.authenticate.PasswordTools

public class PasswordTools
extends java.lang.Object

A tool class for handling passwords and authentication


Constructor Summary
PasswordTools()
           
 
Method Summary
static char[] createRandom(int length)
          Create a random password of length length.
static byte[] decrypt(byte[] bytes)
          Decrypt a byte array which was previously encrypted using encrypt.
static char[] decrypt(java.lang.String value)
          Decrypt a string which was previously encrypted using encrypt.
static byte[] encrypt(byte[] bytes)
          Encrypt a clear text array of bytes.
static java.lang.String encrypt(char[] value)
          Encrypt a clear text array of chars.
static java.lang.String hash(char[] password)
          A one way hash for a clear text password.
static void initialize(byte[] salt, char[] passphrase)
          Initialize the PasswordTools.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordTools

public PasswordTools()
Method Detail

createRandom

public static char[] createRandom(int length)
Create a random password of length length.

Parameters:
length -
Returns:
A new random password.

decrypt

public static byte[] decrypt(byte[] bytes)
Decrypt a byte array which was previously encrypted using encrypt. Provided the same salt and passphrase are used for initialization, this method returns the original unencrypted input.

Parameters:
bytes -
Returns:
The decrypted representation of bytes

decrypt

public static char[] decrypt(java.lang.String value)
Decrypt a string which was previously encrypted using encrypt. Provided the same salt and passphrase are used for initialization, this method returns the original unencrypted input.

Parameters:
value -
Returns:
The decrypted representation of value

encrypt

public static byte[] encrypt(byte[] bytes)
Encrypt a clear text array of bytes. The result is the plain encrypted byte array.

Parameters:
bytes -
Returns:
The encrpyted representation of bytes

encrypt

public static java.lang.String encrypt(char[] value)
Encrypt a clear text array of chars. The result is a Base64 encoded string version of the encrypted UTF-8 encoded input bytes.

Parameters:
value -
Returns:
An encrypted, invertible representation of value

hash

public static java.lang.String hash(char[] password)
A one way hash for a clear text password.

Parameters:
password -
Returns:
A one way hash for a clear text password.

initialize

public static void initialize(byte[] salt,
                              char[] passphrase)
Initialize the PasswordTools.

Parameters:
salt -
passphrase -