diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java b/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java index 3ae2d218bc..3a9c3ef355 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java @@ -37,6 +37,7 @@ import org.apache.activemq.command.ConsumerId; import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.RemoveSubscriptionInfo; import org.apache.activemq.network.NetworkConnector; +import org.apache.activemq.security.SecurityContext; /** * @version $Revision$ @@ -313,6 +314,7 @@ public class BrokerView implements BrokerViewMBean { protected static ConnectionContext createAdminConnectionContext(Broker broker) { ConnectionContext context = new ConnectionContext(); context.setBroker(broker); + context.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); return context; } diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java new file mode 100644 index 0000000000..c1190d4255 --- /dev/null +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/AuthorizationFromAdminViewTest.java @@ -0,0 +1,55 @@ +/* + * AuthorizationFromAdminViewTest + * Date: Oct 21, 2010 + * Copyright: Sony BMG + * Created by: baraza + */ +package org.apache.activemq.usecases; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerFactory; +import org.apache.activemq.broker.BrokerPlugin; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.security.AuthorizationPlugin; +import org.apache.activemq.security.SimpleAuthorizationMap; + +public class AuthorizationFromAdminViewTest extends org.apache.activemq.TestSupport { + + private BrokerService broker; + + protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { + return new ActiveMQConnectionFactory("vm://" + getName()); + } + + protected void setUp() throws Exception { + createBroker(); + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + destroyBroker(); + } + + private void createBroker() throws Exception { + broker = BrokerFactory.createBroker("broker:(vm://localhost)"); + broker.setPersistent(false); + broker.setBrokerName(getName()); + + AuthorizationPlugin plugin = new AuthorizationPlugin(); + plugin.setMap(new SimpleAuthorizationMap()); + BrokerPlugin[] plugins = new BrokerPlugin[] {plugin}; + broker.setPlugins(plugins); + + broker.start(); + } + + private void destroyBroker() throws Exception { + if (broker != null) + broker.stop(); + } + + public void testAuthorizationFromAdminView() throws Exception { + broker.getAdminView().addQueue(getDestinationString()); + } +}