activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1187817 - in /activemq/trunk: ./ activemq-optional/src/main/java/org/apache/activemq/transport/http/ activemq-optional/src/main/java/org/apache/activemq/transport/https/ activemq-optional/src/main/java/org/apache/activemq/transport/ws/
Date Sat, 22 Oct 2011 22:22:52 GMT
Author: tabish
Date: Sat Oct 22 22:22:51 2011
New Revision: 1187817

URL: http://svn.apache.org/viewvc?rev=1187817&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3504

Move to the latest Jetty version that still allows the Web Console to work.  This version
has the latest websocket updates that jetty has to offer.

Modified:
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/Krb5AndCertsSslSocketConnector.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompServlet.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompSocket.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java
Sat Oct 22 22:22:51 2011
@@ -96,5 +96,4 @@ public class HttpTransportFactory extend
 
         return transport;
     }
-
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportServer.java
Sat Oct 22 22:22:51 2011
@@ -26,17 +26,11 @@ import org.apache.activemq.transport.xst
 import org.apache.activemq.util.ServiceStopper;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.bio.SocketConnector;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.server.session.SessionHandler;
-import org.eclipse.jetty.servlet.ServletHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.servlet.ServletMapping;
-
-/**
- * 
- */
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+
 public class HttpTransportServer extends TransportServerSupport {
+
     private URI bindAddress;
     private TextWireFormat wireFormat;
     private Server server;
@@ -78,39 +72,17 @@ public class HttpTransportServer extends
     protected void doStart() throws Exception {
         server = new Server();
         if (connector == null) {
-            connector = new SocketConnector();
+            connector = new SelectChannelConnector();
         }
         connector.setHost(bindAddress.getHost());
         connector.setPort(bindAddress.getPort());
         connector.setServer(server);
-        server.setConnectors(new Connector[] {
-            connector
-        });
-
-        ContextHandler contextHandler = new ContextHandler();
-        contextHandler.setContextPath("/");
-        contextHandler.setServer(server);
-        server.setHandler(contextHandler);
-
-        SessionHandler sessionHandler = new SessionHandler();
-        contextHandler.setHandler(sessionHandler);
-
-        ServletHandler servletHandler = new ServletHandler();
-        sessionHandler.setHandler(servletHandler);
-
-        ServletHolder holder = new ServletHolder();
-        holder.setName("httpTunnel");
-        holder.setClassName(HttpTunnelServlet.class.getName());
-        servletHandler.setServlets(new ServletHolder[] {
-            holder
-        });
-
-        ServletMapping mapping = new ServletMapping();
-        mapping.setServletName("httpTunnel");
-        mapping.setPathSpec("/*");
-        servletHandler.setServletMappings(new ServletMapping[] {
-            mapping
-        });
+        server.addConnector(connector);
+
+        ServletContextHandler contextHandler =
+            new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY);
+
+        contextHandler.addServlet(HttpTunnelServlet.class, "/");
 
         contextHandler.setAttribute("acceptListener", getAcceptListener());
         contextHandler.setAttribute("wireFormat", getWireFormat());
@@ -130,5 +102,4 @@ public class HttpTransportServer extends
     public InetSocketAddress getSocketAddress() {
         return null;
     }
-
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java
Sat Oct 22 22:22:51 2011
@@ -96,15 +96,11 @@ public class HttpTunnelServlet extends H
             packet = (Command)transportChannel.getQueue().poll(requestTimeout, TimeUnit.MILLISECONDS);
 
             DataOutputStream stream = new DataOutputStream(response.getOutputStream());
-            // while( packet !=null ) {
             wireFormat.marshal(packet, stream);
             count++;
-            // packet = (Command) transportChannel.getQueue().poll(0,
-            // TimeUnit.MILLISECONDS);
-            // }
-
         } catch (InterruptedException ignore) {
         }
+
         if (count == 0) {
             response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT);
         }
@@ -137,7 +133,6 @@ public class HttpTunnelServlet extends H
     }
 
     private boolean canProcessWireFormatVersion(int version) {
-        // TODO:
         return true;
     }
 

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportFactory.java
Sat Oct 22 22:22:51 2011
@@ -33,15 +33,13 @@ import org.apache.activemq.wireformat.Wi
 
 /**
  * Factory of HTTPS based transports
- * 
- * 
  */
 public class HttpsTransportFactory extends HttpTransportFactory {
-    
+
     public TransportServer doBind(String brokerId, URI location) throws IOException {
         return doBind(location);
     }
-    
+
     public TransportServer doBind(URI location) throws IOException {
         try {
             Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
@@ -52,7 +50,7 @@ public class HttpsTransportFactory exten
         } catch (URISyntaxException e) {
             throw IOExceptionSupport.create(e);
         }
-        
+
     }
 
     protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException
{

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/HttpsTransportServer.java
Sat Oct 22 22:22:51 2011
@@ -32,40 +32,40 @@ public class HttpsTransportServer extend
     private String protocol;
     private String auth;
 
-	 public HttpsTransportServer(URI uri, HttpsTransportFactory factory) {
+     public HttpsTransportServer(URI uri, HttpsTransportFactory factory) {
         super(uri, factory);
     }
 
     public void doStart() throws Exception {
-    	Krb5AndCertsSslSocketConnector sslConnector = new Krb5AndCertsSslSocketConnector();
-    	
-    	if(auth != null){
-        	sslConnector.setMode(auth);
-        }
-    	
-        sslConnector.setKeystore(keyStore);
-        sslConnector.setPassword(keyStorePassword);
+        Krb5AndCertsSslSocketConnector sslConnector = new Krb5AndCertsSslSocketConnector();
+
+        if(auth != null){
+            sslConnector.setMode(auth);
+        }
+
+        sslConnector.getSslContextFactory().setKeyStore(keyStore);
+        sslConnector.getSslContextFactory().setKeyStorePassword(keyStorePassword);
         // if the keyPassword hasn't been set, default it to the
         // key store password
         if (keyPassword == null) {
-            sslConnector.setKeyPassword(keyStorePassword);
+            sslConnector.getSslContextFactory().setKeyStorePassword(keyStorePassword);
         }
         if (keyStoreType != null) {
-            sslConnector.setKeystoreType(keyStoreType);
+            sslConnector.getSslContextFactory().setKeyStoreType(keyStoreType);
         }
         if (secureRandomCertficateAlgorithm != null) {
-            sslConnector.setSecureRandomAlgorithm(secureRandomCertficateAlgorithm);
+            sslConnector.getSslContextFactory().setSecureRandomAlgorithm(secureRandomCertficateAlgorithm);
         }
         if (keyCertificateAlgorithm != null) {
-            sslConnector.setSslKeyManagerFactoryAlgorithm(keyCertificateAlgorithm);
+            sslConnector.getSslContextFactory().setSslKeyManagerFactoryAlgorithm(keyCertificateAlgorithm);
         }
         if (trustCertificateAlgorithm != null) {
-            sslConnector.setSslTrustManagerFactoryAlgorithm(trustCertificateAlgorithm);
+            sslConnector.getSslContextFactory().setTrustManagerFactoryAlgorithm(trustCertificateAlgorithm);
         }
         if (protocol != null) {
-            sslConnector.setProtocol(protocol);
+            sslConnector.getSslContextFactory().setProtocol(protocol);
         }
-        
+
         setConnector(sslConnector);
 
         super.doStart();
@@ -139,17 +139,17 @@ public class HttpsTransportServer extend
     }
 
     /**
-	 * @return the auth
-	 */
-	public String getAuth() {
-		return auth;
-	}
-
-	/**
-	 * @param auth the auth to set
-	 */
-	public void setAuth(String auth) {
-		this.auth = auth;
-	}
+     * @return the auth
+     */
+    public String getAuth() {
+        return auth;
+    }
+
+    /**
+     * @param auth the auth to set
+     */
+    public void setAuth(String auth) {
+        this.auth = auth;
+    }
 
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/Krb5AndCertsSslSocketConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/Krb5AndCertsSslSocketConnector.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/Krb5AndCertsSslSocketConnector.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/https/Krb5AndCertsSslSocketConnector.java
Sat Oct 22 22:22:51 2011
@@ -5,9 +5,9 @@
  * 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
@@ -17,8 +17,10 @@
 package org.apache.activemq.transport.https;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.ServerSocket;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
 import java.security.Principal;
 import java.util.List;
 import java.util.Collections;
@@ -26,146 +28,169 @@ import java.util.Random;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLServerSocket;
-import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocket;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.eclipse.jetty.http.HttpSchemes;
+import org.eclipse.jetty.http.ssl.SslContextFactory;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.ssl.ServletSSL;
 import org.eclipse.jetty.server.ssl.SslSocketConnector;
 
 /**
- * Extend Jetty's {@link SslSocketConnector} to optionally also provide 
- * Kerberos5ized SSL sockets.  The only change in behavior from superclass
- * is that we no longer honor requests to turn off NeedAuthentication when
- * running with Kerberos support.
+ * Extend Jetty's {@link SslSocketConnector} to optionally also provide
+ * Kerberos5ized SSL sockets. The only change in behavior from superclass is
+ * that we no longer honor requests to turn off NeedAuthentication when running
+ * with Kerberos support.
  */
 public class Krb5AndCertsSslSocketConnector extends SslSocketConnector {
-  public static final List<String> KRB5_CIPHER_SUITES = 
-    Collections.unmodifiableList(Collections.singletonList(
-          "TLS_KRB5_WITH_3DES_EDE_CBC_SHA"));
-  static {
-    System.setProperty("https.cipherSuites", KRB5_CIPHER_SUITES.get(0));
-  }
-  
-  private static final Logger LOG = LoggerFactory.getLogger(Krb5AndCertsSslSocketConnector.class);
-
-  private static final String REMOTE_PRINCIPAL = "remote_principal";
-
-  public enum MODE {KRB, CERTS, BOTH} // Support Kerberos, certificates or both?
-
-  private boolean useKrb;
-  private boolean useCerts;
-
-  public Krb5AndCertsSslSocketConnector() {
-	  // By default, stick to cert based authentication
-    super();
-    useKrb = false;
-    useCerts = true;
-    setPasswords();
-  }
-  
-  public void setMode(String mode) {
-    useKrb = mode == MODE.KRB.toString() || mode == MODE.BOTH.toString();
-    useCerts = mode == MODE.CERTS.toString() || mode == MODE.BOTH.toString();
-    logIfDebug("useKerb = " + useKrb + ", useCerts = " + useCerts);
-  }
-
-  // If not using Certs, set passwords to random gibberish or else
-  // Jetty will actually prompt the user for some.
-  private void setPasswords() {
-   if(!useCerts) {
-     Random r = new Random();
-     System.setProperty("jetty.ssl.password", String.valueOf(r.nextLong()));
-     System.setProperty("jetty.ssl.keypassword", String.valueOf(r.nextLong()));
-   }
-  }
-  
-  @Override
-  protected SSLServerSocketFactory createFactory() throws Exception {
-    if(useCerts)
-      return super.createFactory();
-    
-    SSLContext context = super.getProvider()==null
-       ? SSLContext.getInstance(super.getProtocol())
-        :SSLContext.getInstance(super.getProtocol(), super.getProvider());
-    context.init(null, null, null);
-    
-    System.err.println("Creating socket factory");
-    return context.getServerSocketFactory();
-  }
-  
-  /* (non-Javadoc)
-   * @see org.mortbay.jetty.security.SslSocketConnector#newServerSocket(java.lang.String,
int, int)
-   */
-  @Override
-  protected ServerSocket newServerSocket(String host, int port, int backlog)
-      throws IOException {
-	  System.err.println("Creating new KrbServerSocket for: " + host);
-    logIfDebug("Creating new KrbServerSocket for: " + host);
-    SSLServerSocket ss = null;
-    
-    if(useCerts) // Get the server socket from the SSL super impl
-      ss = (SSLServerSocket)super.newServerSocket(host, port, backlog);
-    else { // Create a default server socket
-      try {
-        ss = (SSLServerSocket)(host == null 
-         ? createFactory().createServerSocket(port, backlog) :
-           createFactory().createServerSocket(port, backlog, InetAddress.getByName(host)));
-      } catch (Exception e)
-      {
-        LOG.warn("Could not create KRB5 Listener", e);
-        throw new IOException("Could not create KRB5 Listener: " + e.toString());
-      }
-    }
-    
-    // Add Kerberos ciphers to this socket server if needed.
-    if(useKrb) {
-      ss.setNeedClientAuth(true);
-      String [] combined;
-      if(useCerts) { // combine the cipher suites
-        String[] certs = ss.getEnabledCipherSuites();
-        combined = new String[certs.length + KRB5_CIPHER_SUITES.size()];
-        System.arraycopy(certs, 0, combined, 0, certs.length);
-        System.arraycopy(KRB5_CIPHER_SUITES.toArray(new String[0]), 0, combined,
-              certs.length, KRB5_CIPHER_SUITES.size());
-      } else { // Just enable Kerberos auth
-        combined = KRB5_CIPHER_SUITES.toArray(new String[0]);
-      }
-      
-      ss.setEnabledCipherSuites(combined);
-    }
-    System.err.println("New socket created");
-    return ss;
-  };
-
-  @Override
-  public void customize(EndPoint endpoint, Request request) throws IOException {
-    if(useKrb) { // Add Kerberos-specific info
-      SSLSocket sslSocket = (SSLSocket)endpoint.getTransport();
-      Principal remotePrincipal = sslSocket.getSession().getPeerPrincipal();
-      logIfDebug("Remote principal = " + remotePrincipal);
-      request.setScheme(HttpSchemes.HTTPS);
-      request.setAttribute(REMOTE_PRINCIPAL, remotePrincipal);
-      
-      if(!useCerts) { // Add extra info that would have been added by super
-        String cipherSuite = sslSocket.getSession().getCipherSuite();
-        Integer keySize = Integer.valueOf(ServletSSL.deduceKeyLength(cipherSuite));;
-        
-        request.setAttribute("javax.servlet.request.cipher_suite", cipherSuite);
-        request.setAttribute("javax.servlet.request.key_size", keySize);
-      } 
-    }
-    
-    if(useCerts) super.customize(endpoint, request);
-    System.err.println();
-  }
-  
-  private void logIfDebug(String s) {
-    if(LOG.isDebugEnabled())
-      LOG.debug(s);
-  }
+    public static final List<String> KRB5_CIPHER_SUITES = Collections.unmodifiableList(Collections.singletonList("TLS_KRB5_WITH_3DES_EDE_CBC_SHA"));
+    static {
+        System.setProperty("https.cipherSuites", KRB5_CIPHER_SUITES.get(0));
+    }
+
+    private static final Logger LOG = LoggerFactory.getLogger(Krb5AndCertsSslSocketConnector.class);
+
+    private static final String REMOTE_PRINCIPAL = "remote_principal";
+
+    public enum MODE {
+        KRB, CERTS, BOTH
+    } // Support Kerberos, certificates or both?
+
+    private boolean useKrb;
+    private boolean useCerts;
+
+    public Krb5AndCertsSslSocketConnector() {
+        // By default, stick to cert based authentication
+        super();
+        useKrb = false;
+        useCerts = true;
+        setPasswords();
+    }
+
+    public void setMode(String mode) {
+        useKrb = mode == MODE.KRB.toString() || mode == MODE.BOTH.toString();
+        useCerts = mode == MODE.CERTS.toString() || mode == MODE.BOTH.toString();
+        logIfDebug("useKerb = " + useKrb + ", useCerts = " + useCerts);
+    }
+
+    // If not using Certs, set passwords to random gibberish or else
+    // Jetty will actually prompt the user for some.
+    private void setPasswords() {
+        if (!useCerts) {
+            Random r = new Random();
+            System.setProperty("jetty.ssl.password", String.valueOf(r.nextLong()));
+            System.setProperty("jetty.ssl.keypassword", String.valueOf(r.nextLong()));
+        }
+    }
+
+    // @Override
+    // protected SSLServerSocketFactory createFactory() throws Exception {
+    // if(useCerts)
+    // return super.createFactory();
+    //
+    // SSLContext context = super.getProvider()==null
+    // ? SSLContext.getInstance(super.getProtocol())
+    // :SSLContext.getInstance(super.getProtocol(), super.getProvider());
+    // context.init(null, null, null);
+    //
+    // System.err.println("Creating socket factory");
+    // return context.getServerSocketFactory();
+    // }
+
+    @Override
+    public SslContextFactory getSslContextFactory() {
+        final SslContextFactory factory = super.getSslContextFactory();
+
+        if (useCerts) {
+            return factory;
+        }
+
+        try {
+            SSLContext context = factory.getProvider() == null ? SSLContext.getInstance(factory.getProtocol())
: SSLContext.getInstance(factory.getProtocol(),
+                factory.getProvider());
+            context.init(null, null, null);
+            factory.setSslContext(context);
+        } catch (NoSuchAlgorithmException e) {
+        } catch (NoSuchProviderException e) {
+        } catch (KeyManagementException e) {
+        }
+
+        return factory;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.mortbay.jetty.security.SslSocketConnector#newServerSocket(java.lang
+     * .String, int, int)
+     */
+    @Override
+    protected ServerSocket newServerSocket(String host, int port, int backlog) throws IOException
{
+        System.err.println("Creating new KrbServerSocket for: " + host);
+        logIfDebug("Creating new KrbServerSocket for: " + host);
+        SSLServerSocket ss = null;
+
+        if (useCerts) // Get the server socket from the SSL super impl
+            ss = (SSLServerSocket) super.newServerSocket(host, port, backlog);
+        else { // Create a default server socket
+            try {
+                ss = (SSLServerSocket) super.newServerSocket(host, port, backlog);
+            } catch (Exception e) {
+                LOG.warn("Could not create KRB5 Listener", e);
+                throw new IOException("Could not create KRB5 Listener: " + e.toString());
+            }
+        }
+
+        // Add Kerberos ciphers to this socket server if needed.
+        if (useKrb) {
+            ss.setNeedClientAuth(true);
+            String[] combined;
+            if (useCerts) { // combine the cipher suites
+                String[] certs = ss.getEnabledCipherSuites();
+                combined = new String[certs.length + KRB5_CIPHER_SUITES.size()];
+                System.arraycopy(certs, 0, combined, 0, certs.length);
+                System.arraycopy(KRB5_CIPHER_SUITES.toArray(new String[0]), 0, combined,
certs.length, KRB5_CIPHER_SUITES.size());
+            } else { // Just enable Kerberos auth
+                combined = KRB5_CIPHER_SUITES.toArray(new String[0]);
+            }
+
+            ss.setEnabledCipherSuites(combined);
+        }
+        System.err.println("New socket created");
+        return ss;
+    };
+
+    @Override
+    public void customize(EndPoint endpoint, Request request) throws IOException {
+        if (useKrb) { // Add Kerberos-specific info
+            SSLSocket sslSocket = (SSLSocket) endpoint.getTransport();
+            Principal remotePrincipal = sslSocket.getSession().getPeerPrincipal();
+            logIfDebug("Remote principal = " + remotePrincipal);
+            request.setScheme(HttpSchemes.HTTPS);
+            request.setAttribute(REMOTE_PRINCIPAL, remotePrincipal);
+
+            if (!useCerts) { // Add extra info that would have been added by
+                             // super
+                String cipherSuite = sslSocket.getSession().getCipherSuite();
+                Integer keySize = Integer.valueOf(ServletSSL.deduceKeyLength(cipherSuite));
+                ;
+
+                request.setAttribute("javax.servlet.request.cipher_suite", cipherSuite);
+                request.setAttribute("javax.servlet.request.key_size", keySize);
+            }
+        }
+
+        if (useCerts)
+            super.customize(endpoint, request);
+        System.err.println();
+    }
+
+    private void logIfDebug(String s) {
+        if (LOG.isDebugEnabled())
+            LOG.debug(s);
+    }
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompServlet.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompServlet.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompServlet.java
Sat Oct 22 22:22:51 2011
@@ -28,16 +28,13 @@ import org.eclipse.jetty.websocket.WebSo
 import org.eclipse.jetty.websocket.WebSocketServlet;
 
 /**
- * 
  * Handle connection upgrade requests and creates web sockets
- *
  */
 public class StompServlet extends WebSocketServlet {
-
     private static final long serialVersionUID = -4716657876092884139L;
-    
+
     private TransportAcceptListener listener;
-    
+
     public void init() throws ServletException {
         super.init();
         listener = (TransportAcceptListener)getServletContext().getAttribute("acceptListener");
@@ -46,15 +43,15 @@ public class StompServlet extends WebSoc
         }
     }
 
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
+    protected void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException ,IOException  {
         getServletContext().getNamedDispatcher("default").forward(request,response);
     }
-    
-    protected WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+
+    @Override
+    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
         StompSocket socket = new StompSocket();
         listener.onAccept(socket);
         return socket;
     }
-    
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompSocket.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompSocket.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompSocket.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/StompSocket.java
Sat Oct 22 22:22:51 2011
@@ -32,22 +32,24 @@ import org.apache.activemq.util.ServiceS
 import org.eclipse.jetty.websocket.WebSocket;
 
 /**
- *
  * Implements web socket and mediates between servlet and the broker
- *
  */
-class StompSocket extends TransportSupport implements WebSocket, StompTransport {
-    Outbound outbound;
+class StompSocket extends TransportSupport implements WebSocket.OnTextMessage, StompTransport
{
+    Connection outbound;
     ProtocolConverter protocolConverter = new ProtocolConverter(this, null);
     StompWireFormat wireFormat = new StompWireFormat();
 
-    public void onConnect(Outbound outbound) {
-        this.outbound=outbound;
+    @Override
+    public void onOpen(Connection connection) {
+        this.outbound = connection;
     }
 
-    public void onMessage(byte frame, byte[] data,int offset, int length) {}
+    @Override
+    public void onClose(int closeCode, String message) {
+    }
 
-    public void onMessage(byte frame, String data) {
+    @Override
+    public void onMessage(String data) {
         try {
             protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
         } catch (Exception e) {
@@ -55,23 +57,25 @@ class StompSocket extends TransportSuppo
         }
     }
 
-    public void onDisconnect() {
-    }
-
+    @Override
     protected void doStart() throws Exception {
     }
 
+    @Override
     protected void doStop(ServiceStopper stopper) throws Exception {
     }
 
+    @Override
     public int getReceiveCounter() {
         return 0;
     }
 
+    @Override
     public String getRemoteAddress() {
         return "StompSocket_" + this.hashCode();
     }
 
+    @Override
     public void oneway(Object command) throws IOException {
         try {
             protocolConverter.onActiveMQCommand((Command)command);
@@ -80,16 +84,19 @@ class StompSocket extends TransportSuppo
         }
     }
 
+    @Override
     public X509Certificate[] getPeerCertificates() {
         return null;
     }
 
+    @Override
     public void sendToActiveMQ(Command command) {
         doConsume(command);
     }
 
+    @Override
     public void sendToStomp(StompFrame command) throws IOException {
-        outbound.sendMessage(WebSocket.SENTINEL_FRAME, command.format());
+        outbound.sendMessage(command.format());
     }
 
     @Override

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java
Sat Oct 22 22:22:51 2011
@@ -26,8 +26,8 @@ import org.apache.activemq.util.ServiceS
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.bio.SocketConnector;
-import org.eclipse.jetty.server.handler.ContextHandler;
 import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.servlet.ServletMapping;
@@ -37,11 +37,11 @@ import org.eclipse.jetty.servlet.Servlet
  *
  */
 public class WSTransportServer extends TransportServerSupport {
-    
+
     private URI bindAddress;
     private Server server;
     private Connector connector;
-    
+
     public WSTransportServer(URI location) {
         super(location);
         this.bindAddress = location;
@@ -57,8 +57,8 @@ public class WSTransportServer extends T
         server.setConnectors(new Connector[] {
                 connector
         });
-        
-        ContextHandler contextHandler = new ContextHandler();
+
+        ServletContextHandler contextHandler = new ServletContextHandler();
         contextHandler.setContextPath("/");
         contextHandler.setServer(server);
         server.setHandler(contextHandler);
@@ -68,7 +68,7 @@ public class WSTransportServer extends T
 
         ServletHandler servletHandler = new ServletHandler();
         sessionHandler.setHandler(servletHandler);
-        
+
         ServletHolder holder = new ServletHolder();
         holder.setName("WSStomp");
         holder.setClassName(StompServlet.class.getName());
@@ -84,7 +84,7 @@ public class WSTransportServer extends T
         });
 
         contextHandler.setAttribute("acceptListener", getAcceptListener());
-        
+
         server.start();
     }
 

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=1187817&r1=1187816&r2=1187817&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Sat Oct 22 22:22:51 2011
@@ -67,7 +67,7 @@
     <hsqldb-version>1.7.2.2</hsqldb-version>
     <jasypt-version>1.8</jasypt-version>
     <jdom-version>1.0</jdom-version>
-    <jetty-version>7.1.6.v20100715</jetty-version>
+    <jetty-version>7.5.1.v20110908</jetty-version>
     <jsp-version>2.1.v20100127</jsp-version>
     <jstl-version>1.1.2</jstl-version>
     <jettison-version>1.3</jettison-version>



Mime
View raw message