Hi Shaan,
This is the widely used approach of attaching a security policy to a client.
StAXOMBuilder builder = new
StAXOMBuilder("/path/to/policy");
Policy policy
= PolicyEngine.getPolicy(builder.getDocumentElement());
RampartConfig rc = new RampartConfig();
// set the parameters to rampart config.
policy.addAssertion(rc);
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy(policy));
HTH.
Thanks.
/thilina
Thilina Mahesh Buddhika
http://blog.thilinamb.com
On Tue, Dec 8, 2009 at 4:07 PM, Shaan Jayaratna <[email protected]>wrote:
> Hi.
>
> I want to use WSSPolicy with Axis2 1.5.1 and Rampart 1.4. Deploying the
> service with an attached Policy works fine. Creating the stubs with
> WSDL2Java don't cause an error. But when I send a request there are no
> WSSHeaders generated.
>
> Rampart is engaged. Using the OutflowSecurity parameter WSS works on the
> client side.
>
> Without the OutflowSecurity parameter I use the RampartConfig class to
> configure the client:
>
> RampartConfig rampartConfig = new RampartConfig();
> rampartConfig.setUser("client");
> rampartConfig.setPwCbClass("PWDCallback");
> CryptoConfig sigCrypto = new CryptoConfig();
> sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
> Properties props = new Properties();
> props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type",
> "JKS");
>
> props.setProperty("org.apache.ws.security.crypto.merlin.file","client.jks");
> props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password",
> "apache");
> sigCrypto.setProp(props);
> rampartConfig.setSigCryptoConfig(sigCrypto);
> Policy policy = new Policy();
> policy.addAssertion(rampartConfig);
>
> stub._getServiceClient().getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,
> policy);
>
> Thanks,
> Shaan
>
>