Added support + tests for creating "default" STSClients

Conflicts:
        
rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/782c622a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/782c622a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/782c622a

Branch: refs/heads/2.7.x-fixes
Commit: 782c622a065eb6a7eca6628bbbd2525c81229323
Parents: b4fd12c
Author: Colm O hEigeartaigh <[email protected]>
Authored: Tue Sep 9 15:49:24 2014 +0100
Committer: Colm O hEigeartaigh <[email protected]>
Committed: Tue Sep 9 16:43:46 2014 +0100

----------------------------------------------------------------------
 .../ws/security/trust/AbstractSTSClient.java    |   2 -
 .../apache/cxf/ws/security/trust/STSUtils.java  |  65 +++--
 .../systest/sts/stsclient/STSClientTest.java    | 119 ++++++++++
 .../cxf/systest/sts/stsclient/Server.java       |  46 ++++
 .../cxf/systest/sts/stsclient/DoubleIt.wsdl     | 236 +++++++++++++++++++
 .../systest/sts/stsclient/cxf-client-name.xml   |  58 +++++
 .../sts/stsclient/cxf-default-client.xml        |  58 +++++
 .../cxf/systest/sts/stsclient/cxf-service.xml   |  49 ++++
 8 files changed, 605 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
----------------------------------------------------------------------
diff --git 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
index b46775a..b6aa991 100755
--- 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
+++ 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/AbstractSTSClient.java
@@ -58,7 +58,6 @@ import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.Configurable;
-import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
@@ -627,7 +626,6 @@ public abstract class AbstractSTSClient implements 
Configurable, InterceptorProv
         if (client != null) {
             return;
         }
-        bus.getExtension(Configurer.class).configureBean(name, this);
 
         if (wsdlLocation != null) {
             WSDLServiceFactory factory = new WSDLServiceFactory(bus, 
wsdlLocation, serviceName);

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java
----------------------------------------------------------------------
diff --git 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java
index d91f6d7..afd131a 100644
--- 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java
+++ 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSUtils.java
@@ -22,12 +22,12 @@ package org.apache.cxf.ws.security.trust;
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactory;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
+import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -92,9 +92,39 @@ public final class STSUtils {
     }
     
     public static STSClient getClient(Message message, String type, 
IssuedToken itok) {
+<<<<<<< HEAD
         // Find out first if we have an EPR to get the STS Address (possibly 
via WS-MEX)
         if (itok != null && itok.getIssuerEpr() != null && message != null) {
             EndpointReferenceType epr = itok.getIssuerEpr();
+=======
+        
+        // Retrieve or create the STSClient
+        STSClient client = (STSClient)message
+            .getContextualProperty(SecurityConstants.STS_CLIENT);
+        if (client == null) {
+            client = createSTSClient(message, type);
+            Bus bus = message.getExchange().get(Bus.class);
+            
+            // Check for the "default" case first
+            
bus.getExtension(Configurer.class).configureBean("default.sts-client", client);
+            
+            // Check for Endpoint specific case next
+            if (client.getBeanName() != null) {
+                
bus.getExtension(Configurer.class).configureBean(client.getBeanName(), client);
+            }
+        }
+        
+        
+        // Find out if we have an EPR to get the STS Address (possibly via 
WS-MEX)
+        if (itok != null && itok.getIssuer() != null && message != null) {
+            EndpointReferenceType epr = null;
+            try {
+                epr = 
VersionTransformer.parseEndpointReference(itok.getIssuer());
+            } catch (JAXBException e) {
+                throw new IllegalArgumentException(e);
+            }
+            
+>>>>>>> b535ff6... Added support + tests for creating "default" STSClients
             String mexLocation = findMEXLocation(epr);
             // Configure via WS-MEX
             if (mexLocation != null
@@ -102,45 +132,28 @@ public final class STSUtils {
                                                      
SecurityConstants.PREFER_WSMEX_OVER_STS_CLIENT_CONFIG,
                                                      false)) {
                 // WS-MEX call. So now either get the WS-MEX specific 
STSClient or else create one
-                STSClient client = (STSClient)message
+                STSClient wsMexClient = (STSClient)message
                     .getContextualProperty(SecurityConstants.STS_CLIENT + 
".wsmex");
-                if (client == null) {
-                    client = createSTSClient(message, type);
+                if (wsMexClient == null) {
+                    wsMexClient = createSTSClient(message, type);
                 }
-                client.configureViaEPR(epr, false);
-                return client;
-            } else if (configureViaEPR(message, type, epr)) {
+                wsMexClient.configureViaEPR(epr, false);
+                return wsMexClient;
+            } else if (configureViaEPR(client, epr)) {
                 // Only use WS-MEX here if the pre-configured STSClient has no 
location/wsdllocation
                 boolean useEPRWSAAddrAsMEXLocation = 
                     !Boolean.valueOf((String)message.getContextualProperty(
                         
SecurityConstants.DISABLE_STS_CLIENT_WSMEX_CALL_USING_EPR_ADDRESS));
                 
-                STSClient client = (STSClient)message
-                    .getContextualProperty(SecurityConstants.STS_CLIENT);
-                if (client == null) {
-                    client = createSTSClient(message, type);
-                }
                 client.configureViaEPR(epr, useEPRWSAAddrAsMEXLocation);
                 return client;
             }
         }
         
-        // Not a WS-MEX call
-        STSClient client = (STSClient)message
-            .getContextualProperty(SecurityConstants.STS_CLIENT);
-        if (client == null) {
-            client = createSTSClient(message, type);
-        }
-        
         return client;
     }
-        
-    public static boolean configureViaEPR(Message message, String type, 
EndpointReferenceType epr) {
-        STSClient client = (STSClient)message
-            .getContextualProperty(SecurityConstants.STS_CLIENT);
-        if (epr != null && client == null) {
-            return true;
-        } else if (epr != null && client != null && client.getLocation() == 
null && client.getWsdlLocation() == null) {
+    public static boolean configureViaEPR(STSClient client, 
EndpointReferenceType epr) {
+        if (epr != null && client.getLocation() == null && 
client.getWsdlLocation() == null) {
             return true;
         }
             

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSClientTest.java
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSClientTest.java
 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSClientTest.java
new file mode 100644
index 0000000..62bbc8e
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/STSClientTest.java
@@ -0,0 +1,119 @@
+/**
+ * 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.sts.stsclient;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.sts.common.SecurityTestUtil;
+import org.apache.cxf.systest.sts.deployment.STSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+
+/**
+ * Some tests for STSClient configuration.
+ */
+public class STSClientTest extends AbstractBusClientServerTestBase {
+    
+    static final String STSPORT = allocatePort(STSServer.class);
+    static final String STSPORT2 = allocatePort(STSServer.class, 2);
+    
+    private static final String NAMESPACE = 
"http://www.example.org/contract/DoubleIt";;
+    private static final QName SERVICE_QNAME = new QName(NAMESPACE, 
"DoubleItService");
+
+    private static final String PORT = allocatePort(Server.class);
+    
+    @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)
+        );
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(STSServer.class, true)
+        );
+    }
+    
+    @org.junit.AfterClass
+    public static void cleanup() throws Exception {
+        SecurityTestUtil.cleanup();
+        stopAllServers();
+    }
+
+    @org.junit.Test
+    public void testSTSClientName() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = STSClientTest.class.getResource("cxf-client-name.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = STSClientTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1Port");
+        DoubleItPortType transportSaml1Port = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(transportSaml1Port, PORT);
+        
+        doubleIt(transportSaml1Port, 25);
+        
+        ((java.io.Closeable)transportSaml1Port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
+    public void testDefaultSTSClient() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = 
STSClientTest.class.getResource("cxf-default-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = STSClientTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1Port");
+        DoubleItPortType transportSaml1Port = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(transportSaml1Port, PORT);
+        
+        doubleIt(transportSaml1Port, 25);
+        
+        ((java.io.Closeable)transportSaml1Port).close();
+        bus.shutdown(true);
+    }
+    
+    private static void doubleIt(DoubleItPortType port, int numToDouble) {
+        int resp = port.doubleIt(numToDouble);
+        assertEquals(numToDouble * 2 , resp);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/Server.java
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/Server.java
 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/Server.java
new file mode 100644
index 0000000..802d631
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/stsclient/Server.java
@@ -0,0 +1,46 @@
+/**
+ * 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.sts.stsclient;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+    public Server() {
+
+    }
+
+    protected void run()  {
+        URL busFile = Server.class.getResource("cxf-service.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
+
+        try {
+            new Server();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/DoubleIt.wsdl
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/DoubleIt.wsdl
 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/DoubleIt.wsdl
new file mode 100644
index 0000000..65f3274
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/DoubleIt.wsdl
@@ -0,0 +1,236 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:di="http://www.example.org/schema/DoubleIt"; 
xmlns:tns="http://www.example.org/contract/DoubleIt"; 
xmlns:wsp="http://www.w3.org/ns/ws-policy"; 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"; 
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"; 
xmlns:t="http://docs.oasis-open.org/ws-sx/ws-trust/200512"; 
xmlns:wsaw="http://www.w3.org/2005/08/addressing"; 
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"; name="DoubleIt" 
targetNamespace="http://www.example.org/contract/DoubleIt";>
+    <wsdl:import location="src/test/resources/DoubleItLogical.wsdl" 
namespace="http://www.example.org/contract/DoubleIt"/>
+    <wsdl:binding name="DoubleItTransportSAML1Binding" 
type="tns:DoubleItPortType">
+        <wsp:PolicyReference URI="#DoubleItBindingTransportSAML1Policy"/>
+        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="DoubleIt">
+            <soap:operation soapAction=""/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+                <wsp:PolicyReference 
URI="#DoubleItBinding_DoubleIt_Input_Policy"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+                <wsp:PolicyReference 
URI="#DoubleItBinding_DoubleIt_Output_Policy"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="DoubleItTransportSAML2Binding" 
type="tns:DoubleItPortType">
+        <wsp:PolicyReference URI="#DoubleItBindingTransportSAML2Policy"/>
+        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="DoubleIt">
+            <soap:operation soapAction=""/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+                <wsp:PolicyReference 
URI="#DoubleItBinding_DoubleIt_Input_Policy"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+                <wsp:PolicyReference 
URI="#DoubleItBinding_DoubleIt_Output_Policy"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="DoubleItService">
+        <wsdl:port name="DoubleItTransportSAML1Port" 
binding="tns:DoubleItTransportSAML1Binding">
+            <soap:address 
location="https://localhost:8081/doubleit/services/doubleittransportsaml1"/>
+        </wsdl:port>
+        <wsdl:port name="DoubleItTransportSAML2Port" 
binding="tns:DoubleItTransportSAML2Binding">
+            <soap:address 
location="https://localhost:8081/doubleit/services/doubleittransportsaml2"/>
+        </wsdl:port>
+    </wsdl:service>
+    <wsp:Policy wsu:Id="DoubleItBindingTransportSAML1Policy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <wsam:Addressing wsp:Optional="false">
+                    <wsp:Policy/>
+                </wsam:Addressing>
+                <sp:TransportBinding 
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702";>
+                    <wsp:Policy>
+                        <sp:TransportToken>
+                            <wsp:Policy>
+                                <sp:IssuedToken 
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient";>
+                                    <sp:RequestSecurityTokenTemplate>
+                                        
<t:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</t:TokenType>
+                                        
<t:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey</t:KeyType>
+                                    </sp:RequestSecurityTokenTemplate>
+                                    <wsp:Policy>
+                                        <sp:RequireInternalReference/>
+                                    </wsp:Policy>
+                                    <sp:Issuer>
+                                        
<wsaw:Address>http://localhost:8080/STS/STSUT
+                                                                               
 </wsaw:Address>
+                                        <wsaw:Metadata>
+                                            <wsx:Metadata>
+                                                <wsx:MetadataSection>
+                                                    <wsx:MetadataReference>
+                                                        
<wsaw:Address>http://localhost:8080/SecurityTokenService/UT/mex
+                                                                               
                                 </wsaw:Address>
+                                                    </wsx:MetadataReference>
+                                                </wsx:MetadataSection>
+                                            </wsx:Metadata>
+                                        </wsaw:Metadata>
+                                    </sp:Issuer>
+                                </sp:IssuedToken>
+                            </wsp:Policy>
+                        </sp:TransportToken>
+                        <sp:AlgorithmSuite>
+                            <wsp:Policy>
+                                <sp:TripleDes/>
+                            </wsp:Policy>
+                        </sp:AlgorithmSuite>
+                        <sp:Layout>
+                            <wsp:Policy>
+                                <sp:Lax/>
+                            </wsp:Policy>
+                        </sp:Layout>
+                        <sp:IncludeTimestamp/>
+                    </wsp:Policy>
+                </sp:TransportBinding>
+                <sp:Wss11>
+                    <wsp:Policy>
+                        <sp:MustSupportRefIssuerSerial/>
+                        <sp:MustSupportRefThumbprint/>
+                        <sp:MustSupportRefEncryptedKey/>
+                    </wsp:Policy>
+                </sp:Wss11>
+                <sp:Trust13>
+                    <wsp:Policy>
+                        <sp:MustSupportIssuedTokens/>
+                        <sp:RequireClientEntropy/>
+                        <sp:RequireServerEntropy/>
+                    </wsp:Policy>
+                </sp:Trust13>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+    <wsp:Policy wsu:Id="DoubleItBindingTransportSAML2Policy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <wsam:Addressing wsp:Optional="false">
+                    <wsp:Policy/>
+                </wsam:Addressing>
+                <sp:TransportBinding 
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702";>
+                    <wsp:Policy>
+                        <sp:TransportToken>
+                            <wsp:Policy>
+                                <sp:IssuedToken 
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient";>
+                                    <sp:RequestSecurityTokenTemplate>
+                                        
<t:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</t:TokenType>
+                                        
<t:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/PublicKey</t:KeyType>
+                                    </sp:RequestSecurityTokenTemplate>
+                                    <wsp:Policy>
+                                        <sp:RequireInternalReference/>
+                                    </wsp:Policy>
+                                    <sp:Issuer>
+                                        
<wsaw:Address>http://localhost:8080/SecurityTokenService/UT
+                                                                               
 </wsaw:Address>
+                                        <wsaw:Metadata>
+                                            <wsx:Metadata>
+                                                <wsx:MetadataSection>
+                                                    <wsx:MetadataReference>
+                                                        
<wsaw:Address>http://localhost:8080/SecurityTokenService/UT/mex
+                                                                               
                                 </wsaw:Address>
+                                                    </wsx:MetadataReference>
+                                                </wsx:MetadataSection>
+                                            </wsx:Metadata>
+                                        </wsaw:Metadata>
+                                    </sp:Issuer>
+                                </sp:IssuedToken>
+                            </wsp:Policy>
+                        </sp:TransportToken>
+                        <sp:AlgorithmSuite>
+                            <wsp:Policy>
+                                <sp:TripleDes/>
+                            </wsp:Policy>
+                        </sp:AlgorithmSuite>
+                        <sp:Layout>
+                            <wsp:Policy>
+                                <sp:Lax/>
+                            </wsp:Policy>
+                        </sp:Layout>
+                        <sp:IncludeTimestamp/>
+                    </wsp:Policy>
+                </sp:TransportBinding>
+                <sp:Wss11>
+                    <wsp:Policy>
+                        <sp:MustSupportRefIssuerSerial/>
+                        <sp:MustSupportRefThumbprint/>
+                        <sp:MustSupportRefEncryptedKey/>
+                    </wsp:Policy>
+                </sp:Wss11>
+                <sp:Trust13>
+                    <wsp:Policy>
+                        <sp:MustSupportIssuedTokens/>
+                        <sp:RequireClientEntropy/>
+                        <sp:RequireServerEntropy/>
+                    </wsp:Policy>
+                </sp:Trust13>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+    <wsp:Policy wsu:Id="DoubleItBinding_DoubleIt_Input_Policy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <sp:EncryptedParts>
+                    <sp:Body/>
+                </sp:EncryptedParts>
+                <sp:SignedParts>
+                    <sp:Body/>
+                    <sp:Header Name="To" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="From" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="FaultTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="ReplyTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="MessageID" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="RelatesTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="Action" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="AckRequested" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="SequenceAcknowledgement" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="Sequence" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="CreateSequence" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                </sp:SignedParts>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+    <wsp:Policy wsu:Id="DoubleItBinding_DoubleIt_Output_Policy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <sp:EncryptedParts>
+                    <sp:Body/>
+                </sp:EncryptedParts>
+                <sp:SignedParts>
+                    <sp:Body/>
+                    <sp:Header Name="To" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="From" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="FaultTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="ReplyTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="MessageID" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="RelatesTo" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="Action" 
Namespace="http://www.w3.org/2005/08/addressing"/>
+                    <sp:Header Name="AckRequested" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="SequenceAcknowledgement" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="Sequence" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                    <sp:Header Name="CreateSequence" 
Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                </sp:SignedParts>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+</wsdl:definitions>

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-client-name.xml
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-client-name.xml
 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-client-name.xml
new file mode 100644
index 0000000..1814647
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-client-name.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:jaxws="http://cxf.apache.org/jaxws"; 
xmlns:cxf="http://cxf.apache.org/core"; 
xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; xsi:schemaLocation=" 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
http://cxf.apache.org/transports/http/configuration 
http://cxf.apache.org/schemas/configuration/http-conf.xsd 
http://cxf.apache.org/configuration/security 
http://cxf.apache.org/schemas/configuration/security.xsd";>
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    
+    <bean id="stsClient" class="org.apache.cxf.ws.security.trust.STSClient"
+        
name="{http://www.example.org/contract/DoubleIt}DoubleItTransportSAML1Port.sts-client";
+        abstract="true"
+    >
+        <constructor-arg ref="cxf"/>
+        <property name="wsdlLocation" 
value="https://localhost:${testutil.ports.STSServer}/SecurityTokenService/Transport?wsdl"/>
+        <property name="serviceName" 
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService"/>
+        <property name="endpointName" 
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"/>
+        <property name="properties">
+            <map>
+                <entry key="ws-security.username" value="alice"/>
+                <entry key="ws-security.callback-handler" 
value="org.apache.cxf.systest.sts.common.CommonCallbackHandler"/>
+                <entry key="ws-security.sts.token.username" 
value="myclientkey"/>
+                <entry key="ws-security.sts.token.properties" 
value="clientKeystore.properties"/>
+                <entry key="ws-security.sts.token.usecert" value="true"/>
+            </map>
+        </property>
+    </bean>
+    
+    <http:conduit name="https://localhost.*";>
+        <http:tlsClientParameters disableCNCheck="true">
+            <sec:keyManagers keyPassword="ckpass">
+                <sec:keyStore type="jks" password="cspass" 
resource="clientstore.jks"/>
+            </sec:keyManagers>
+            <sec:trustManagers>
+                <sec:keyStore type="jks" password="cspass" 
resource="clientstore.jks"/>
+            </sec:trustManagers>
+        </http:tlsClientParameters>
+    </http:conduit>
+</beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-default-client.xml
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-default-client.xml
 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-default-client.xml
new file mode 100644
index 0000000..275b417
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-default-client.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:jaxws="http://cxf.apache.org/jaxws"; 
xmlns:cxf="http://cxf.apache.org/core"; 
xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; xsi:schemaLocation=" 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
http://cxf.apache.org/transports/http/configuration 
http://cxf.apache.org/schemas/configuration/http-conf.xsd 
http://cxf.apache.org/configuration/security 
http://cxf.apache.org/schemas/configuration/security.xsd";>
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    
+    <bean id="stsClient" class="org.apache.cxf.ws.security.trust.STSClient"
+        name="default.sts-client"
+        abstract="true"
+    >
+        <constructor-arg ref="cxf"/>
+        <property name="wsdlLocation" 
value="https://localhost:${testutil.ports.STSServer}/SecurityTokenService/Transport?wsdl"/>
+        <property name="serviceName" 
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService"/>
+        <property name="endpointName" 
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"/>
+        <property name="properties">
+            <map>
+                <entry key="ws-security.username" value="alice"/>
+                <entry key="ws-security.callback-handler" 
value="org.apache.cxf.systest.sts.common.CommonCallbackHandler"/>
+                <entry key="ws-security.sts.token.username" 
value="myclientkey"/>
+                <entry key="ws-security.sts.token.properties" 
value="clientKeystore.properties"/>
+                <entry key="ws-security.sts.token.usecert" value="true"/>
+            </map>
+        </property>
+    </bean>
+    
+    <http:conduit name="https://localhost.*";>
+        <http:tlsClientParameters disableCNCheck="true">
+            <sec:keyManagers keyPassword="ckpass">
+                <sec:keyStore type="jks" password="cspass" 
resource="clientstore.jks"/>
+            </sec:keyManagers>
+            <sec:trustManagers>
+                <sec:keyStore type="jks" password="cspass" 
resource="clientstore.jks"/>
+            </sec:trustManagers>
+        </http:tlsClientParameters>
+    </http:conduit>
+</beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/782c622a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-service.xml
----------------------------------------------------------------------
diff --git 
a/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-service.xml
 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-service.xml
new file mode 100644
index 0000000..ac2680b
--- /dev/null
+++ 
b/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/stsclient/cxf-service.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"; 
xmlns:cxf="http://cxf.apache.org/core"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; 
xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"; 
xmlns:jaxws="http://cxf.apache.org/jaxws"; xsi:schemaLocation="             
http://cxf.apache.org/core             http://cxf.apache.org/schemas/core.xsd   
          http://cxf.apache.org/configuration/security             
http://cxf.apache.org/schemas/configuration/security.xsd             
http://cxf.apache.org/jaxws             http://cxf.apache.org/schemas/jaxws.xsd 
            http://cxf.apache.org/transports/http/configuration             
http://cxf.apache.org/schemas/configuration/http-conf.xsd             
http://cxf.apache.org/transports/http-jetty/configuration             
http://cxf.apache.org/schemas/configuration/http-jetty.xsd      
        http://www.springframework.org/schema/beans             
http://www.springframework.org/schema/beans/spring-beans.xsd";>
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt"; 
id="doubleittransportsaml1" 
implementor="org.apache.cxf.systest.sts.common.DoubleItPortTypeImpl" 
endpointName="s:DoubleItTransportSAML1Port" serviceName="s:DoubleItService" 
depends-on="ClientAuthHttpsSettings" 
address="https://localhost:${testutil.ports.Server}/doubleit/services/doubleittransportsaml1";
 wsdlLocation="org/apache/cxf/systest/sts/stsclient/DoubleIt.wsdl">
+        <jaxws:properties>
+            <entry key="ws-security.callback-handler" 
value="org.apache.cxf.systest.sts.common.CommonCallbackHandler"/>
+            <entry key="ws-security.signature.properties" 
value="serviceKeystore.properties"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+    <httpj:engine-factory id="ClientAuthHttpsSettings" bus="cxf">
+        <httpj:engine port="${testutil.ports.Server}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="skpass">
+                    <sec:keyStore type="jks" password="sspass" 
resource="servicestore.jks"/>
+                </sec:keyManagers>
+                <sec:trustManagers>
+                    <sec:keyStore type="jks" password="stsspass" 
resource="stsstore.jks"/>
+                </sec:trustManagers>
+                <sec:cipherSuitesFilter>
+                    <sec:include>.*_EXPORT_.*</sec:include>
+                    <sec:include>.*_EXPORT1024_.*</sec:include>
+                    <sec:include>.*_WITH_DES_.*</sec:include>
+                    <sec:include>.*_WITH_AES_.*</sec:include>
+                    <sec:include>.*_WITH_NULL_.*</sec:include>
+                    <sec:exclude>.*_DH_anon_.*</sec:exclude>
+                </sec:cipherSuitesFilter>
+                <sec:clientAuthentication want="true" required="true"/>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+</beans>

Reply via email to