Package org.apache.fulcrum.jce.crypto
Class PasswordFactory
- java.lang.Object
-
- org.apache.fulcrum.jce.crypto.PasswordFactory
-
- All Implemented Interfaces:
PasswordParameters
public class PasswordFactory extends Object implements PasswordParameters
The implementation supplies a default password in the case that the programmer don't want to have additional hassles. It is easy to reengineer the password being used but much better than a hard-coded password in the application. The code uses parts from Markus Hahn's Blowfish library found at http://blowfishj.sourceforge.net/- Author:
- Siegfried Goeschl , Markus Hahn
-
-
Field Summary
-
Fields inherited from interface org.apache.fulcrum.jce.crypto.PasswordParameters
COUNT
-
-
Constructor Summary
Constructors Constructor Description PasswordFactory(String algo)
PasswordFactory(String algo, int count)
-
Method Summary
Modifier and Type Method Description char[]
create()
Create a new passwordchar[]
create(char[] seed)
char[]
create(char[] password, byte[] salt, int count)
Creates a default password using "xxxx-xxxx-xxxx-xxxxx".char[]
create(String seed)
Create a new password using a seedstatic PasswordFactory
getInstance()
Factory method to get a default instancestatic PasswordFactory
getInstance(String algo)
Factory method to get a default instancestatic PasswordFactory
getInstance(String algo, int count)
Factory method to get a default instance
-
-
-
Method Detail
-
getInstance
public static PasswordFactory getInstance()
Factory method to get a default instance- Returns:
- an instance of the CryptoStreamFactory
-
getInstance
public static PasswordFactory getInstance(String algo)
Factory method to get a default instance- Parameters:
algo
- algorithm- Returns:
- an instance of the CryptoStreamFactory
-
getInstance
public static PasswordFactory getInstance(String algo, int count)
Factory method to get a default instance- Parameters:
algo
- algorithmcount
- the number of MessageDigest iterations- Returns:
- an instance of the CryptoStreamFactory
-
create
public char[] create() throws NoSuchAlgorithmException, UnsupportedEncodingException
Create a new password- Returns:
- a default password using "xxxx-xxxx-xxxx-xxxxx"
- Throws:
NoSuchAlgorithmException
- the encryption algorithm is not supportedUnsupportedEncodingException
- the requested encoding is not supported
-
create
public char[] create(String seed) throws NoSuchAlgorithmException, UnsupportedEncodingException
Create a new password using a seed- Parameters:
seed
- the default password supplied by the caller- Returns:
- a password using "xxxx-xxxx-xxxx-xxxxx"
- Throws:
NoSuchAlgorithmException
- the encryption algorithm is not supportedUnsupportedEncodingException
- the requested encoding is not supported
-
create
public final char[] create(char[] seed) throws NoSuchAlgorithmException, UnsupportedEncodingException
- Parameters:
seed
- the default password supplied by the caller- Returns:
- a password using "xxxx-xxxx-xxxx-xxxxx"
- Throws:
NoSuchAlgorithmException
- the encryption algorithm is not supportedUnsupportedEncodingException
- the requested encoding is not supported
-
create
public char[] create(char[] password, byte[] salt, int count) throws NoSuchAlgorithmException, UnsupportedEncodingException
Creates a default password using "xxxx-xxxx-xxxx-xxxxx".- Parameters:
salt
- the password saltpassword
- the default passwordcount
- number of MessageDigest iterations- Returns:
- the default password
- Throws:
NoSuchAlgorithmException
- the encryption algorithm is not supportedUnsupportedEncodingException
- the requested encoding is not supported
-
-