Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 0b3a9ec32 -> b8d1d726c


Adding the ability to cache tokens per-proxy

Conflicts:
        
rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
        
rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JUtils.java


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

Branch: refs/heads/2.7.x-fixes
Commit: 03610028ee5133a3dc1122a794fbe270d784e5b5
Parents: 0b3a9ec
Author: Colm O hEigeartaigh <[email protected]>
Authored: Mon Mar 3 15:41:25 2014 +0000
Committer: Colm O hEigeartaigh <[email protected]>
Committed: Mon Mar 3 16:11:17 2014 +0000

----------------------------------------------------------------------
 .../cxf/ws/security/SecurityConstants.java      |  15 +-
 .../policy/interceptors/NegotiationUtils.java   |   6 +-
 .../cxf/systest/ws/cache/CachingTest.java       | 212 +++++++++++++++++++
 .../org/apache/cxf/systest/ws/cache/Server.java |  41 ++++
 .../cxf/systest/ws/cache/DoubleItCache.wsdl     | 108 ++++++++++
 .../org/apache/cxf/systest/ws/cache/client.xml  |  42 ++++
 .../cxf/systest/ws/cache/per-proxy-cache.xml    |  10 +
 .../org/apache/cxf/systest/ws/cache/server.xml  |  43 ++++
 8 files changed, 475 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
----------------------------------------------------------------------
diff --git 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
index 60f7e22..d2a91ff 100644
--- 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
+++ 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/SecurityConstants.java
@@ -292,6 +292,18 @@ public final class SecurityConstants {
      */
     public static final String TOKEN_STORE_CACHE_INSTANCE = 
         "org.apache.cxf.ws.security.tokenstore.TokenStore";
+    
+    /**
+     * The Cache Identifier to use with the TokenStore. CXF uses the following 
key to retrieve a
+     * token store: 
"org.apache.cxf.ws.security.tokenstore.TokenStore-<identifier>". This key can 
be 
+     * used to configure service-specific cache configuration. If the 
identifier does not match, then it 
+     * falls back to a cache configuration with key 
"org.apache.cxf.ws.security.tokenstore.TokenStore".
+     * 
+     * The default "<identifier>" is the QName of the service in question. 
However to pick up a 
+     * custom cache configuration (for example, if you want to specify a 
TokenStore per-client proxy),
+     * it can be configured with this identifier instead.
+     */
+    public static final String CACHE_IDENTIFIER = 
"ws-security.cache.identifier";
 
     /**
      * A comma separated String of regular expressions which will be applied 
to the subject DN of 
@@ -527,7 +539,8 @@ public final class SecurityConstants {
             DISABLE_STS_CLIENT_WSMEX_CALL_USING_EPR_ADDRESS, STS_TOKEN_CRYPTO,
             STS_TOKEN_PROPERTIES, STS_TOKEN_USERNAME, STS_TOKEN_ACT_AS, 
STS_TOKEN_ON_BEHALF_OF,
             TOKEN, TOKEN_ID, SUBJECT_ROLE_CLASSIFIER, 
SUBJECT_ROLE_CLASSIFIER_TYPE, MUST_UNDERSTAND,
-            ASYMMETRIC_SIGNATURE_ALGORITHM, ENABLE_SAML_ONE_TIME_USE_CACHE, 
SAML_ONE_TIME_USE_CACHE_INSTANCE
+            ASYMMETRIC_SIGNATURE_ALGORITHM, ENABLE_SAML_ONE_TIME_USE_CACHE, 
SAML_ONE_TIME_USE_CACHE_INSTANCE,
+            CACHE_IDENTIFIER
         }));
         ALL_PROPERTIES = Collections.unmodifiableSet(s);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
----------------------------------------------------------------------
diff --git 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
index b236395..ec817f8 100644
--- 
a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
+++ 
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
@@ -111,7 +111,11 @@ public final class NegotiationUtils {
             if (create && tokenStore == null) {
                 TokenStoreFactory tokenStoreFactory = 
TokenStoreFactory.newInstance();
                 String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
-                if (info.getName() != null) {
+                String cacheIdentifier = 
+                    
(String)message.getContextualProperty(SecurityConstants.CACHE_IDENTIFIER);
+                if (cacheIdentifier != null) {
+                    cacheKey += "-" + cacheIdentifier;
+                } else if (info.getName() != null) {
                     cacheKey += "-" + info.getName().toString();
                 }
                 tokenStore = tokenStoreFactory.newTokenStore(cacheKey, 
message);

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java
 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java
new file mode 100644
index 0000000..72fa9e3
--- /dev/null
+++ 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java
@@ -0,0 +1,212 @@
+/**
+ * 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.cache;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.systest.ws.common.SecurityTestUtil;
+import org.apache.cxf.systest.ws.common.TestParam;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.tokenstore.TokenStore;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * A set of tests for token caching on the client side
+ */
+@RunWith(value = org.junit.runners.Parameterized.class)
+public class CachingTest 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");
+    
+    final TestParam test;
+    
+    public CachingTest(TestParam type) {
+        this.test = type;
+    }
+    
+    @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)
+        );
+    }
+    
+    @Parameters(name = "{0}")
+    public static Collection<TestParam[]> data() {
+       
+        return Arrays.asList(new TestParam[][] {{new TestParam(PORT, false)},
+                                                {new TestParam(PORT, true)},
+        });
+    }
+    
+    @org.junit.AfterClass
+    public static void cleanup() throws Exception {
+        SecurityTestUtil.cleanup();
+        stopAllServers();
+    }
+
+    @org.junit.Test
+    public void testSymmetric() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = CachingTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        URL wsdl = CachingTest.class.getResource("DoubleItCache.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItCacheSymmetricPort");
+        
+        // First invocation
+        DoubleItPortType port = 
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, test.getPort());
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
+        
+        port.doubleIt(25);
+
+        Client client = ClientProxy.getClient(port);
+        TokenStore tokenStore = 
+            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
+                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
+            );
+        assertNotNull(tokenStore);
+        // We expect two tokens as the identifier + SHA-1 are cached
+        assertEquals(tokenStore.getTokenIdentifiers().size(), 2);
+        
+        // Second invocation
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, test.getPort());
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
+        
+        port.doubleIt(35);
+
+        client = ClientProxy.getClient(port);
+        tokenStore = 
+            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
+                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
+            );
+        assertNotNull(tokenStore);
+        // There should now be 4 tokens as both proxies share the same 
TokenStore
+        assertEquals(tokenStore.getTokenIdentifiers().size(), 4);
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
+    public void testCachePerProxySymmetric() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = CachingTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        URL wsdl = CachingTest.class.getResource("DoubleItCache.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, 
"DoubleItCachePerProxySymmetricPort");
+        
+        // First invocation
+        DoubleItPortType port = 
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, test.getPort());
+        
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.CACHE_IDENTIFIER, "proxy1"
+        );
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.CACHE_CONFIG_FILE, "per-proxy-cache.xml"
+        );
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
+        
+        port.doubleIt(25);
+
+        Client client = ClientProxy.getClient(port);
+        TokenStore tokenStore = 
+            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
+                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
+            );
+        assertNotNull(tokenStore);
+        // We expect two tokens as the identifier + SHA-1 are cached
+        assertEquals(tokenStore.getTokenIdentifiers().size(), 2);
+        
+        // Second invocation
+        port = service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, test.getPort());
+        
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.CACHE_IDENTIFIER, "proxy2"
+        );
+        ((BindingProvider)port).getRequestContext().put(
+            SecurityConstants.CACHE_CONFIG_FILE, "per-proxy-cache.xml"
+        );
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
+        
+        port.doubleIt(35);
+
+        client = ClientProxy.getClient(port);
+        tokenStore = 
+            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
+                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
+            );
+        assertNotNull(tokenStore);
+        // We expect two tokens as the identifier + SHA-1 are cached
+        assertEquals(tokenStore.getTokenIdentifiers().size(), 2);
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/Server.java
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/Server.java
 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/Server.java
new file mode 100644
index 0000000..07ce94c
--- /dev/null
+++ 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/Server.java
@@ -0,0 +1,41 @@
+/**
+ * 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.cache;
+
+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("server.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl
 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl
new file mode 100644
index 0000000..bc833d3
--- /dev/null
+++ 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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: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:wsaws="http://www.w3.org/2005/08/addressing"; 
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"; 
xmlns:sp13="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802"; 
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="DoubleItSymmetricBinding" type="tns:DoubleItPortType">
+        <wsp:PolicyReference URI="#DoubleItSymmetricPolicy"/>
+        <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:fault name="DoubleItFault">
+                <soap:body use="literal" name="DoubleItFault"/>
+            </wsdl:fault>
+        </wsdl:operation>
+    </wsdl:binding>
+    
+    <wsdl:service name="DoubleItService">
+        <wsdl:port name="DoubleItCacheSymmetricPort" 
binding="tns:DoubleItSymmetricBinding">
+            <soap:address 
location="http://localhost:9001/DoubleItCacheSymmetric"/>
+        </wsdl:port>
+        <wsdl:port name="DoubleItCachePerProxySymmetricPort" 
binding="tns:DoubleItSymmetricBinding">
+            <soap:address 
location="http://localhost:9001/DoubleItCachePerProxySymmetric"/>
+        </wsdl:port>
+    </wsdl:service>
+    
+    <wsp:Policy wsu:Id="DoubleItSymmetricPolicy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <sp:SymmetricBinding>
+                    <wsp:Policy>
+                        <sp:ProtectionToken>
+                            <wsp:Policy>
+                                <sp:X509Token 
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never";>
+                                    <wsp:Policy>
+                                        <sp:WssX509V3Token10/>
+                                        <sp:RequireKeyIdentifierReference/>
+                                    </wsp:Policy>
+                                </sp:X509Token>
+                            </wsp:Policy>
+                        </sp:ProtectionToken>
+                        <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:SymmetricBinding>
+            </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: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:SignedParts>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+
+</wsdl:definitions>

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/client.xml
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/client.xml
 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/client.xml
new file mode 100644
index 0000000..2962f04
--- /dev/null
+++ 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/client.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:jaxws="http://cxf.apache.org/jaxws"; 
xmlns:cxf="http://cxf.apache.org/core"; xmlns:p="http://cxf.apache.org/policy"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; xsi:schemaLocation="   
        http://www.springframework.org/schema/beans           
http://www.springframework.org/schema/beans/spring-beans.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           
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd           
http://cxf.apache.org/policy http://cxf.apache.org/schemas/poli
 cy.xsd">
+    <cxf:bus>
+        <cxf:features>
+            <p:policies/>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+   
+    <jaxws:client 
name="{http://www.example.org/contract/DoubleIt}DoubleItCacheSymmetricPort"; 
createdFromAPI="true">
+        <jaxws:properties>
+            <entry key="ws-security.encryption.properties" 
value="bob.properties"/>
+            <entry key="ws-security.encryption.username" value="bob"/>
+        </jaxws:properties>
+    </jaxws:client>
+    
+    <jaxws:client 
name="{http://www.example.org/contract/DoubleIt}DoubleItCachePerProxySymmetricPort";
 createdFromAPI="true">
+        <jaxws:properties>
+            <entry key="ws-security.encryption.properties" 
value="bob.properties"/>
+            <entry key="ws-security.encryption.username" value="bob"/>
+        </jaxws:properties>
+    </jaxws:client>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/per-proxy-cache.xml
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/per-proxy-cache.xml
 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/per-proxy-cache.xml
new file mode 100644
index 0000000..de11dff
--- /dev/null
+++ 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/per-proxy-cache.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<ehcache xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false" 
monitoring="autodetect" dynamicConfig="true" name="perProxyCache">
+    <diskStore path="java.io.tmpdir"/>
+    <defaultCache maxEntriesLocalHeap="5000" eternal="false" 
timeToIdleSeconds="3600" timeToLiveSeconds="3600" overflowToDisk="true" 
maxElementsOnDisk="10000000" diskPersistent="false" 
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU"/>
+    
+    <cache name="org.apache.cxf.ws.security.tokenstore.TokenStore-proxy1" 
overflowToDisk="false" maxEntriesLocalHeap="1000" timeToIdleSeconds="3600" 
timeToLiveSeconds="3600"/>
+    
+    <cache name="org.apache.cxf.ws.security.tokenstore.TokenStore-proxy2" 
overflowToDisk="false" maxEntriesLocalHeap="500" timeToIdleSeconds="3600" 
timeToLiveSeconds="3600"/>
+    
+</ehcache>

http://git-wip-us.apache.org/repos/asf/cxf/blob/03610028/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/server.xml
----------------------------------------------------------------------
diff --git 
a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/server.xml
 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/server.xml
new file mode 100644
index 0000000..1a3a27e
--- /dev/null
+++ 
b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/cache/server.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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:util="http://www.springframework.org/schema/util"; 
xmlns:jaxws="http://cxf.apache.org/jaxws"; 
xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; 
xmlns:cxf="http://cxf.apache.org/core"; xmlns:p="http://cxf.apache.org/policy"; 
xsi:schemaLocation="         http://www.springframework.org/schema/beans        
             http://www.springframework.org/schema/beans/spring-beans.xsd       
  http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-2.0.xsd         
http://cxf.apache.org/jaxws                                     
http://cxf.apache.org/schemas/jaxws.xsd         http://cxf.apache.org/core 
http://cxf.apache.org/schemas/core.xsd         http://cxf.apache.org/policy 
http://cxf.apache.org/s
 chemas/policy.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://cxf.apache.org/configuration/security                    
http://cxf.apache.org/schemas/configuration/security.xsd     ">
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    <cxf:bus>
+        <cxf:features>
+            <p:policies/>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt"; 
id="CacheSymmetric" 
address="http://localhost:${testutil.ports.Server}/DoubleItCacheSymmetric"; 
serviceName="s:DoubleItService" endpointName="s:DoubleItCacheSymmetricPort" 
implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" 
wsdlLocation="org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl">
+        <jaxws:properties>
+            <entry key="ws-security.callback-handler" 
value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+            <entry key="ws-security.signature.crypto" value="bob.properties"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+    
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt"; 
id="CachePerProxySymmetric" 
address="http://localhost:${testutil.ports.Server}/DoubleItCachePerProxySymmetric";
 serviceName="s:DoubleItService" endpointName="s:DoubleItCacheSymmetricPort" 
implementor="org.apache.cxf.systest.ws.common.DoubleItImpl" 
wsdlLocation="org/apache/cxf/systest/ws/cache/DoubleItCache.wsdl">
+        <jaxws:properties>
+            <entry key="ws-security.callback-handler" 
value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+            <entry key="ws-security.signature.crypto" value="bob.properties"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+
+</beans>

Reply via email to