Specify a User Through Configuration File
By default, as a PPM server the PPM Web service toolkit enables UsernameToken, Timestamp, and Encrypt.
Set Headers
In the client-axis2.xml file, the following "OutflowSecurity" section defines how WS-Security headers are set on an outgoing SOAP message generated by the toolkit.
<module ref="rampart" />
<parameter name="OutflowSecurity">
<action>
<items>UsernameToken Encrypt Timestamp</items>
<user>admin</user>
<passwordCallbackClass>examples.security.PasswordCallbackHandler
</passwordCallbackClass>
<passwordType>PasswordText
</passwordType>
<encryptionParts>{Element}{http://docs.oasis-open.org/
wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd}UsernameToken</encryptionParts>
<encryptionUser>ppmservice</encryptionUser>
<encryptionPropFile>client.properties
</encryptionPropFile>
</action>
</parameter>
To specify a fixed user name for the web service call, simply change the value of the <user> element in the client-axis2.xml file.
Set Password
To set the password for this particular user, following these steps:
-
Open
<webservice_toolkit>/java/ client/src/examples/security/PasswordCallbackHandler.java -
Change the default password "admin" to the desired password.
Example:
public class PasswordCallbackHandler implements CallbackHandler
{
String username = null;
public void handle(Callback[] callbacks) throws
IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback callback =
(WSPasswordCallback)callbacks[i];
// obtain password. This can be customized to obtain
// password from any desire source and apply any
// necessary algorithm.
//
// if your logic requires the username, you can get
the
// user name by:
// String username = callback.getIdentifier();
//
String password = "admin";
// set the obtained password
callback.setPassword(password);
}
}
}
Specify User
The following code describes how to specify the user through a configuration file.
String repositoryPath =
System.getProperty("client.repository.dir");
String axis2 = repositoryPath + "/conf/clientaxis2.
xml";
File file = new File(axis2);
if (file.exists()) {
try {
ctx = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(
repositoryPath, axis2);
} catch (Exception e) {
e.printStackTrace();
}
}

