Package org.apache.wss4j.common.util
Class UsernameTokenUtil
- java.lang.Object
-
- org.apache.wss4j.common.util.UsernameTokenUtil
-
public final class UsernameTokenUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ITERATION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdoPasswordDigest(byte[] nonce, String created, byte[] password)static StringdoPasswordDigest(byte[] nonce, String created, String password)static byte[]doRawPasswordDigest(byte[] nonce, String created, byte[] password)static byte[]generateDerivedKey(byte[] password, byte[] salt, int iteration)This static method generates a derived key as defined in WSS Username Token Profile.static byte[]generateDerivedKey(String password, byte[] salt, int iteration)This static method generates a derived key as defined in WSS Username Token Profile.static byte[]generateNonce(int length)Generate a nonce of the given length using a secure random algorithm.static byte[]generateSalt(boolean useForMac)This static method generates a 128 bit salt value as defined in WSS Username Token Profile.static StringgetRawPassword(CallbackHandler callbackHandler, String username, String password, String passwordType)Get the raw (plain text) password used to compute secret key.
-
-
-
Field Detail
-
DEFAULT_ITERATION
public static final int DEFAULT_ITERATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateDerivedKey
public static byte[] generateDerivedKey(byte[] password, byte[] salt, int iteration) throws WSSecurityExceptionThis static method generates a derived key as defined in WSS Username Token Profile.- Parameters:
password- The password to include in the key generationsalt- The Salt valueiteration- The Iteration value. If zero (0) is given the method uses the default value- Returns:
- Returns the derived key a byte array
- Throws:
WSSecurityException
-
generateDerivedKey
public static byte[] generateDerivedKey(String password, byte[] salt, int iteration) throws WSSecurityException
This static method generates a derived key as defined in WSS Username Token Profile.- Parameters:
password- The password to include in the key generationsalt- The Salt valueiteration- The Iteration value. If zero (0) is given the method uses the default value- Returns:
- Returns the derived key a byte array
- Throws:
WSSecurityException
-
generateSalt
public static byte[] generateSalt(boolean useForMac)
This static method generates a 128 bit salt value as defined in WSS Username Token Profile.- Parameters:
useForMac- Iftruedefine the Salt for use in a MAC- Returns:
- Returns the 128 bit salt value as byte array
-
generateNonce
public static byte[] generateNonce(int length) throws WSSecurityExceptionGenerate a nonce of the given length using a secure random algorithm. The SecureRandom instance that backs this method is cached for efficiency.- Returns:
- a nonce of the given length
- Throws:
WSSecurityException
-
doPasswordDigest
public static String doPasswordDigest(byte[] nonce, String created, String password) throws WSSecurityException
- Throws:
WSSecurityException
-
doPasswordDigest
public static String doPasswordDigest(byte[] nonce, String created, byte[] password) throws WSSecurityException
- Throws:
WSSecurityException
-
doRawPasswordDigest
public static byte[] doRawPasswordDigest(byte[] nonce, String created, byte[] password) throws WSSecurityException- Throws:
WSSecurityException
-
getRawPassword
public static String getRawPassword(CallbackHandler callbackHandler, String username, String password, String passwordType) throws WSSecurityException
Get the raw (plain text) password used to compute secret key.- Throws:
WSSecurityException
-
-