activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1357293 - in /activemq/trunk/activemq-optional/src/main: java/org/apache/activemq/transport/ java/org/apache/activemq/transport/https/ java/org/apache/activemq/transport/ws/ java/org/apache/activemq/transport/wss/ resources/META-INF/servic...
Date Wed, 04 Jul 2012 15:05:45 GMT
Author: dejanb
Date: Wed Jul  4 15:05:44 2012
New Revision: 1357293

URL: http://svn.apache.org/viewvc?rev=1357293&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3880 - wss transport implementation

Added:
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
      - copied, changed from r1357201, activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportServer.java
    activemq/trunk/activemq-optional/src/main/resources/META-INF/services/org/apache/activemq/transport/wss
Modified:
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.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/WSTransportFactory.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportServer.java

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java?rev=1357293&r1=1357292&r2=1357293&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java
Wed Jul  4 15:05:44 2012
@@ -20,6 +20,8 @@ import org.apache.activemq.spring.Spring
 import org.apache.activemq.transport.https.Krb5AndCertsSslSocketConnector;
 import org.apache.activemq.util.IntrospectionSupport;
 import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.ssl.SslConnector;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 
 import org.apache.activemq.broker.SslContext;
@@ -47,7 +49,14 @@ public class SecureSocketConnectorFactor
 
     @Override
     public Connector createConnector() throws Exception {
-        Krb5AndCertsSslSocketConnector sslConnector = new Krb5AndCertsSslSocketConnector();
+        IntrospectionSupport.setProperties(this, getTransportOptions());
+        SslConnector sslConnector;
+        if (Krb5AndCertsSslSocketConnector.isKrb(auth)) {
+            sslConnector = new Krb5AndCertsSslSocketConnector();
+            ((Krb5AndCertsSslSocketConnector)sslConnector).setMode(auth);
+        } else {
+            sslConnector = new SslSelectChannelConnector();
+        }
 
         SSLContext sslContext = context == null ? null : context.getSSLContext();
 
@@ -61,11 +70,6 @@ public class SecureSocketConnectorFactor
             factory.setSslContext(sslContext);
 
         } else {
-            IntrospectionSupport.setProperties(this, getTransportOptions());
-
-            if (auth != null) {
-                sslConnector.setMode(auth);
-            }
 
             if (keyStore != null) {
                 factory.setKeyStorePath(keyStore);

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=1357293&r1=1357292&r2=1357293&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
Wed Jul  4 15:05:44 2012
@@ -70,6 +70,10 @@ public class Krb5AndCertsSslSocketConnec
         setPasswords();
     }
 
+    public static boolean isKrb(String mode) {
+        return mode == MODE.KRB.toString() || mode == MODE.BOTH.toString();
+    }
+
     public void setMode(String mode) {
         useKrb = mode == MODE.KRB.toString() || mode == MODE.BOTH.toString();
         useCerts = mode == MODE.CERTS.toString() || mode == MODE.BOTH.toString();

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java?rev=1357293&r1=1357292&r2=1357293&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
Wed Jul  4 15:05:44 2012
@@ -19,9 +19,15 @@ package org.apache.activemq.transport.ws
 
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportServer;
+import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
 
 /**
  * 
@@ -31,7 +37,15 @@ import org.apache.activemq.transport.Tra
 public class WSTransportFactory extends TransportFactory {
 
     public TransportServer doBind(URI location) throws IOException {
-        return new WSTransportServer(location);
+        try {
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
+            WSTransportServer result = new WSTransportServer(location);
+            Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options,
"transport.");
+            result.setTransportOption(transportOptions);
+            return result;
+        } catch (URISyntaxException e) {
+            throw IOExceptionSupport.create(e);
+        }
     }
 
 }

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=1357293&r1=1357292&r2=1357293&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
Wed Jul  4 15:05:44 2012
@@ -18,6 +18,7 @@
 package org.apache.activemq.transport.ws;
 
 import org.apache.activemq.command.BrokerInfo;
+import org.apache.activemq.transport.SocketConnectorFactory;
 import org.apache.activemq.transport.TransportServerSupport;
 import org.apache.activemq.util.ServiceStopper;
 import org.eclipse.jetty.server.Connector;
@@ -28,6 +29,7 @@ import org.eclipse.jetty.servlet.Servlet
 
 import java.net.InetSocketAddress;
 import java.net.URI;
+import java.util.Map;
 
 /**
  * Creates a web server and registers web socket server
@@ -38,16 +40,18 @@ public class WSTransportServer extends T
     private URI bindAddress;
     private Server server;
     private Connector connector;
+    protected SocketConnectorFactory socketConnectorFactory;
 
     public WSTransportServer(URI location) {
         super(location);
         this.bindAddress = location;
+        socketConnectorFactory = new SocketConnectorFactory();
     }
 
     protected void doStart() throws Exception {
         server = new Server();
         if (connector == null) {
-            connector = new SelectChannelConnector();
+            connector = socketConnectorFactory.createConnector();
         }
         connector.setHost(bindAddress.getHost());
         connector.setPort(bindAddress.getPort());
@@ -81,4 +85,14 @@ public class WSTransportServer extends T
     public void setBrokerInfo(BrokerInfo brokerInfo) {
     }
 
+    protected void setConnector(Connector connector) {
+        this.connector = connector;
+    }
+
+    @Override
+    public void setTransportOption(Map<String, Object> transportOptions) {
+        socketConnectorFactory.setTransportOptions(transportOptions);
+        super.setTransportOption(transportOptions);
+    }
+
 }

Copied: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
(from r1357201, activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java?p2=activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java&p1=activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java&r1=1357201&r2=1357293&rev=1357293&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/ws/WSTransportFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportFactory.java
Wed Jul  4 15:05:44 2012
@@ -14,24 +14,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.activemq.transport.wss;
 
-package org.apache.activemq.transport.ws;
+import org.apache.activemq.broker.SslContext;
+import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.TransportServer;
+import org.apache.activemq.transport.ws.WSTransportServer;
+import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
 
 import java.io.IOException;
 import java.net.URI;
-
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.transport.TransportServer;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
- * 
- * Factory for WebSocket (ws) transport
+ *
+ * Factory for Secure WebSocket (wss) transport
  *
  */
-public class WSTransportFactory extends TransportFactory {
+public class WSSTransportFactory extends TransportFactory {
 
     public TransportServer doBind(URI location) throws IOException {
-        return new WSTransportServer(location);
+        try {
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
+            WSSTransportServer result = new WSSTransportServer(location, SslContext.getCurrentSslContext());
+            Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options,
"transport.");
+            result.setTransportOption(transportOptions);
+            return result;
+        } catch (URISyntaxException e) {
+            throw IOExceptionSupport.create(e);
+        }
     }
 
 }

Added: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportServer.java?rev=1357293&view=auto
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportServer.java
(added)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/wss/WSSTransportServer.java
Wed Jul  4 15:05:44 2012
@@ -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.activemq.transport.wss;
+
+import org.apache.activemq.broker.SslContext;
+import org.apache.activemq.transport.SecureSocketConnectorFactory;
+import org.apache.activemq.transport.https.Krb5AndCertsSslSocketConnector;
+import org.apache.activemq.transport.ws.WSTransportServer;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+
+import javax.net.ssl.SSLContext;
+import java.net.URI;
+
+public class WSSTransportServer extends WSTransportServer {
+    private SslContext context;
+
+    public WSSTransportServer(URI location, SslContext context) {
+        super(location);
+        this.context = context;
+        this.socketConnectorFactory = new SecureSocketConnectorFactory(context);
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+
+        Connector sslConnector = socketConnectorFactory.createConnector();
+
+        setConnector(sslConnector);
+
+        super.doStart();
+    }
+}

Added: activemq/trunk/activemq-optional/src/main/resources/META-INF/services/org/apache/activemq/transport/wss
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/resources/META-INF/services/org/apache/activemq/transport/wss?rev=1357293&view=auto
==============================================================================
--- activemq/trunk/activemq-optional/src/main/resources/META-INF/services/org/apache/activemq/transport/wss
(added)
+++ activemq/trunk/activemq-optional/src/main/resources/META-INF/services/org/apache/activemq/transport/wss
Wed Jul  4 15:05:44 2012
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+class=org.apache.activemq.transport.wss.WSSTransportFactory
\ No newline at end of file



Mime
View raw message