diff --git a/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java b/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java index 89a0fe7719..2327b9a7d3 100644 --- a/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/security/AuthorizationBroker.java @@ -28,6 +28,7 @@ import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.command.ConsumerInfo; +import org.apache.activemq.command.DestinationInfo; import org.apache.activemq.command.Message; import org.apache.activemq.command.ProducerInfo; @@ -45,6 +46,11 @@ public class AuthorizationBroker extends BrokerFilter implements SecurityAdminMB super(next); this.authorizationMap = authorizationMap; } + + public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { + addDestination(context, info.getDestination()); + super.addDestinationInfo(context, info); + } public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception { final SecurityContext securityContext = (SecurityContext)context.getSecurityContext(); diff --git a/activemq-core/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java b/activemq-core/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java index 0c38eb9753..fa69556a00 100644 --- a/activemq-core/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/security/SimpleAuthenticationPluginTest.java @@ -18,14 +18,20 @@ package org.apache.activemq.security; import java.net.URI; +import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TemporaryTopic; +import javax.management.ObjectName; import junit.framework.Test; import org.apache.activemq.CombinationTestSupport; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.jmx.TopicViewMBean; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; import org.apache.commons.logging.Log; @@ -66,5 +72,24 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport { assertEquals("guest", ((ActiveMQMessage)sent).getUserID()); assertEquals("guest", sent.getStringProperty("JMSXUserID")); } + + public void testTempDestinations() throws Exception { + Connection conn = factory.createConnection("guest", "password"); + Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); + String name = "org.apache.activemq:BrokerName=localhost,Type=TempTopic"; + try { + conn.start(); + TemporaryTopic temp = sess.createTemporaryTopic(); + name += ",Destination=" + temp.getTopicName().replaceAll(":", "_"); + fail("Should have failed creating a temp topic"); + } catch (Exception ignore) {} + + ObjectName objName = new ObjectName(name); + TopicViewMBean mbean = (TopicViewMBean)broker.getManagementContext().newProxyInstance(objName, TopicViewMBean.class, true); + try { + System.out.println(mbean.getName()); + fail("Shouldn't have created a temp topic"); + } catch (Exception ignore) {} + } } diff --git a/activemq-core/src/test/resources/org/apache/activemq/security/simple-auth-broker.xml b/activemq-core/src/test/resources/org/apache/activemq/security/simple-auth-broker.xml index 54bf334a09..c1d7163624 100644 --- a/activemq-core/src/test/resources/org/apache/activemq/security/simple-auth-broker.xml +++ b/activemq-core/src/test/resources/org/apache/activemq/security/simple-auth-broker.xml @@ -60,6 +60,9 @@ + + +