git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@660517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-05-27 13:51:42 +00:00
parent 1f9e67f2b7
commit 041b1b8ad5
3 changed files with 34 additions and 0 deletions

View File

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

View File

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

View File

@ -23,6 +23,10 @@
<broker useJmx="false" persistent="false" xmlns="http://activemq.apache.org/schema/core" populateJMSXUserID="true">
<destinations>
<queue physicalName="TEST.Q" />
</destinations>
<plugins>
<simpleAuthenticationPlugin>
<users>
@ -44,6 +48,8 @@
<authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
<authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
<authorizationEntry queue="TEST.Q" read="guests" write="guests" />
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
<authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />