activemq message security

Thu, Jul 30, 2009

Worried about what clients are consuming messages on your broker? Implement a MessageAuthorizationPolicy. Add it to your camel-config:

<broker useJmx=“true” persistent=“false”
    xmlns=“http://activemq.apache.org/schema/core">
  <messageAuthorizationPolicy>
    <bean class=“org.funnyfarm.security.MessageGuard”
        xmlns=“http://www.springframework.org/schema/beans"/>
  </messageAuthorizationPolicy>

<transportConnectors> <transportConnector uri=“tcp://localhost:61616” /> <transportConnector name=“stomp” uri=“stomp://localhost:61613”/> </transportConnectors> </broker>

then implement one:
package org.funnyfarm.security;

import org.apache.activemq.security.MessageAuthorizationPolicy; import org.apache.activemq.broker.ConnectionContext; import org.apache.activemq.command.Message;

public class MessageGuard implements MessageAuthorizationPolicy { public boolean isAllowedToConsume(ConnectionContext context, Message message) { // Do funny stuff with the context client-id, message producerid, // message destination etc if (doFunnyStuff()) { return true; } else { return false; } } }

comments powered by Disqus