cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/4] cxf git commit: Fixing failing test
Date Wed, 17 Dec 2014 16:41:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5b017782e -> 593525139


Fixing failing test


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

Branch: refs/heads/master
Commit: 593525139909e081ae809278d301688c0ba03697
Parents: fb9d265
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Dec 17 16:40:24 2014 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Dec 17 16:40:34 2014 +0000

----------------------------------------------------------------------
 .../security/AllowAllHostnameVerifier.java      | 47 ++++++++++++++++++++
 .../jaxrs/security/JAXRS20HttpsBookTest.java    |  5 +--
 2 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/59352513/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AllowAllHostnameVerifier.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AllowAllHostnameVerifier.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AllowAllHostnameVerifier.java
new file mode 100644
index 0000000..f440240
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AllowAllHostnameVerifier.java
@@ -0,0 +1,47 @@
+/**
+ * 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.jaxrs.security;
+
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
+
+/**
+ * Allow all hostnames. This is only suitable for use in testing, and NOT in production!

+ */
+class AllowAllHostnameVerifier implements javax.net.ssl.HostnameVerifier {
+
+    @Override
+    public boolean verify(String host, SSLSession session) {
+        try {
+            Certificate[] certs = session.getPeerCertificates();
+            if (certs != null && certs[0] instanceof X509Certificate) {
+                return true;
+            }
+            return false;
+        } catch (SSLException e) {
+            return false;
+        }
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/59352513/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRS20HttpsBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRS20HttpsBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRS20HttpsBookTest.java
index 87fdd62..818749c 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRS20HttpsBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRS20HttpsBookTest.java
@@ -33,7 +33,6 @@ import javax.ws.rs.core.MediaType;
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.systest.jaxrs.Book;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.apache.cxf.transport.https.CertificateHostnameVerifier;
 import org.apache.cxf.transport.https.SSLUtils;
 
 import org.junit.BeforeClass;
@@ -58,7 +57,7 @@ public class JAXRS20HttpsBookTest extends AbstractBusClientServerTestBase
{
                                        "password");
         
         builder.trustStore(trustStore);
-        builder.hostnameVerifier(CertificateHostnameVerifier.ALLOW_ALL);
+        builder.hostnameVerifier(new AllowAllHostnameVerifier());
         
         KeyStore keyStore = loadStore("src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks",
             "password");
@@ -79,7 +78,7 @@ public class JAXRS20HttpsBookTest extends AbstractBusClientServerTestBase
{
         SSLContext sslContext = createSSLContext();
         builder.sslContext(sslContext);
         
-        builder.hostnameVerifier(CertificateHostnameVerifier.ALLOW_ALL);
+        builder.hostnameVerifier(new AllowAllHostnameVerifier());
         
         
         Client client = builder.build();


Mime
View raw message