Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes dc5025766 -> 8dda906e3


Adding a TLS test for an expired cert

# Conflicts:
#       
systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java


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

Branch: refs/heads/3.0.x-fixes
Commit: 02d6bdbf3079d8dfbef1dad5e7d5a9514dd0ac34
Parents: dc50257
Author: Colm O hEigeartaigh <cohei...@apache.org>
Authored: Tue Apr 5 12:46:26 2016 +0100
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Tue Apr 5 14:04:50 2016 +0100

----------------------------------------------------------------------
 .../https/ciphersuites/CipherSuitesTest.java    |  39 +++++++++++++++++++
 .../src/test/resources/keys/wss40exp.jks        | Bin 0 -> 3941 bytes
 .../src/test/resources/keys/wss40expCA.jks      | Bin 0 -> 858 bytes
 .../ciphersuites-client-expired-cert.xml        |  37 ++++++++++++++++++
 .../https/ciphersuites/ciphersuites-server.xml  |  28 +++++++++++++
 5 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/02d6bdbf/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
----------------------------------------------------------------------
diff --git 
a/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
 
b/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
index 13257f9..f253618 100644
--- 
a/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
+++ 
b/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
@@ -73,6 +73,15 @@ public class CipherSuitesTest extends 
AbstractBusClientServerTestBase {
         UNRESTRICTED_POLICIES_INSTALLED = ok;
     }
     
+<<<<<<< HEAD
+=======
+    static final String PORT = allocatePort(CipherSuitesServer.class);
+    static final String PORT2 = allocatePort(CipherSuitesServer.class, 2);
+    static final String PORT3 = allocatePort(CipherSuitesServer.class, 3);
+    static final String PORT4 = allocatePort(CipherSuitesServer.class, 4);
+    static final String PORT5 = allocatePort(CipherSuitesServer.class, 5);
+    
+>>>>>>> 3235f4b... Adding a TLS test for an expired cert
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -620,6 +629,36 @@ public class CipherSuitesTest extends 
AbstractBusClientServerTestBase {
         bus.shutdown(true);
     }
     
+    // Test an expired cert
+    @org.junit.Test
+    public void testExpiredCert() throws Exception {
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = 
CipherSuitesTest.class.getResource("ciphersuites-client-expired-cert.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        URL url = SOAPService.WSDL_LOCATION;
+        SOAPService service = new SOAPService(url, SOAPService.SERVICE);
+        assertNotNull("Service is null", service);   
+        final Greeter port = service.getHttpsPort();
+        assertNotNull("Port is null", port);
+        
+        updateAddressPort(port, PORT5);
+        
+        try {
+            port.greetMe("Kitty");
+            fail("Failure expected on not being able to negotiate a cipher 
suite");
+        } catch (Exception ex) {
+            // expected
+        }
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
     private static class NoOpX509TrustManager implements X509TrustManager {
 
         public NoOpX509TrustManager() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/02d6bdbf/systests/transports/src/test/resources/keys/wss40exp.jks
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/keys/wss40exp.jks 
b/systests/transports/src/test/resources/keys/wss40exp.jks
new file mode 100644
index 0000000..1ee7be7
Binary files /dev/null and 
b/systests/transports/src/test/resources/keys/wss40exp.jks differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/02d6bdbf/systests/transports/src/test/resources/keys/wss40expCA.jks
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/keys/wss40expCA.jks 
b/systests/transports/src/test/resources/keys/wss40expCA.jks
new file mode 100644
index 0000000..886d85c
Binary files /dev/null and 
b/systests/transports/src/test/resources/keys/wss40expCA.jks differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/02d6bdbf/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
----------------------------------------------------------------------
diff --git 
a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
 
b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
new file mode 100644
index 0000000..0e92933
--- /dev/null
+++ 
b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
@@ -0,0 +1,37 @@
+<?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>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    <http:conduit name="https://localhost:.*";>
+        <http:tlsClientParameters disableCNCheck="true" 
secureSocketProtocol="TLSv1.2">
+            <sec:trustManagers>
+                <sec:keyStore type="jks" password="security" 
resource="keys/wss40expCA.jks"/>
+            </sec:trustManagers>
+            <sec:cipherSuites>
+                
<sec:cipherSuite>TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256</sec:cipherSuite>
+            </sec:cipherSuites>
+        </http:tlsClientParameters>
+    </http:conduit>
+</beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/02d6bdbf/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
----------------------------------------------------------------------
diff --git 
a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
 
b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
index e5b382e..83e6c3f 100644
--- 
a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
+++ 
b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
@@ -120,4 +120,32 @@
                      
address="https://localhost:${testutil.ports.CipherSuitesServer.4}/SoapContext/HttpsPort";
 
                      serviceName="s:SOAPService" 
                      endpointName="e:HttpsPort" 
depends-on="aes-explicit-tls-settings"/>
+                     
+    <httpj:engine-factory id="expired-cert-tls-settings">
+        <httpj:engine port="${testutil.ports.CipherSuitesServer.5}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="security">
+                    <sec:keyStore type="jks" password="security" 
resource="keys/wss40exp.jks"/>
+                </sec:keyManagers>
+                <sec:clientAuthentication want="false" required="false"/>
+                <sec:cipherSuitesFilter>
+                    <sec:include>.*_WITH_AES_.*</sec:include>
+                </sec:cipherSuitesFilter>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+    
+    <jaxws:endpoint xmlns:e="http://apache.org/hello_world/services"; 
+                     xmlns:s="http://apache.org/hello_world/services"; 
+                     id="AESExpiredCertTLSServer" 
+                     implementor="org.apache.cxf.systest.http.GreeterImpl" 
+                     
address="https://localhost:${testutil.ports.CipherSuitesServer.5}/SoapContext/HttpsPort";
 
+                     serviceName="s:SOAPService" 
+                     endpointName="e:HttpsPort" 
depends-on="expired-cert-tls-settings">
+        <jaxws:inInterceptors>
+            <bean 
class="org.apache.cxf.systest.https.ciphersuites.CipherSuiteChecker">
+                <property name="requiredAlgorithm" value="AES"/>
+            </bean>
+        </jaxws:inInterceptors>
+    </jaxws:endpoint>
 </beans>

Reply via email to