com.ibm.websphere.crypto
Class PasswordUtil

java.lang.Object
  extended by com.ibm.websphere.crypto.PasswordUtil

public class PasswordUtil
extends java.lang.Object

Password related utilities.


Field Summary
static java.lang.String PROPERTY_CRYPTO_KEY
           
static java.lang.String PROPERTY_HASH_ALGORITHM
           
static java.lang.String PROPERTY_HASH_ENCODED
           
static java.lang.String PROPERTY_HASH_ITERATION
           
static java.lang.String PROPERTY_HASH_LENGTH
           
static java.lang.String PROPERTY_HASH_SALT
           
 
Constructor Summary
PasswordUtil()
           
 
Method Summary
static java.lang.String decode(java.lang.String encoded_string)
          Decode the provided password.
static java.lang.String encode_password(java.lang.String decoded_string, java.lang.String crypto_algorithm, java.util.Map<java.lang.String,java.lang.String> properties)
          Encode the raw input with the provided algorithm.
static java.lang.String encode(java.lang.String decoded_string)
          Encode the provided password.
static java.lang.String encode(java.lang.String decoded_string, java.lang.String crypto_algorithm)
          Encode the provided password with the input algorithm.
static java.lang.String encode(java.lang.String decoded_string, java.lang.String crypto_algorithm, java.util.Map<java.lang.String,java.lang.String> properties)
           
static java.lang.String encode(java.lang.String decoded_string, java.lang.String crypto_algorithm, java.lang.String crypto_key)
          Encode the provided password with the input algorithm.
static java.lang.String getCryptoAlgorithm(java.lang.String password)
          Determine the crypto algorithm inside the provided password, ie {xor}blah returns "xor".
static java.lang.String getCryptoAlgorithmTag(java.lang.String password)
          Get any algorithm tag found in the input data.
static java.lang.String getDefaultEncoding()
           
static boolean isEncrypted(java.lang.String encoded_string)
          Check whether the password has a valid crypto algorithm applied.
static boolean isHashed(java.lang.String encodedString)
          Determine if the provided algorithm tag is a valid supported one or not.
static boolean isValidCryptoAlgorithm(java.lang.String crypto_algorithm)
          Determine if the provided algorithm string is a valid one.
static boolean isValidCryptoAlgorithmTag(java.lang.String tag)
          Determine if the provided algorithm tag is a valid supported one or not.
static java.lang.String passwordDecode(java.lang.String encoded_string)
          Decode the provided password string.
static java.lang.String passwordEncode(java.lang.String decoded_string)
          Encode the provided password with the default algorithm.
static java.lang.String passwordEncode(java.lang.String decoded_string, java.lang.String crypto_algorithm)
          Encode the provided password with the input algorithm.
static java.lang.String removeCryptoAlgorithmTag(java.lang.String password)
          Remove the algorithm tag from the input encoded password.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_CRYPTO_KEY

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

PROPERTY_HASH_ALGORITHM

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

PROPERTY_HASH_ITERATION

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

PROPERTY_HASH_SALT

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

PROPERTY_HASH_ENCODED

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

PROPERTY_HASH_LENGTH

public static final java.lang.String PROPERTY_HASH_LENGTH
See Also:
Constant Field Values
Constructor Detail

PasswordUtil

public PasswordUtil()
Method Detail

getDefaultEncoding

public static final java.lang.String getDefaultEncoding()

decode

public static java.lang.String decode(java.lang.String encoded_string)
                               throws InvalidPasswordDecodingException,
                                      com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
Decode the provided password. An empty algorithm "{}" is treated as a no-op; however, a missing algorithm will trigger the InvalidPasswordDecodingException.

Parameters:
encoded_string -
Returns:
String
Throws:
InvalidPasswordDecodingException
com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException

encode

public static java.lang.String encode(java.lang.String decoded_string)
                               throws InvalidPasswordEncodingException,
                                      com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
Encode the provided password.

Parameters:
decoded_string -
Returns:
String
Throws:
InvalidPasswordEncodingException
com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException

encode

public static java.lang.String encode(java.lang.String decoded_string,
                                      java.lang.String crypto_algorithm)
                               throws InvalidPasswordEncodingException,
                                      com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
Encode the provided password with the input algorithm.

Parameters:
decoded_string -
crypto_algorithm -
Returns:
Throws:
com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
InvalidPasswordEncodingException

encode

public static java.lang.String encode(java.lang.String decoded_string,
                                      java.lang.String crypto_algorithm,
                                      java.lang.String crypto_key)
                               throws InvalidPasswordEncodingException,
                                      com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
Encode the provided password with the input algorithm.

Parameters:
decoded_string -
crypto_algorithm -
crypto_key -
Returns:
Throws:
InvalidPasswordEncodingException
com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException

encode

public static java.lang.String encode(java.lang.String decoded_string,
                                      java.lang.String crypto_algorithm,
                                      java.util.Map<java.lang.String,java.lang.String> properties)
                               throws InvalidPasswordEncodingException,
                                      com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException
Throws:
InvalidPasswordEncodingException
com.ibm.ws.crypto.util.UnsupportedCryptoAlgorithmException

getCryptoAlgorithm

public static java.lang.String getCryptoAlgorithm(java.lang.String password)
Determine the crypto algorithm inside the provided password, ie {xor}blah returns "xor".

Parameters:
password -
Returns:
String - null if not present

getCryptoAlgorithmTag

public static java.lang.String getCryptoAlgorithmTag(java.lang.String password)
Get any algorithm tag found in the input data. "{xor}blah" returns "{xor}". This returns null if no algorithm is found.

Parameters:
password -
Returns:
String

isEncrypted

public static boolean isEncrypted(java.lang.String encoded_string)
Check whether the password has a valid crypto algorithm applied. "{xor}blah" would return true while "blah" would not.

Parameters:
encoded_string -
Returns:
boolean

isValidCryptoAlgorithm

public static boolean isValidCryptoAlgorithm(java.lang.String crypto_algorithm)
Determine if the provided algorithm string is a valid one.

Parameters:
crypto_algorithm -
Returns:
boolean

isValidCryptoAlgorithmTag

public static boolean isValidCryptoAlgorithmTag(java.lang.String tag)
Determine if the provided algorithm tag is a valid supported one or not.

Parameters:
tag -
Returns:
boolean

isHashed

public static boolean isHashed(java.lang.String encodedString)
Determine if the provided algorithm tag is a valid supported one or not.

Parameters:
tag -
Returns:
boolean

passwordDecode

public static java.lang.String passwordDecode(java.lang.String encoded_string)
Decode the provided password string.

Parameters:
encoded_string -
Returns:
String

passwordEncode

public static java.lang.String passwordEncode(java.lang.String decoded_string)
Encode the provided password with the default algorithm.

Parameters:
decoded_string -
Returns:
String

passwordEncode

public static java.lang.String passwordEncode(java.lang.String decoded_string,
                                              java.lang.String crypto_algorithm)
Encode the provided password with the input algorithm. If another algorithm is already applied, it will be removed and replaced with the new one.

Parameters:
decoded_string -
crypto_algorithm -
Returns:
String

removeCryptoAlgorithmTag

public static java.lang.String removeCryptoAlgorithmTag(java.lang.String password)
Remove the algorithm tag from the input encoded password.

Parameters:
password -
Returns:
String

encode_password

public static java.lang.String encode_password(java.lang.String decoded_string,
                                               java.lang.String crypto_algorithm,
                                               java.util.Map<java.lang.String,java.lang.String> properties)
Encode the raw input with the provided algorithm.

Parameters:
decoded_string -
crypto_algorithm -
crypto_key -
Returns:
String