public class PasswordUtil
extends java.lang.Object
PasswordUtil
class provides utility functions to encode and decode passwords.
This functionality is not new in WebSphere Applicaiton Server, but it is the first time
this function becomes available as WebSphere public programming interface.
InvalidPasswordDecodingException
,
InvalidPasswordEncodingException
,
UnsupportedCryptoAlgorithmException
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CRYPTO_ALGORITHM |
static java.lang.String |
STRING_CONVERSION_CODE |
static java.lang.Class |
thisClass |
Constructor and Description |
---|
PasswordUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decode(java.lang.String encoded_string)
This method decodes the specified encoded data.
|
static java.lang.String |
encode(java.lang.String decoded_string)
This method encodes the specified data using defaul encoding algorithm.
|
static java.lang.String |
encode(java.lang.String decoded_string,
java.lang.String crypto_algorithm)
This method encodes the specified data using the specified encoding algorithm.
|
static java.lang.String |
getCryptoAlgorithm(java.lang.String encoded_string)
This method extracts name of the encoding algorithm specified in the encoding algorithm tag in the ecoded data string.
|
static java.lang.String |
getCryptoAlgorithmTag(java.lang.String encoded_string)
This method extracts the encoding algorithm tag embedded in the ecoded data string.
|
static boolean |
isEncrypted(java.lang.String encoded_string)
This method returns true if the input string contains an encoded algorithm tag.
|
static boolean |
isValidCryptoAlgorithm(java.lang.String crypto_algorithm)
This method returns true if the specified encoded algorithm is a supported algorithm or
if the input String is null.
|
static boolean |
isValidCryptoAlgorithmTag(java.lang.String crypto_algorithm_tag)
This method returns true if input String represents a valid encoding algorithm tag or
if the input String is null.
|
static java.lang.String |
passwordDecode(java.lang.String encoded_string)
This method decodes the specified encoded data.
|
static java.lang.String |
passwordEncode(java.lang.String decoded_string)
This method encodes the specified data using default encoding algorithm.
|
static java.lang.String |
passwordEncode(java.lang.String decoded_string,
java.lang.String crypto_algorithm)
This method encodes the specified data using the specified encoding algorithm.
|
static java.lang.String |
removeCryptoAlgorithmTag(java.lang.String encoded_string)
This method removesw the encoding algorithm tag embedded in the input String.
|
public static final java.lang.String DEFAULT_CRYPTO_ALGORITHM
public static final java.lang.String STRING_CONVERSION_CODE
public static final java.lang.Class thisClass
public static final java.lang.String decode(java.lang.String encoded_string) throws InvalidPasswordDecodingException, UnsupportedCryptoAlgorithmException
This method decodes the specified encoded data.
encoded
- string A java.lang.String
object contains encoded datajava.lang.String
object that contains decoded data.InvalidPasswordDecodingException
- will be thrown if the input param is null, if the encoding algorithm tag is missing, or if the inputs data is
not a valid encoded string.UnsupportedCryptoAlgorithmException
- will be thrown if the encoding algorithm specified in the encoded data is not a supported algorithm.InvalidPasswordDecodingException
UnsupportedCryptoAlgorithmException
public static final java.lang.String encode(java.lang.String decoded_string) throws InvalidPasswordEncodingException, UnsupportedCryptoAlgorithmException
This method encodes the specified data using defaul encoding algorithm.
string
- A java.lang.String
object contains data to be encoded.java.lang.String
object that contains encoded data.InvalidPasswordEncodingException
- will be thrown if the input param is null or if the input data string contains an encoding algorithm tag.UnsupportedCryptoAlgorithmException
- will be thrown if the default encoding algorithm is not defined properly.InvalidPasswordEncodingException
UnsupportedCryptoAlgorithmException
public static final java.lang.String encode(java.lang.String decoded_string, java.lang.String crypto_algorithm) throws InvalidPasswordEncodingException, UnsupportedCryptoAlgorithmException
This method encodes the specified data using the specified encoding algorithm.
string
- A java.lang.String
object contains data to be encoded.java.lang.String
object that contains encoded data.InvalidPasswordEncodingException
- will be thrown if the input param is null or if the input data string contains an encoding algorithm tag.UnsupportedCryptoAlgorithmException
- will be thrown if the specified encoding algorithm is not supported by the implementation.InvalidPasswordEncodingException
UnsupportedCryptoAlgorithmException
public static final java.lang.String getCryptoAlgorithm(java.lang.String encoded_string)
This method extracts name of the encoding algorithm specified in the encoding algorithm tag in the ecoded data string.
string
- A java.lang.String
object contains encoded data.java.lang.String
object that contains the extracted encoding algorithm name.public static final java.lang.String getCryptoAlgorithmTag(java.lang.String encoded_string)
This method extracts the encoding algorithm tag embedded in the ecoded data string.
string
- A java.lang.String
object contains encoded data.java.lang.String
object that contains the extracted encoding algorithm tag.public static final boolean isEncrypted(java.lang.String encoded_string)
This method returns true if the input string contains an encoded algorithm tag.
string
- A java.lang.String
object contains encoded data.public static final boolean isValidCryptoAlgorithm(java.lang.String crypto_algorithm)
This method returns true if the specified encoded algorithm is a supported algorithm or if the input String is null.
string
- A java.lang.String
object contains name of an encoding algorithm.public static final boolean isValidCryptoAlgorithmTag(java.lang.String crypto_algorithm_tag)
This method returns true if input String represents a valid encoding algorithm tag or if the input String is null.
string
- A java.lang.String
object contains an encoding algorithm tag.public static final java.lang.String passwordDecode(java.lang.String encoded_string)
This method decodes the specified encoded data. This method returns the input String if it is not encoded.
encoded
- string A java.lang.String
object contains encoded datajava.lang.String
object that contains decoded data.public static final java.lang.String passwordEncode(java.lang.String decoded_string)
This method encodes the specified data using default encoding algorithm. If the input String is already encoded, this method first decodes it and then encodes it using the default encoding algorithm.
string
- A java.lang.String
object contains data to be encoded.java.lang.String
object that contains encoded data.public static final java.lang.String passwordEncode(java.lang.String decoded_string, java.lang.String crypto_algorithm)
This method encodes the specified data using the specified encoding algorithm. If the input String is already encoded, this method first decodes it and then encodes it using the specified encoding algorithm. This methodd returns a null String if the specified encoding algorithm is not a supported algorithm.
string
- A java.lang.String
object contains data to be encoded.java.lang.String
object that contains encoded data.public static final java.lang.String removeCryptoAlgorithmTag(java.lang.String encoded_string)
This method removesw the encoding algorithm tag embedded in the input String.
string
- A java.lang.String
object contains encoded data.java.lang.String
object that contains the encoded data with the encoding algorithm tag removed.