Repository: cxf Updated Branches: refs/heads/master 272698898 -> 6e9405c6d
Adding @Ignore'd testcase for signature validation issue Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6e9405c6 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6e9405c6 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6e9405c6 Branch: refs/heads/master Commit: 6e9405c6d55e92f2047215918f64b8e1147d7450 Parents: 2726988 Author: Colm O hEigeartaigh <[email protected]> Authored: Fri May 2 16:12:17 2014 +0100 Committer: Colm O hEigeartaigh <[email protected]> Committed: Fri May 2 16:12:17 2014 +0100 ---------------------------------------------------------------------- .../ws/action/SignatureWhitespaceTest.java | 116 +++++++++++++++++++ .../cxf/systest/ws/action/DoubleItAction.wsdl | 3 + .../org/apache/cxf/systest/ws/action/client.xml | 25 ++++ .../action/request-with-trailing-whitespace.xml | 10 ++ .../org/apache/cxf/systest/ws/action/server.xml | 26 +++++ 5 files changed, 180 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/6e9405c6/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java new file mode 100644 index 0000000..d95bbee --- /dev/null +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/SignatureWhitespaceTest.java @@ -0,0 +1,116 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.systest.ws.action; + +import java.io.File; +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.transform.stream.StreamSource; +import javax.xml.ws.Dispatch; +import javax.xml.ws.Service; + +import org.apache.cxf.Bus; +import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.systest.ws.common.SecurityTestUtil; +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.example.contract.doubleit.DoubleItPortType; +import org.junit.BeforeClass; + +/** + * A test for CXF-5679. + */ +public class SignatureWhitespaceTest extends AbstractBusClientServerTestBase { + public static final String PORT = allocatePort(Server.class); + + private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt"; + private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService"); + + @BeforeClass + public static void startServers() throws Exception { + assertTrue( + "Server failed to launch", + // run the server in the same process + // set this to false to fork + launchServer(Server.class, true) + ); + } + + @org.junit.AfterClass + public static void cleanup() throws Exception { + SecurityTestUtil.cleanup(); + stopAllServers(); + } + + @org.junit.Test + public void testNormalSignedSOAPBody() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = SignatureWhitespaceTest.class.getResource("client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = SignatureWhitespaceTest.class.getResource("DoubleItAction.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItSignaturePort"); + DoubleItPortType port = + service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(port, PORT); + + port.doubleIt(25); + + ((java.io.Closeable)port).close(); + bus.shutdown(true); + } + + // TODO test not working + @org.junit.Test + @org.junit.Ignore + public void testTrailingWhitespaceInSOAPBody() throws Exception { + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = SignatureWhitespaceTest.class.getResource("client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = SignatureWhitespaceTest.class.getResource("DoubleItAction.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItSignaturePort"); + + Dispatch<StreamSource> dispatch = + service.createDispatch(portQName, StreamSource.class, Service.Mode.MESSAGE); + + // Creating a DOMSource Object for the request + + URL requestFile = + SignatureWhitespaceTest.class.getResource("request-with-trailing-whitespace.xml"); + + StreamSource request = new StreamSource(new File(requestFile.getPath())); + + updateAddressPort(dispatch, PORT); + + // Make a successful request + StreamSource response = dispatch.invoke(request); + assertNotNull(response); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/6e9405c6/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/DoubleItAction.wsdl ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/DoubleItAction.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/DoubleItAction.wsdl index a7c6829..d9794d3 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/DoubleItAction.wsdl +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/DoubleItAction.wsdl @@ -50,5 +50,8 @@ <wsdl:port name="DoubleItSignedTimestampPort" binding="tns:DoubleItNoSecurityBinding"> <soap:address location="http://localhost:9001/DoubleItSignedTimestamp"/> </wsdl:port> + <wsdl:port name="DoubleItSignaturePort" binding="tns:DoubleItNoSecurityBinding"> + <soap:address location="http://localhost:9001/DoubleItSignature"/> + </wsdl:port> </wsdl:service> </wsdl:definitions> http://git-wip-us.apache.org/repos/asf/cxf/blob/6e9405c6/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/client.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/client.xml index 68f51b1..0dca80c 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/client.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/client.xml @@ -113,4 +113,29 @@ </bean> </jaxws:inInterceptors> </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSignaturePort" createdFromAPI="true"> + <jaxws:outInterceptors> + <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"> + <constructor-arg> + <map> + <entry key="action" value="Signature"/> + <entry key="signatureUser" value="alice"/> + <entry key="signaturePropFile" value="alice.properties"/> + <entry key="signatureKeyIdentifier" value="DirectReference"/> + <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + </map> + </constructor-arg> + </bean> + </jaxws:outInterceptors> + <jaxws:inInterceptors> + <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"> + <constructor-arg> + <map> + <entry key="action" value="Signature"/> + <entry key="signatureVerificationPropFile" value="alice.properties"/> + </map> + </constructor-arg> + </bean> + </jaxws:inInterceptors> + </jaxws:client> </beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/6e9405c6/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/request-with-trailing-whitespace.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/request-with-trailing-whitespace.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/request-with-trailing-whitespace.xml new file mode 100644 index 0000000..5369fb3 --- /dev/null +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/request-with-trailing-whitespace.xml @@ -0,0 +1,10 @@ +<soapenv:Envelope xmlns:doub="http://www.example.org/schema/DoubleIt" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> + <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" wsu:Id="X509-9E450DB8066C2DC474139904277046747">MIIENzCCAhUwggF+oAMCAQICBElUYAAwDQYJKoZIhvcNAQEFBQAwMzETMBEGA1UEChMKYXBhY2hlLm9yZzEMMAoGA1UECxMDZW5nMQ4wDAYDVQQDEwVjeGZjYTAeFw03MDAxMDEwMDAwMDBaFw0zODAxMTkwMzE0MDdaMDMxEzARBgNVBAoTCmFwYWNoZS5vcmcxDDAKBgNVBAsTA2VuZzEOMAwGA1UEAxMFY3hmY2EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOGBi9p1BUVpWm17gmjZTo6QkrpeiVZklOwUsVhZtnTpBlUiIqOghi/ZZXDww0iA8Y8aIaV8vL850D+kXr9muYQ78ii6fBTfKuuLQ+blHqWYamFjFJedYCqbgvg5OTpvcJKQRQWSNsjGUtSuQ3SaBPK9ch/EpDX1JWl8dTseHLhZAgMBAAGjNjA0MCEGA1UdEgQaMBiCFk5PVF9GT1Jf UFJPRFVDVElPTl9VU0UwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQALwODmMIEEwUztngEOEHZoxRag4TQ+Mmz/39lLNVSWlC6Lf3hmPLSJ2rAQCIahs1WTpyBbc+iPyphwYfZkO1zKtpDcuq/aVnLzcJLrT29jl24aFzNWyusSbi9Z3jLj3N1iVHKLknT8uui0U2JsCvGzkeEH3gwReoD1+ENeWrohRzCCAhowggGDoAMCAQICBElUYAEwDQYJKoZIhvcNAQEFBQAwMzETMBEGA1UEChMKYXBhY2hlLm9yZzEMMAoGA1UECxMDZW5nMQ4wDAYDVQQDEwVjeGZjYTAeFw03MDAxMDEwMDAwMDBaFw0zODAxMTkwMzE0MDdaMDMxEzARBgNVBAoTCmFwYWNoZS5vcmcxDDAKBgNVBAsTA2VuZzEOMAwGA1UEAxMFYWxpY2UwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL7u+O/1UoUPOX9egxknOCMYfT1aRoLshKqwrCvKvVxzmF/Zff4OcBAumXEdhcHzbKGh3CjT43ebEk81bQVpkI3wRHyKsE0e77ooTscjU8BM1cCCc76O6fP2mMZPlXQbUMauFMHiHH/4hZFGzNXGdaIl0UM3IkQYvgtQUAkBNKs7AgMBAAGjOzA5MCEGA1UdEgQaMBiCFk5PVF9GT1JfUFJPRFVDVElPTl9VU0UwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAIS8JJvvKbCreIJ24pBs1dE4KUlhnFsVigYvs/LSNp+oRQOb9Y1Rx2uBvYd7NJ8UNk3sM3kf5O4JoFdrCOPNzYK2B5k5iymgwVs2tqQLmbg4UB/BgBISWpBbSgT/vhAvazTaWZ6qh8cd6m9rVtuakbQcw5ivdtYIPTzKJjHO7qkU</wsse:BinarySecurityToken><ds:Signat ure Id="SIG-9E450DB8066C2DC474139904277047151" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="doub soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI="#id-9E450DB8066C2DC474139904277046950"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="doub" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>NjwLBwsqvjfogp5SpOQLf1O/8PE=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>AzpBOq3B+60uGO2FI8Rjej5c1uZm3S+R5ZBYl7BAFam/lU+Lsk7a7vSZyAZJwHrTt16floie3t21 +Bv2rdFumRFDDUDYrJ5niEpUqx6w24jt9ZfaY6akhfxAsoWX8CEO7AtD5D6qgpVxaVKneNRYG72rY +GoaDyT54NMaFvTape5s=</ds:SignatureValue><ds:KeyInfo Id="KI-9E450DB8066C2DC474139904277046748"><wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" wsu:Id="STR-9E450DB8066C2DC474139904277046749" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"><wsse:Reference URI="#X509-9E450DB8066C2DC474139904277046747" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1"/></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soapenv:Header> + <soapenv:Body wsu:Id="id-9E450DB8066C2DC474139904277046950" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> + <doub:DoubleIt> + <numberToDouble>25</numberToDouble> + </doub:DoubleIt> + </soapenv:Body> +</soapenv:Envelope> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/6e9405c6/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/server.xml index 158bfe2..345738b 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/action/server.xml @@ -124,4 +124,30 @@ </bean> </jaxws:inInterceptors> </jaxws:endpoint> + + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="Signature" address="http://localhost:${testutil.ports.Server}/DoubleItSignature" serviceName="s:DoubleItService" endpointName="s:DoubleItSignaturePort" implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" wsdlLocation="org/apache/cxf/systest/ws/action/DoubleItAction.wsdl"> + <jaxws:outInterceptors> + <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"> + <constructor-arg> + <map> + <entry key="action" value="Signature"/> + <entry key="signatureUser" value="bob"/> + <entry key="signaturePropFile" value="bob.properties"/> + <entry key="signatureKeyIdentifier" value="DirectReference"/> + <entry key="passwordCallbackClass" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + </map> + </constructor-arg> + </bean> + </jaxws:outInterceptors> + <jaxws:inInterceptors> + <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"> + <constructor-arg> + <map> + <entry key="action" value="Signature"/> + <entry key="signatureVerificationPropFile" value="bob.properties"/> + </map> + </constructor-arg> + </bean> + </jaxws:inInterceptors> + </jaxws:endpoint> </beans>
