Saturday 15 May 2010

java - webservice encryption not working (jbossws-cxf) -



java - webservice encryption not working (jbossws-cxf) -

i trying ws-security encryption working on wildfly. read doc: https://docs.jboss.org/author/display/wfly8/ws-security.

i want soap messages travel encrypted client server , vice-versa.

i followed steps server , client message not encrypted , server not complaint de unencrypted message receives.

the unique difference doc illustration not utilize wsdl contract enforcing(our wsdl not include info encryption).

webservice server , client both works encryption not configured.

1) webservice implementation

@webservice(servicename = "imdservice", portname="imdserviceport", targetnamespace="http://ws.prueba.com") @soapbinding(style = soapbinding.style.rpc) @remote(imdservice.class) @stateless @endpointconfig(configfile = "web-inf/jaxws-endpoint-config.xml", configname = "custom ws-security endpoint") public class imdserviceimpl implements imdservice { ... }

2) file jaxws-endpoint-config.xml:

<?xml version="1.0" encoding="utf-8"?> <jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd"> <endpoint-config> <config-name>custom ws-security endpoint</config-name> <property> <property-name>ws-security.signature.properties</property-name> <property-value>bob.properties</property-value> </property> <property> <property-name>ws-security.encryption.properties</property-name> <property-value>bob.properties</property-value> </property> <property> <property-name>ws-security.signature.username</property-name> <property-value>bob</property-value> </property> <property> <property-name>ws-security.encryption.username</property-name> <property-value>alice</property-value> </property> <property> <property-name>ws-security.callback-handler</property-name> <property-value>ar.com.condortech.business.keystorepasswordcallback</property-value> </property> </endpoint-config> </jaxws-config>

3) here have bob.properties , alice.properties files content:

alice.properties ================ org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin org.apache.ws.security.crypto.merlin.keystore.type=jks org.apache.ws.security.crypto.merlin.keystore.password=password org.apache.ws.security.crypto.merlin.keystore.alias=alice org.apache.ws.security.crypto.merlin.keystore.file=alice.jks bob.properties ============== org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.merlin org.apache.ws.security.crypto.merlin.keystore.type=jks org.apache.ws.security.crypto.merlin.keystore.password=password org.apache.ws.security.crypto.merlin.keystore.alias=bob org.apache.ws.security.crypto.merlin.keystore.file=bob.jks

we have generated both keytores correctly.

4) in client side set properties service interface:

imdservice imdservice = this.getservice(); //we phone call own method obtain service... ((bindingprovider)imdservice).getrequestcontext().put(securityconstants.callback_handler, new keystorepasswordcallback()); ((bindingprovider)imdservice).getrequestcontext().put(securityconstants.signature_properties, thread.currentthread().getcontextclassloader().getresource("alice.properties")); ((bindingprovider)imdservice).getrequestcontext().put(securityconstants.encrypt_properties, thread.currentthread().getcontextclassloader().getresource("alice.properties")); ((bindingprovider)imdservice).getrequestcontext().put(securityconstants.signature_username, "alice"); ((bindingprovider)imdservice).getrequestcontext().put(securityconstants.encrypt_username, "bob");

5) managed dependencies maven , in provided scope in order not indcluded in final war:

- org.jboss.ws.native (jbossws-native-core) - 4.2.0.final - org.apache.ws.security (wss4j) - 1.6.17 - org.apache.cxf (cxf-rt-ws-security, cxf-rt-frontend-jaxws, cxf-rt-transports-http, cxf-rt-transports-http-jetty) - 2.2.3

6) manifest file content is:

manifest-version: 1.0 built-by: laispuru build-jdk: 1.8.0_05 created-by: maven integration eclipse dependencies: org.apache.ws.security

java web-services cxf wss wildfly-8

No comments:

Post a Comment