Package org.apache.ws.security
Class WSPasswordCallback
java.lang.Object
org.apache.ws.security.WSPasswordCallback
- All Implemented Interfaces:
Callback
Simple class to provide a password callback mechanism.
It uses the JAAS authentication mechanisms and callback methods.
In addition to the identifier (user name) this class also provides
information what type of information the callback
handle
method shall provide.
The WSPasswordCallback
class defines the following usage
codes:
UNKNOWN
- an unknown usage. Never used by the WSS4J implementation and shall be treated as an error by thehandle
method.DECRYPT
- need a password to get the private key of this identifier (username) from the keystore. WSS4J uses this private key to decrypt the session (symmetric) key. Because the encryption method uses the public key to encrypt the session key it needs no password (a public key is usually not protected by a password).USERNAME_TOKEN
- need the password to fill in or to verify aUsernameToken
.SIGNATURE
- need the password to get the private key of this identifier (username) from the keystore. WSS4J uses this private key to produce a signature. The signature verfication uses the public key to verfiy the signature.KEY_NAME
- need the key, not the password, associated with the identifier. WSS4J uses this key to encrypt or decrypt parts of the SOAP request. Note, the key must match the symmetric encryption/decryption algorithm specified (refer toWSHandlerConstants.ENC_SYM_ALGO
).USERNAME_TOKEN_UNKNOWN
- either an not specified password type or a password type passwordText. In these both cases only the password variable is set. The callback class now may check if the username and password match. If they don't match the callback class must throw an exception. The exception can be a UnsupportedCallbackException or an IOException.SECURITY_CONTEXT_TOKEN
- need the key to to be associated with awsc:SecurityContextToken
.
- Author:
- Werner Dittmann (Werner.Dittmann@siemens.com).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionWSPasswordCallback
(String id, int usage) Constructor.WSPasswordCallback
(String id, String pw, String type, int usage) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the identifier.byte[]
getKey()
Get the key.Get the password.The password type is only relevant for usageUSERNAME_TOKEN
andUSERNAME_TOKEN_UNKNOWN
.int
getUsage()
Get the usage.void
setKey
(byte[] key) Set the Key.void
setPassword
(String passwd) Set the password.
-
Field Details
-
UNKNOWN
public static final int UNKNOWN- See Also:
-
DECRYPT
public static final int DECRYPT- See Also:
-
USERNAME_TOKEN
public static final int USERNAME_TOKEN- See Also:
-
SIGNATURE
public static final int SIGNATURE- See Also:
-
KEY_NAME
public static final int KEY_NAME- See Also:
-
USERNAME_TOKEN_UNKNOWN
public static final int USERNAME_TOKEN_UNKNOWN- See Also:
-
SECURITY_CONTEXT_TOKEN
public static final int SECURITY_CONTEXT_TOKEN- See Also:
-
-
Constructor Details
-
WSPasswordCallback
Constructor.- Parameters:
id
- The application called back must supply the password for this identifier.
-
WSPasswordCallback
Constructor.- Parameters:
id
- The application called back must supply the password for this identifier.
-
-
Method Details
-
getIdentifer
Get the identifier.- Returns:
- The identifier
-
setPassword
Set the password.- Parameters:
passwd
- is the password associated to the identifier
-
getPassword
Get the password.- Returns:
- The password
-
setKey
public void setKey(byte[] key) Set the Key.- Parameters:
key
- is the key associated to the identifier
-
getKey
public byte[] getKey()Get the key.- Returns:
- The key
-
getUsage
public int getUsage()Get the usage.- Returns:
- The usage for this callback
-
getPasswordType
The password type is only relevant for usageUSERNAME_TOKEN
andUSERNAME_TOKEN_UNKNOWN
.- Returns:
- Returns the passwordType.
-