Package ise.antelope.tasks
Class PasswordHandler
- java.lang.Object
-
- ise.antelope.tasks.PasswordHandler
-
public class PasswordHandler extends java.lang.Object
Simple class to encode and decode passwords. The encrypted password is a base-64 encoded string, so it's suitable for storage in a properties file or where ever a string might be stored. This class could be used for larger strings than passwords, but all I need is an easy way to store passwords in a file.- Version:
- $Revision: 125 $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_KEY
key to use if none givenstatic java.lang.String
DESEDE
use Triple-DES as algorithm
-
Constructor Summary
Constructors Constructor Description PasswordHandler()
Constructor for PasswordHandler, uses default key.PasswordHandler(java.lang.String encryptKey)
Constructor for PasswordHandler
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
decrypt(java.lang.String encryptedPassword)
Decrypt a password.java.lang.String
encrypt(java.lang.String password)
Encrypt a password.static void
main(java.lang.String[] args)
for testing only
-
-
-
Field Detail
-
DESEDE
public static final java.lang.String DESEDE
use Triple-DES as algorithm- See Also:
- Constant Field Values
-
DEFAULT_KEY
public static final java.lang.String DEFAULT_KEY
key to use if none given- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PasswordHandler
public PasswordHandler() throws PasswordHandlerException
Constructor for PasswordHandler, uses default key.- Throws:
PasswordHandlerException
- Description of Exception
-
PasswordHandler
public PasswordHandler(java.lang.String encryptKey) throws PasswordHandlerException
Constructor for PasswordHandler- Parameters:
encryptKey
- String to use for a key, must be at least 32 characters long.- Throws:
PasswordHandlerException
- Description of Exception
-
-
Method Detail
-
encrypt
public java.lang.String encrypt(java.lang.String password) throws PasswordHandlerException
Encrypt a password.- Parameters:
password
- the password to encrypt- Returns:
- the encrypted password.
- Throws:
PasswordHandlerException
- Description of Exception
-
decrypt
public java.lang.String decrypt(java.lang.String encryptedPassword) throws PasswordHandlerException
Decrypt a password.- Parameters:
encryptedPassword
- the encrypted password, needing to be decrypted- Returns:
- the original, plain text password
- Throws:
PasswordHandlerException
- Description of Exception
-
main
public static void main(java.lang.String[] args)
for testing only- Parameters:
args
- The command line arguments
-
-