Hi,

Since you have used the configuration parameters username/password will
not be picked up from the options object. Username/password will be
given priority if you are using policy based configuration only.

This is how you set username/password dynamically if you are using
configuration parameter approach.

OutflowConfiguration ofc = new OutflowConfiguration();
ofc.setActionItems("UsernameToken");
options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY,
ofc.getProperty());

myCallback.setUTUsername("bob");
myCallback.setUTPassword("bobpass");
options.put(WSHandlerConstants.PW_CALLBACK_REF, myCallback);

/*
myCallback is an instance of a class extending from
org.apache.ws.security.WSPasswordCallback.
You should implement it.
*/

Then remove the password callback class given in the client.axis2.xml
because there Rampart doesn't give priority to PW_CALLBAK_REF. 

Thanks,
Dimuthu.



On Wed, 2008-01-16 at 11:36 +0000, Sanjay Vivek wrote:
> 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="OutflowSecurity">
>       <action>
>               <items>UsernameToken Timestamp</items>
>               <user>bob</user>
>  
> <passwordCallbackClass>org.apache.rampart.samples.sample02.PWCBHandler</
> passwordCallbackClass>
>       </action>
>     </parameter>
> 
> 
> However, I want to set username/password dynamically, and I'm attempting
> to use the ServiceClient to do just this.
> 
> The 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>
> element 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 Vivek
> Web Analyst
> Middleware Team
> ISS
> University of Newcastle Upon Tyne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to