git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@891786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-12-17 16:18:46 +00:00
parent 1606c59b9e
commit 3a1bdc6249
3 changed files with 34 additions and 0 deletions

View File

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

View File

@ -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) {}
}
}

View File

@ -60,6 +60,9 @@
<authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
</authorizationEntries>
<tempDestinationAuthorizationEntry>
<tempDestinationAuthorizationEntry read="admin" write="admin" admin="admin"/>
</tempDestinationAuthorizationEntry>
</authorizationMap>
</map>
</authorizationPlugin>