diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java index 94e77d57049..358dd965e08 100644 --- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java +++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java @@ -262,7 +262,7 @@ private void doEncryptBeforeSign() { this.addDerivedKeyElement(secondRefList); } else if (!secondEncrParts.isEmpty()) { //Encrypt, get hold of the ref list and add it - secondRefList = ((WSSecEncrypt)encr).encryptForRef(null, encrParts); + secondRefList = ((WSSecEncrypt)encr).encryptForRef(null, secondEncrParts); this.addDerivedKeyElement(secondRefList); } } diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java index 5c6f81c90c1..c62b1727ce9 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java @@ -338,6 +338,29 @@ public void testAsymmetricUsernameToken() throws Exception { bus.shutdown(true); } + @org.junit.Test + public void testSymmetricUsernameToken() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = X509TokenTest.class.getResource("client/client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItSymmetricUsernameTokenPort"); + DoubleItPortType x509Port = + service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(x509Port, PORT); + + x509Port.doubleIt(25); + + ((java.io.Closeable)x509Port).close(); + bus.shutdown(true); + } + @org.junit.Test public void testSymmetricProtectTokens() throws Exception { diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl index 6dcc8236ccc..6b40a0fdf02 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl @@ -258,6 +258,24 @@ + + + + + + + + + + + + + + + + + + + + + @@ -953,6 +974,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/client.xml index e48303a49b2..459d27b5134 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/client.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/client.xml @@ -236,6 +236,17 @@ + + + + + + + + + diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/server.xml index 8a09062dcbe..de3c1d7bc4b 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/server.xml @@ -386,6 +386,15 @@ + + + + + + +