Author: coheigea Date: Mon Mar 25 13:05:26 2013 New Revision: 1460641 URL: http://svn.apache.org/r1460641 Log: Merged revisions 1460635 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
........ r1460635 | coheigea | 2013-03-25 12:40:08 +0000 (Mon, 25 Mar 2013) | 10 lines Merged revisions 1460624 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1460624 | coheigea | 2013-03-25 11:38:23 +0000 (Mon, 25 Mar 2013) | 2 lines Adding some SAML Negative tests ........ ........ Added: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-asym-policy.xml cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml Modified: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml Modified: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java?rev=1460641&r1=1460640&r2=1460641&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java (original) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java Mon Mar 25 13:05:26 2013 @@ -102,6 +102,23 @@ public class SamlTokenTest extends Abstr int result = saml1Port.doubleIt(25); assertTrue(result == 50); + // Don't send any Token...failure expected + portQName = new QName(NAMESPACE, "DoubleItSaml1TransportPort2"); + saml1Port = service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(saml1Port, PORT2); + + ((BindingProvider)saml1Port).getRequestContext().put( + "ws-security.saml-callback-handler", new SamlCallbackHandler(false) + ); + + try { + saml1Port.doubleIt(25); + fail("Failure expected on no token"); + } catch (javax.xml.ws.soap.SOAPFaultException ex) { + String error = "The received token does not match the token inclusion requirement"; + assertTrue(ex.getMessage().contains(error)); + } + ((java.io.Closeable)saml1Port).close(); bus.shutdown(true); } @@ -240,6 +257,23 @@ public class SamlTokenTest extends Abstr int result = saml2Port.doubleIt(25); assertTrue(result == 50); + // Don't send any Token...failure expected + portQName = new QName(NAMESPACE, "DoubleItSaml2AsymmetricPort2"); + saml2Port = service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(saml2Port, PORT); + + ((BindingProvider)saml2Port).getRequestContext().put( + "ws-security.saml-callback-handler", new SamlCallbackHandler() + ); + + try { + saml2Port.doubleIt(25); + fail("Failure expected on no token"); + } catch (javax.xml.ws.soap.SOAPFaultException ex) { + String error = "The received token does not match the token inclusion requirement"; + assertTrue(ex.getMessage().contains(error)); + } + ((java.io.Closeable)saml2Port).close(); bus.shutdown(true); } Modified: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl?rev=1460641&r1=1460640&r2=1460641&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl (original) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl Mon Mar 25 13:05:26 2013 @@ -298,6 +298,9 @@ <wsdl:port name="DoubleItSaml1TransportPort" binding="tns:DoubleItSaml1TransportBinding"> <soap:address location="https://localhost:9009/DoubleItSaml1Transport" /> </wsdl:port> + <wsdl:port name="DoubleItSaml1TransportPort2" binding="tns:DoubleItInlinePolicyBinding"> + <soap:address location="https://localhost:9009/DoubleItSaml1Transport2" /> + </wsdl:port> <wsdl:port name="DoubleItSaml2SymmetricPort" binding="tns:DoubleItSaml2SymmetricBinding"> <soap:address location="http://localhost:9001/DoubleItSaml2Symmetric" /> </wsdl:port> @@ -308,6 +311,9 @@ <wsdl:port name="DoubleItSaml2AsymmetricPort" binding="tns:DoubleItSaml2AsymmetricBinding"> <soap:address location="http://localhost:9001/DoubleItSaml2Asymmetric" /> </wsdl:port> + <wsdl:port name="DoubleItSaml2AsymmetricPort2" binding="tns:DoubleItInlinePolicyBinding"> + <soap:address location="http://localhost:9001/DoubleItSaml2Asymmetric2" /> + </wsdl:port> <wsdl:port name="DoubleItSaml1SelfSignedTransportPort" binding="tns:DoubleItSaml1SelfSignedTransportBinding"> <soap:address location="https://localhost:9009/DoubleItSaml1SelfSignedTransport" /> Added: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-asym-policy.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-asym-policy.xml?rev=1460641&view=auto ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-asym-policy.xml (added) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-asym-policy.xml Mon Mar 25 13:05:26 2013 @@ -0,0 +1,53 @@ +<wsp:Policy wsu:Id="CleanAsymmetricPolicy" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://www.w3.org/ns/ws-policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:AsymmetricBinding + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:InitiatorToken> + <wsp:Policy> + <sp:X509Token + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10 /> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:InitiatorToken> + <sp:RecipientToken> + <wsp:Policy> + <sp:X509Token + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10 /> + <sp:RequireIssuerSerialReference /> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:RecipientToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128/> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:AsymmetricBinding> + <sp:Wss11 xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:MustSupportRefIssuerSerial/> + <sp:MustSupportRefThumbprint/> + <sp:MustSupportRefEncryptedKey/> + </wsp:Policy> + </sp:Wss11> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> \ No newline at end of file Added: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml?rev=1460641&view=auto ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml (added) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml Mon Mar 25 13:05:26 2013 @@ -0,0 +1,31 @@ +<wsp:Policy wsu:Id="CleanTransportPolicy" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://www.w3.org/ns/ws-policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:TransportBinding + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:TransportToken> + <wsp:Policy> + <sp:HttpsToken> + <wsp:Policy/> + </sp:HttpsToken> + </wsp:Policy> + </sp:TransportToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax /> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp /> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128 /> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:TransportBinding> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> \ No newline at end of file Modified: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml?rev=1460641&r1=1460640&r2=1460641&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml (original) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/client/client.xml Mon Mar 25 13:05:26 2013 @@ -52,6 +52,16 @@ </http:tlsClientParameters> </http:conduit> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSaml1TransportPort2" + createdFromAPI="true"> + <jaxws:features> + <p:policies> + <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" + URI="classpath:/org/apache/cxf/systest/ws/saml/clean-tls-policy.xml" /> + </p:policies> + </jaxws:features> + </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSaml2SymmetricPort" createdFromAPI="true"> <jaxws:properties> @@ -83,6 +93,27 @@ <entry key="ws-security.signature.username" value="alice"/> </jaxws:properties> </jaxws:client> + + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSaml2AsymmetricPort2" + createdFromAPI="true"> + <jaxws:properties> + <entry key="ws-security.callback-handler" + value="org.apache.cxf.systest.ws.wssec10.client.KeystorePasswordCallback"/> + <entry key="ws-security.encryption.properties" + value="org/apache/cxf/systest/ws/wssec10/client/bob.properties"/> + <entry key="ws-security.encryption.username" value="bob"/> + <entry key="ws-security.signature.properties" + value="org/apache/cxf/systest/ws/wssec10/client/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/saml/clean-asym-policy.xml" /> + </p:policies> + </jaxws:features> + </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSaml1SelfSignedTransportPort" createdFromAPI="true"> Added: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml?rev=1460641&view=auto ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml (added) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml Mon Mar 25 13:05:26 2013 @@ -0,0 +1,42 @@ +<wsp:Policy wsu:Id="Saml1TransportPolicy" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://www.w3.org/ns/ws-policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:TransportBinding + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:TransportToken> + <wsp:Policy> + <sp:HttpsToken> + <wsp:Policy/> + </sp:HttpsToken> + </wsp:Policy> + </sp:TransportToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax /> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp /> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128 /> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:TransportBinding> + <sp:SupportingTokens + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:SamlToken + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssSamlV11Token11/> + </wsp:Policy> + </sp:SamlToken> + </wsp:Policy> + </sp:SupportingTokens> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> \ No newline at end of file Added: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml?rev=1460641&view=auto ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml (added) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml Mon Mar 25 13:05:26 2013 @@ -0,0 +1,64 @@ +<wsp:Policy wsu:Id="Saml1AsymmetricPolicy" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" + xmlns:wsp="http://www.w3.org/ns/ws-policy"> + <wsp:ExactlyOne> + <wsp:All> + <sp:AsymmetricBinding + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:InitiatorToken> + <wsp:Policy> + <sp:X509Token + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssX509V3Token10 /> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:InitiatorToken> + <sp:RecipientToken> + <wsp:Policy> + <sp:X509Token + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"> + <wsp:Policy> + <sp:WssX509V3Token10 /> + <sp:RequireIssuerSerialReference /> + </wsp:Policy> + </sp:X509Token> + </wsp:Policy> + </sp:RecipientToken> + <sp:Layout> + <wsp:Policy> + <sp:Lax/> + </wsp:Policy> + </sp:Layout> + <sp:IncludeTimestamp/> + <sp:OnlySignEntireHeadersAndBody/> + <sp:AlgorithmSuite> + <wsp:Policy> + <sp:Basic128/> + </wsp:Policy> + </sp:AlgorithmSuite> + </wsp:Policy> + </sp:AsymmetricBinding> + <sp:Wss11 xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:MustSupportRefIssuerSerial/> + <sp:MustSupportRefThumbprint/> + <sp:MustSupportRefEncryptedKey/> + </wsp:Policy> + </sp:Wss11> + <sp:SignedSupportingTokens + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> + <wsp:Policy> + <sp:SamlToken + sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> + <wsp:Policy> + <sp:WssSamlV20Token11/> + </wsp:Policy> + </sp:SamlToken> + </wsp:Policy> + </sp:SignedSupportingTokens> + </wsp:All> + </wsp:ExactlyOne> + </wsp:Policy> \ No newline at end of file Modified: cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml?rev=1460641&r1=1460640&r2=1460641&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml (original) +++ cxf/branches/2.6.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/saml/server/server.xml Mon Mar 25 13:05:26 2013 @@ -85,6 +85,27 @@ </jaxws:endpoint> <jaxws:endpoint + id="Saml1TokenOverTransport2" + address="https://localhost:${testutil.ports.Server.2}/DoubleItSaml1Transport2" + serviceName="s:DoubleItService" + endpointName="s:DoubleItSaml1TransportPort2" + xmlns:s="http://www.example.org/contract/DoubleIt" + implementor="org.apache.cxf.systest.ws.common.DoubleItPortTypeImpl" + wsdlLocation="org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl" + depends-on="tls-settings"> + + <jaxws:properties> + </jaxws:properties> + <jaxws:features> + <p:policies> + <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" + URI="classpath:/org/apache/cxf/systest/ws/saml/saml1-tls-policy.xml" /> + </p:policies> + </jaxws:features> + + </jaxws:endpoint> + + <jaxws:endpoint id="Saml2TokenOverSymmetric" address="http://localhost:${testutil.ports.Server}/DoubleItSaml2Symmetric" serviceName="s:DoubleItService" @@ -128,6 +149,35 @@ </jaxws:endpoint> <jaxws:endpoint + id="Saml2TokenOverAsymmetric2" + address="http://localhost:${testutil.ports.Server}/DoubleItSaml2Asymmetric2" + serviceName="s:DoubleItService" + endpointName="s:DoubleItSaml2AsymmetricPort2" + xmlns:s="http://www.example.org/contract/DoubleIt" + implementor="org.apache.cxf.systest.ws.common.DoubleItPortTypeImpl" + wsdlLocation="org/apache/cxf/systest/ws/saml/DoubleItSaml.wsdl"> + + <jaxws:properties> + <entry key="ws-security.username" value="bob"/> + <entry key="ws-security.callback-handler" + value="org.apache.cxf.systest.ws.wssec10.client.KeystorePasswordCallback"/> + <entry key="ws-security.signature.properties" + value="org/apache/cxf/systest/ws/wssec10/client/bob.properties"/> + <entry key="ws-security.subject.cert.constraints" value=".*O=apache.org.*"/> + <entry key="ws-security.encryption.username" value="useReqSigCert"/> + <entry key="ws-security.saml2.validator" + value="org.apache.cxf.systest.ws.saml.server.CustomSaml2Validator"/> + </jaxws:properties> + <jaxws:features> + <p:policies> + <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" + URI="classpath:/org/apache/cxf/systest/ws/saml/saml2-asym-policy.xml" /> + </p:policies> + </jaxws:features> + + </jaxws:endpoint> + + <jaxws:endpoint id="Saml1SelfSignedTokenOverTransport" address="https://localhost:${testutil.ports.Server.2}/DoubleItSaml1SelfSignedTransport" serviceName="s:DoubleItService"
