mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2539 - adding temp destinations and security
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@891786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1606c59b9e
commit
3a1bdc6249
|
@ -28,6 +28,7 @@ import org.apache.activemq.command.ActiveMQDestination;
|
||||||
import org.apache.activemq.command.ActiveMQQueue;
|
import org.apache.activemq.command.ActiveMQQueue;
|
||||||
import org.apache.activemq.command.ActiveMQTopic;
|
import org.apache.activemq.command.ActiveMQTopic;
|
||||||
import org.apache.activemq.command.ConsumerInfo;
|
import org.apache.activemq.command.ConsumerInfo;
|
||||||
|
import org.apache.activemq.command.DestinationInfo;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
import org.apache.activemq.command.ProducerInfo;
|
import org.apache.activemq.command.ProducerInfo;
|
||||||
|
|
||||||
|
@ -46,6 +47,11 @@ public class AuthorizationBroker extends BrokerFilter implements SecurityAdminMB
|
||||||
this.authorizationMap = authorizationMap;
|
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 {
|
public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception {
|
||||||
final SecurityContext securityContext = (SecurityContext)context.getSecurityContext();
|
final SecurityContext securityContext = (SecurityContext)context.getSecurityContext();
|
||||||
if (securityContext == null) {
|
if (securityContext == null) {
|
||||||
|
|
|
@ -18,14 +18,20 @@ package org.apache.activemq.security;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Message;
|
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 junit.framework.Test;
|
||||||
|
|
||||||
import org.apache.activemq.CombinationTestSupport;
|
import org.apache.activemq.CombinationTestSupport;
|
||||||
import org.apache.activemq.broker.BrokerFactory;
|
import org.apache.activemq.broker.BrokerFactory;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
import org.apache.activemq.broker.jmx.TopicViewMBean;
|
||||||
import org.apache.activemq.command.ActiveMQMessage;
|
import org.apache.activemq.command.ActiveMQMessage;
|
||||||
import org.apache.activemq.command.ActiveMQQueue;
|
import org.apache.activemq.command.ActiveMQQueue;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -67,4 +73,23 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport {
|
||||||
assertEquals("guest", sent.getStringProperty("JMSXUserID"));
|
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) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
|
|
||||||
<authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
|
<authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
|
||||||
</authorizationEntries>
|
</authorizationEntries>
|
||||||
|
<tempDestinationAuthorizationEntry>
|
||||||
|
<tempDestinationAuthorizationEntry read="admin" write="admin" admin="admin"/>
|
||||||
|
</tempDestinationAuthorizationEntry>
|
||||||
</authorizationMap>
|
</authorizationMap>
|
||||||
</map>
|
</map>
|
||||||
</authorizationPlugin>
|
</authorizationPlugin>
|
||||||
|
|
Loading…
Reference in New Issue