seems to be regression from: https://issues.apache.org/activemq/browse/AMQ-2970 - but there is some mix up with the creation of an admin connection context. having the BrokerView do the right thing works for the moment... but this needs some more eyes, test shows the issue when context is missing

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1026092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2010-10-21 18:17:42 +00:00
parent 57737968fb
commit 9e885efca2
2 changed files with 57 additions and 0 deletions

View File

@ -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;
}

View File

@ -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());
}
}