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 02723b1ecf..d3e6550f69 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 @@ -51,6 +51,12 @@ public class AuthorizationBroker extends BrokerFilter implements SecurityAdminMB if (securityContext == null) { throw new SecurityException("User is not authenticated."); } + + Destination existing = this.getDestinationMap().get(destination); + if (existing != null) { + return existing; + } + // if(!((ActiveMQTempDestination)destination).getConnectionId().equals(context.getConnectionId().getValue()) // ) { if (!securityContext.isBrokerContext()) { 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 eb74e20ce7..0c38eb9753 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,9 +18,16 @@ package org.apache.activemq.security; import java.net.URI; +import javax.jms.JMSException; +import javax.jms.Message; + 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.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQQueue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,5 +51,20 @@ public class SimpleAuthenticationPluginTest extends SecurityTestSupport { LOG.info("Loading broker configuration from the classpath with URI: " + uri); return BrokerFactory.createBroker(new URI("xbean:" + uri)); } + + /** + * @see {@link CombinationTestSupport} + */ + public void initCombosForTestPredefinedDestinations() { + addCombinationValues("userName", new Object[] {"guest"}); + addCombinationValues("password", new Object[] {"password"}); + addCombinationValues("destination", new Object[] {new ActiveMQQueue("TEST.Q")}); + } + + public void testPredefinedDestinations() throws JMSException { + Message sent = doSend(false); + assertEquals("guest", ((ActiveMQMessage)sent).getUserID()); + assertEquals("guest", sent.getStringProperty("JMSXUserID")); + } } 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 a5afb27aa5..a5d968f351 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 @@ -23,6 +23,10 @@ + + + + @@ -44,6 +48,8 @@ + +