cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r903761 - in /cxf/trunk/rt/transports: http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java
Date Wed, 27 Jan 2010 17:51:10 GMT
Author: dkulp
Date: Wed Jan 27 17:51:10 2010
New Revision: 903761

URL: http://svn.apache.org/viewvc?rev=903761&view=rev
Log:
[CXF-2633] Fix logging of enabled cipher suites with Jetty https server

Modified:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java?rev=903761&r1=903760&r2=903761&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
Wed Jan 27 17:51:10 2010
@@ -19,12 +19,17 @@
 package org.apache.cxf.transport.https_jetty;
 
 
+import java.io.IOException;
+import java.net.ServerSocket;
 import java.security.SecureRandom;
+import java.util.Arrays;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
 import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.TrustManager;
 
@@ -130,5 +135,13 @@
         setExcludeCipherSuites(cs);
         return con;
     }
+    protected ServerSocket newServerSocket(String host, int port, int backlog) throws IOException
{
+        ServerSocket sock = super.newServerSocket(host, port, backlog);
+        if (sock instanceof SSLServerSocket && LOG.isLoggable(Level.INFO)) {
+            SSLServerSocket sslSock = (SSLServerSocket)sock;
+            LOG.log(Level.INFO, "CIPHERSUITES_SET", Arrays.asList(sslSock.getEnabledCipherSuites()));
+        }
+        return sock;
+    }
 
 }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java?rev=903761&r1=903760&r2=903761&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java
Wed Jan 27 17:51:10 2010
@@ -355,7 +355,7 @@
                                            Logger log, boolean exclude) {
         String[] cipherSuites = null;
         if (!(cipherSuitesList == null || cipherSuitesList.isEmpty())) {
-            cipherSuites = getCiphersFromList(cipherSuitesList, log);
+            cipherSuites = getCiphersFromList(cipherSuitesList, log, exclude);
         } else {
             LogUtils.log(log, Level.INFO, "CIPHERSUITES_NOT_SET");
             if (filters == null) {
@@ -396,9 +396,9 @@
                          "CIPHERSUITES_EXCLUDED",
                          excludedCipherSuites);
             if (exclude) {
-                cipherSuites = getCiphersFromList(excludedCipherSuites, log);
+                cipherSuites = getCiphersFromList(excludedCipherSuites, log, exclude);
             } else {
-                cipherSuites = getCiphersFromList(filteredCipherSuites, log);
+                cipherSuites = getCiphersFromList(filteredCipherSuites, log, exclude);
             }
         } 
         return cipherSuites;
@@ -435,19 +435,21 @@
     }
     
     private static String[] getCiphersFromList(List<String> cipherSuitesList,
-                                               Logger log) {
+                                               Logger log, 
+                                               boolean exclude) {
         int numCipherSuites = cipherSuitesList.size();
-        String[] cipherSuites = new String[numCipherSuites];
-        String ciphsStr = null;
-        for (int i = 0; i < numCipherSuites; i++) {
-            cipherSuites[i] = cipherSuitesList.get(i);
-            if (ciphsStr == null) {
-                ciphsStr = cipherSuites[i];
-            } else {
-                ciphsStr += ", " + cipherSuites[i];
+        String[] cipherSuites = cipherSuitesList.toArray(new String[numCipherSuites]);
+        if (log.isLoggable(exclude ? Level.FINE : Level.INFO)) {
+            StringBuilder ciphsStr = new StringBuilder();
+            for (String s : cipherSuites) {
+                if (ciphsStr.length() != 0) {
+                    ciphsStr.append(", ");
+                }
+                ciphsStr.append(s);
             }
+            LogUtils.log(log, exclude ? Level.FINE : Level.INFO, 
+                exclude ? "CIPHERSUITES_EXCLUDED" : "CIPHERSUITES_SET", ciphsStr.toString());
           
         }
-        LogUtils.log(log, Level.INFO, "CIPHERSUITES_SET", ciphsStr);
         return cipherSuites;
     }
     



Mime
View raw message