[CXF-5585] - "SignatureConfirmation does not work with the Asymmetric Binding + EncryptBeforeSigning".
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8d1f9be3 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8d1f9be3 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8d1f9be3 Branch: refs/heads/master Commit: 8d1f9be35b244f43902e8577f59f70b7bf3d2818 Parents: 276343f Author: Colm O hEigeartaigh <[email protected]> Authored: Fri Feb 28 14:55:24 2014 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Fri Feb 28 14:56:32 2014 +0000 ---------------------------------------------------------------------- .../AsymmetricBindingHandler.java | 5 +++- .../ws/bindings/BindingPropertiesTest.java | 28 ++++++++++++++++++++ .../systest/ws/bindings/DoubleItBindings.wsdl | 3 +++ .../apache/cxf/systest/ws/bindings/client.xml | 16 +++++++++++ .../apache/cxf/systest/ws/bindings/server.xml | 14 ++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/8d1f9be3/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java ---------------------------------------------------------------------- diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java index 3b275cf..e71baf7 100644 --- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java +++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java @@ -338,7 +338,10 @@ public class AsymmetricBindingHandler extends AbstractBindingBuilder { LOG.log(Level.FINE, ex.getMessage(), ex); policyNotAsserted(encryptionToken, ex); } - addSignatureConfirmation(sigParts); + + if (!isRequestor()) { + addSignatureConfirmation(sigParts); + } try { if (sigParts.size() > 0) { http://git-wip-us.apache.org/repos/asf/cxf/blob/8d1f9be3/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java index 4bb4ad5..ff9077c 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java @@ -565,4 +565,32 @@ public class BindingPropertiesTest extends AbstractBusClientServerTestBase { bus.shutdown(true); } + @org.junit.Test + public void testSignatureConfirmationEncBeforeSigning() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = BindingPropertiesTest.class.getResource("client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = BindingPropertiesTest.class.getResource("DoubleItBindings.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + + QName portQName = new QName(NAMESPACE, "DoubleItSignatureConfirmationEncBeforeSigningPort"); + DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(port, test.getPort()); + + if (test.isStreaming()) { + SecurityTestUtil.enableStreaming(port); + } + + port.doubleIt(25); + + ((java.io.Closeable)port).close(); + bus.shutdown(true); + } + + } http://git-wip-us.apache.org/repos/asf/cxf/blob/8d1f9be3/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl index 90a4804..446f8fc 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl @@ -108,6 +108,9 @@ <wsdl:port name="DoubleItSignatureConfirmationPort2" binding="tns:DoubleItStandardBinding"> <soap:address location="http://localhost:9010/DoubleItSignatureConfirmation2"/> </wsdl:port> + <wsdl:port name="DoubleItSignatureConfirmationEncBeforeSigningPort" binding="tns:DoubleItStandardBinding"> + <soap:address location="http://localhost:9010/DoubleItSignatureConfirmationEncBeforeSigning"/> + </wsdl:port> <wsdl:port name="DoubleItStrictPort" binding="tns:DoubleItStandardBinding"> <soap:address location="http://localhost:9010/DoubleItStrict"/> </wsdl:port> http://git-wip-us.apache.org/repos/asf/cxf/blob/8d1f9be3/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/client.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/client.xml index a7f8536..7ca8fcf 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/client.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/client.xml @@ -324,4 +324,20 @@ </p:policies> </jaxws:features> </jaxws:client> + + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSignatureConfirmationEncBeforeSigningPort" createdFromAPI="true"> + <jaxws:properties> + <entry key="ws-security.username" value="Alice"/> + <entry key="ws-security.callback-handler" value="org.apache.cxf.systest.ws.common.UTPasswordCallback"/> + <entry key="ws-security.encryption.properties" value="bob.properties"/> + <entry key="ws-security.encryption.username" value="bob"/> + <entry key="ws-security.signature.properties" value="alice.properties"/> + <entry key="ws-security.signature.username" value="alice"/> + </jaxws:properties> + <jaxws:features> + <p:policies> + <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" URI="classpath:/org/apache/cxf/systest/ws/bindings/sig-conf-enc-before-signing-policy.xml"/> + </p:policies> + </jaxws:features> + </jaxws:client> </beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/8d1f9be3/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/server.xml index 0af881a..233f3ec 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/bindings/server.xml @@ -285,4 +285,18 @@ </p:policies> </jaxws:features> </jaxws:endpoint> + + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="SignatureConfirmationEncBeforeSigningEndpoint" address="http://localhost:${testutil.ports.Server}/DoubleItSignatureConfirmationEncBeforeSigning" serviceName="s:DoubleItService" endpointName="s:DoubleItSignatureConfirmationEncBeforeSigningPort" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/bindings/DoubleItBindings.wsdl"> + <jaxws:properties> + <entry key="ws-security.callback-handler" value="org.apache.cxf.systest.ws.common.UTPasswordCallback"/> + <entry key="ws-security.signature.properties" value="bob.properties"/> + <entry key="ws-security.encryption.username" value="useReqSigCert"/> + <entry key="ws-security.subject.cert.constraints" value=".*O=apache.org.*"/> + </jaxws:properties> + <jaxws:features> + <p:policies> + <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" URI="classpath:/org/apache/cxf/systest/ws/bindings/sig-conf-enc-before-signing-policy.xml"/> + </p:policies> + </jaxws:features> + </jaxws:endpoint> </beans>
