cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1300274 - in /cxf/branches/2.4.x-fixes: ./ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/
Date Tue, 13 Mar 2012 18:29:57 GMT
Author: dkulp
Date: Tue Mar 13 18:29:56 2012
New Revision: 1300274

URL: http://svn.apache.org/viewvc?rev=1300274&view=rev
Log:
Merged revisions 1300270 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

................
  r1300270 | dkulp | 2012-03-13 14:25:59 -0400 (Tue, 13 Mar 2012) | 10 lines
  
  Merged revisions 1300261 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1300261 | dkulp | 2012-03-13 14:04:05 -0400 (Tue, 13 Mar 2012) | 3 lines
  
    Use some reflection magic to allow code compiled with Jetty 7.5 to work
    with Jetty 7.6
  
  ........
................

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
    cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 13 18:29:56 2012
@@ -1,2 +1,2 @@
-/cxf/branches/2.5.x-fixes:1299092,1299637,1299725
+/cxf/branches/2.5.x-fixes:1299092,1299637,1299725,1300270
 /cxf/trunk:1298830,1299635,1299682

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=1300274&r1=1300273&r2=1300274&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Tue Mar 13 18:29:56 2012
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRes
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.security.CertificateConstraintsType;
 import org.apache.cxf.continuations.ContinuationProvider;
@@ -50,7 +51,9 @@ import org.apache.cxf.transport.https.Ce
 import org.apache.cxf.transports.http.QueryHandler;
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
 import org.apache.cxf.transports.http.StemMatchingQueryHandler;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.server.AsyncHttpConnection;
+import org.eclipse.jetty.server.BlockingHttpConnection;
 import org.eclipse.jetty.server.Request;
 
 public class JettyHTTPDestination extends AbstractHTTPDestination {
@@ -209,6 +212,15 @@ public class JettyHTTPDestination extend
                              HttpServletResponse resp) throws IOException {
         doService(servletContext, req, resp);
     }
+    
+    static AbstractConnection getConnectionForRequest(Request r) {
+        try {
+            return (AbstractConnection)r.getClass().getMethod("getConnection").invoke(r);
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+    
     protected void doService(ServletContext context,
                              HttpServletRequest req,
                              HttpServletResponse resp) throws IOException {
@@ -216,14 +228,18 @@ public class JettyHTTPDestination extend
             context = servletContext;
         }
         Request baseRequest = (req instanceof Request) 
-            ? (Request)req : HttpConnection.getCurrentConnection().getRequest();
+            ? (Request)req : getCurrentRequest();
             
         if (!"HEAD".equals(req.getMethod())) {
             //bug in Jetty with persistent connections that if a HEAD is
             //sent, a _head flag is never reset
-            HttpConnection c = baseRequest.getConnection();
+            AbstractConnection c = getConnectionForRequest(baseRequest);
             if (c != null) {
-                c.getGenerator().setHead(false);
+                if (c instanceof AsyncHttpConnection) {
+                    ((AsyncHttpConnection)c).getGenerator().setHead(false);
+                } else if (c instanceof BlockingHttpConnection) {
+                    ((BlockingHttpConnection)c).getGenerator().setHead(false);
+                }
             }
         }
         if (getServer().isSetRedirectURL()) {
@@ -296,7 +312,7 @@ public class JettyHTTPDestination extend
                                   final HttpServletResponse resp)
         throws IOException {
         Request baseRequest = (req instanceof Request) 
-            ? (Request)req : HttpConnection.getCurrentConnection().getRequest();
+            ? (Request)req : getCurrentRequest();
         
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Service http request on thread: " + Thread.currentThread());
@@ -359,4 +375,25 @@ public class JettyHTTPDestination extend
                       new JettyContinuationProvider(req, resp, inMessage));
         }
     }
+    
+    private AbstractConnection getCurrentConnection() {
+        Class<?> cls = AsyncHttpConnection.class.getSuperclass();
+        // AbstractHttpConnection on Jetty 7.6, HttpConnection on Jetty <=7.5
+        try {
+            return (AbstractConnection)ReflectionUtil
+                .setAccessible(cls.getMethod("getCurrentConnection")).invoke(null);
+        } catch (Exception e) {
+            //ignore
+        }
+        return null;
+    }
+    private Request getCurrentRequest() {
+        AbstractConnection con = getCurrentConnection();
+        if (con instanceof AsyncHttpConnection) {
+            return ((AsyncHttpConnection)con).getRequest();
+        } else if (con instanceof BlockingHttpConnection) {
+            return ((BlockingHttpConnection)con).getRequest();
+        }
+        return null;
+    }
 }

Modified: cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java?rev=1300274&r1=1300273&r2=1300274&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/CXFJettySslSocketConnector.java
Tue Mar 13 18:29:56 2012
@@ -28,6 +28,7 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.configuration.security.ClientAuthentication;
 import org.apache.cxf.configuration.security.FiltersType;
 import org.apache.cxf.transport.https.SSLUtils;
@@ -87,31 +88,31 @@ public class CXFJettySslSocketConnector 
      * configures an HTTP Destination.
      */
     protected void setClientAuthentication(ClientAuthentication clientAuth) {
-        getSslContextFactory().setWantClientAuth(true);
+        getCxfSslContextFactory().setWantClientAuth(true);
         if (clientAuth != null) {
             if (clientAuth.isSetWant()) {
-                getSslContextFactory().setWantClientAuth(clientAuth.isWant());
+                getCxfSslContextFactory().setWantClientAuth(clientAuth.isWant());
             }
             if (clientAuth.isSetRequired()) {
-                getSslContextFactory().setNeedClientAuth(clientAuth.isRequired());
+                getCxfSslContextFactory().setNeedClientAuth(clientAuth.isRequired());
             }
         }
     }
     
     protected void doStart() throws Exception {
         // setup the create SSLContext on the SSLContextFactory
-        getSslContextFactory().setSslContext(createSSLContext());
+        getCxfSslContextFactory().setSslContext(createSSLContext());
         super.doStart();
     }
     
     protected SSLContext createSSLContext() throws Exception  {
-        String proto = getSslContextFactory().getProtocol() == null
+        String proto = getCxfSslContextFactory().getProtocol() == null
             ? "TLS"
-                : getSslContextFactory().getProtocol();
+                : getCxfSslContextFactory().getProtocol();
  
-        SSLContext context = getSslContextFactory().getProvider() == null
+        SSLContext context = getCxfSslContextFactory().getProvider() == null
             ? SSLContext.getInstance(proto)
-                : SSLContext.getInstance(proto, getSslContextFactory().getProvider());
+                : SSLContext.getInstance(proto, getCxfSslContextFactory().getProvider());
             
         context.init(keyManagers, trustManagers, secureRandom);
 
@@ -122,8 +123,38 @@ public class CXFJettySslSocketConnector 
                     cipherSuitesFilter,
                     LOG, true);
         
-        getSslContextFactory().setExcludeCipherSuites(cs);
+        getCxfSslContextFactory().setExcludeCipherSuites(cs);
         
         return context;
     }
+    
+    public CxfSslContextFactory getCxfSslContextFactory() {
+        try {
+            Object o = getClass().getMethod("getSslContextFactory").invoke(this);
+            return ReflectionInvokationHandler.createProxyWrapper(o, CxfSslContextFactory.class);
+        } catch (Exception e) {
+            //ignore, the NPE is fine
+        }
+        
+        return null;
+    }
+    
+    interface CxfSslContextFactory {
+        void setExcludeCipherSuites(String ... cs);
+
+        String getProtocol();
+        
+        String getProvider();
+        
+        void setSslContext(SSLContext createSSLContext);
+
+        void setNeedClientAuth(boolean required);
+
+        void setWantClientAuth(boolean want);
+
+        void setProtocol(String secureSocketProtocol);
+
+        void setProvider(String jsseProvider);
+    }
+    
 }

Modified: cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java?rev=1300274&r1=1300273&r2=1300274&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
Tue Mar 13 18:29:56 2012
@@ -83,10 +83,11 @@ public final class JettySslConnectorFact
         con.setSecureRandom(tlsServerParameters.getSecureRandom());
         con.setClientAuthentication(
                 tlsServerParameters.getClientAuthentication());
-        con.getSslContextFactory().setProtocol(tlsServerParameters.getSecureSocketProtocol());
-        con.getSslContextFactory().setProvider(tlsServerParameters.getJsseProvider());
+        con.getCxfSslContextFactory().setProtocol(tlsServerParameters.getSecureSocketProtocol());
+        con.getCxfSslContextFactory().setProvider(tlsServerParameters.getJsseProvider());
         con.setCipherSuites(tlsServerParameters.getCipherSuites());
         con.setCipherSuitesFilter(tlsServerParameters.getCipherSuitesFilter());
     }
-    
+
+
 }



Mime
View raw message