activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1126627 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/ apollo-stomp/src/main/scala/org/apache/activemq/apollo/sto...
Date Mon, 23 May 2011 18:16:09 GMT
Author: chirino
Date: Mon May 23 18:16:09 2011
New Revision: 1126627

URL: http://svn.apache.org/viewvc?rev=1126627&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-21 : Support a protocol interceptor plugins
to allow policy enforcement

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala?rev=1126627&r1=1126626&r2=1126627&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
Mon May 23 18:16:09 2011
@@ -16,13 +16,12 @@
  */
 package org.apache.activemq.apollo.broker.protocol
 
-import java.io.{IOException}
-import org.fusesource.hawtbuf.{Buffer, AsciiBuffer}
+import java.io.IOException
 import org.apache.activemq.apollo.broker.store.MessageRecord
 import org.apache.activemq.apollo.transport._
-import org.apache.activemq.apollo.broker.{Delivery, Message, BrokerConnection}
 import org.apache.activemq.apollo.dto.ConnectionStatusDTO
 import org.apache.activemq.apollo.util.{Log, ClassFinder}
+import org.apache.activemq.apollo.broker.{Broker, Message, BrokerConnection}
 
 /**
  * <p>
@@ -88,3 +87,18 @@ trait ProtocolHandler {
   def on_transport_command(command: AnyRef) = {}
 
 }
+
+object ProtocolFilter {
+  def create_filters(clazzes:List[String], handler:ProtocolHandler) = {
+    clazzes.map { clazz =>
+      val filter = Broker.class_loader.loadClass(clazz).newInstance().asInstanceOf[ProtocolFilter]
+      filter.protocol_handler = handler
+      filter
+    }
+  }
+}
+
+trait ProtocolFilter {
+  var protocol_handler:ProtocolHandler = _
+  def filter[T](command: T):T
+}

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1126627&r1=1126626&r2=1126627&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
Mon May 23 18:16:09 2011
@@ -23,7 +23,7 @@ import org.fusesource.hawtdispatch._
 import Buffer._
 import org.apache.activemq.apollo.broker._
 import java.lang.String
-import protocol.{HeartBeatMonitor, ProtocolHandler}
+import protocol.{ProtocolFilter, HeartBeatMonitor, ProtocolHandler}
 import security.SecurityContext
 import Stomp._
 import org.apache.activemq.apollo.selector.SelectorParser
@@ -36,8 +36,8 @@ import scala.util.continuations._
 import org.apache.activemq.apollo.dto._
 import org.apache.activemq.apollo.transport.tcp.SslTransport
 import java.security.cert.X509Certificate
-import collection.mutable.{ArrayBuffer, ListBuffer, HashMap}
-import java.io.{File, IOException}
+import collection.mutable.{ListBuffer, HashMap}
+import java.io.IOException
 
 
 case class RichBuffer(self:Buffer) extends Proxy {
@@ -72,9 +72,6 @@ object StompProtocolHandler extends Log 
 
 }
 
-import StompProtocolHandler._
-
-
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
@@ -369,6 +366,8 @@ class StompProtocolHandler extends Proto
   var config:StompDTO = _
   var session_id:AsciiBuffer = _
 
+  var protocol_filters = List[ProtocolFilter]()
+
   override def set_connection(connection: BrokerConnection) = {
     super.set_connection(connection)
     import collection.JavaConversions._
@@ -376,11 +375,12 @@ class StompProtocolHandler extends Proto
     val codec = connection.transport.getProtocolCodec.asInstanceOf[StompCodec]
     config = connection.connector.config.protocols.find( _.isInstanceOf[StompDTO]).map(_.asInstanceOf[StompDTO]).getOrElse(new
StompDTO)
 
+    protocol_filters = ProtocolFilter.create_filters(config.protocol_filters.toList, this)
+
     import OptionSupport._
     config.max_data_length.foreach( codec.max_data_length = _ )
     config.max_header_length.foreach( codec.max_header_length = _ )
     config.max_headers.foreach( codec.max_headers = _ )
-
   }
 
   override def create_connection_status = {
@@ -473,9 +473,14 @@ class StompProtocolHandler extends Proto
         case s:StompCodec =>
           // this is passed on to us by the protocol discriminator
           // so we know which wire format is being used.
-        case frame:StompFrame=>
+        case f:StompFrame=>
+
+          trace("received frame: %s", f)
 
-          trace("received frame: %s", frame)
+          var frame = f
+          protocol_filters.foreach { filter =>
+            frame = filter.filter(frame)
+          }
 
           if( protocol_version == null ) {
 

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java?rev=1126627&r1=1126626&r2=1126627&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/dto/StompDTO.java
Mon May 23 18:16:09 2011
@@ -50,4 +50,10 @@ public class StompDTO extends ProtocolDT
     @XmlAttribute(name="max_data_length")
     public Integer max_data_length;
 
+    /**
+     * A broker accepts connections via it's configured connectors.
+     */
+    @XmlElement(name="protocol_filter")
+    public List<String> protocol_filters = new ArrayList<String>();
+
 }



Mime
View raw message