| Code: |
|
This WS-Security scenario adds username and password values to the message header. A password can be sent as plain text or in hashed form (depending on "passwordType" property). Client side configuration : protected void configureOutProperties(Properties config) { // Action to perform : user token config.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); // Password type : plain text config.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT); // for hashed password use: //properties.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST); // User name to send config.setProperty(WSHandlerConstants.USER, "serveralias"); // Callback used to retrive password for given user. config.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName()); } The PasswordHandler class is responsible for finding the password for given user name and must implement the org.apache.ws.security.WSPasswordCallback interface. You can also specify an existing handler instance, using the WSHandlerConstants.PW_CALLBACK_REF property on the client/service instance or MessageContext ( e.g. client.setProperty(new PasswordHandler())). The WSHandlerConstants.PASSWORD_TYPE property determines how the password will be sent. If it is set to WSConstants.PW_TEXT, the password will be sent as plain text. If the value is WSConstants.PW_DIGEST, a password digest will be sent. If no value is set, a digest is used by default.. |
| Quote: |
|
As i wrote before you have working example in /examples/ws-security sample application inside XFire distribution. |