This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Services and the fly likes Dynamically setting the username/password with Rampart. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Dynamically setting the username/password with Rampart." Watch "Dynamically setting the username/password with Rampart." New topic
Author

Dynamically setting the username/password with Rampart.

Sanjay Vivek
Greenhorn

Joined: Jan 16, 2008
Posts: 8
Hi everyone,

I'm attempting to call a simple Web Service (an Echo Service) that is protected by WS-Security UsernameToken. I'm using Axis2-1.3 and Rampart 1.3. I've been looking at the samples given in the Apache Rampart distro and it makes sense to me. However, in the samples given in the Rampart distro, the username is hardcoded within the OuflowSecurity element in the client config file (client.axis2.xml) as shown below:

<parameter name="OuflowSecurity">t
<action>
<items>UsernameToken Timestamp</items>

<user>bob</user>

<passwordCallbackClass>
echo.PWHandlerClient
</passwordCallbackClass>
</action>
</parameter>


However, I want to set username/password dynamically, and I'm attempting to use the ServiceClient to do just this.

The following code snippet below shows how I've gone about using the ServiceClient to set the username and password:

ConfigurationContext ctx = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(axis2ConfPath, null);

ServiceClient client = new ServiceClient(ctx, null); OMElement payload = client.sendReceive(getPayload("Hello world"));

Options options = new Options();
client.engageModule(new QName("rampart"));

options.setTo(targetEPR);
options.setAction("urn:echo");

options.setUserName("bob");
options.setPassword("wspwd");

client.setOptions(options);
result = client.sendReceive(payload);

However, the client seems to be picking up the value within the <user> in the "OutflowSecurity" element which is defined in client.axis2.xml (from axis2ConfPath/conf). How do I override the "user" value in client.axis2.xml so that the client picks up the username from 'options.setUserName("bob")'? Any help would be appreciated. Cheers.

Regards
Sanjay
Dharmveer Jain
Greenhorn

Joined: May 28, 2009
Posts: 2
Hi,

Were you able to resolve this issue? If yes then what you did?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Dynamically setting the username/password with Rampart.
 
Similar Threads
rampart problem with oc4j
SOAP Header missing using Rampart w/ Axis2 Generated Stub
Axis2, client handler not getting called
Rampart encrypting options: I can't encrypt parameters
WSHandler: cannot create instance of password callback