You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2009/11/27 09:19:32 UTC
svn commit: r884778 - in /activemq/trunk/activemq-core/src:
main/java/org/apache/activemq/broker/region/Queue.java
test/java/org/apache/activemq/security/SecurityJMXTest.java
Author: gtully
Date: Fri Nov 27 08:19:19 2009
New Revision: 884778
URL: http://svn.apache.org/viewvc?rev=884778&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2516 - broker send to dlq now uses broker security context so it will bypass the authentication plugin when configured
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=884778&r1=884777&r2=884778&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java Fri Nov 27 08:19:19 2009
@@ -61,6 +61,7 @@
import org.apache.activemq.filter.BooleanExpression;
import org.apache.activemq.filter.MessageEvaluationContext;
import org.apache.activemq.filter.NonCachedMessageEvaluationContext;
+import org.apache.activemq.security.SecurityContext;
import org.apache.activemq.selector.SelectorParser;
import org.apache.activemq.store.MessageRecoveryListener;
import org.apache.activemq.store.MessageStore;
@@ -1262,6 +1263,7 @@
ConnectionContext answer = new ConnectionContext(new NonCachedMessageEvaluationContext());
answer.setBroker(this.broker);
answer.getMessageEvaluationContext().setDestination(getActiveMQDestination());
+ answer.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
return answer;
}
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java?rev=884778&r1=884777&r2=884778&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java Fri Nov 27 08:19:19 2009
@@ -18,7 +18,13 @@
import java.net.URI;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
@@ -28,9 +34,11 @@
import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,6 +54,7 @@
}
public void tearDown() throws Exception {
+ broker.stop();
}
public void testMoveMessages() throws Exception {
@@ -58,6 +67,34 @@
String msgId = queueMbean.sendTextMessage("test", "system", "manager");
queueMbean.moveMessageTo(msgId, "TEST1.Q");
}
+
+
+ public void testBrowseExpiredMessages() throws Exception {
+ JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
+ JMXConnector connector = JMXConnectorFactory.connect(url, null);
+ connector.connect();
+ MBeanServerConnection connection = connector.getMBeanServerConnection();
+ ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=TEST.Q");
+ QueueViewMBean queueMbean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true);
+ HashMap<String, String> headers = new HashMap<String, String>();
+ headers.put("JMSExpiration", Long.toString(System.currentTimeMillis() + 2000));
+ headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
+ String msgId = queueMbean.sendTextMessage(headers, "test", "system", "manager");
+ // allow message to expire on the queue
+ TimeUnit.SECONDS.sleep(3);
+
+ Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager");
+ c.start();
+
+ // browser consumer will force expriation check on addConsumer
+ QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q"));
+ assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements());
+
+ // verify dlq got the message, no security exception as brokers context is now used
+ browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
+ assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements());
+ }
+
protected BrokerService createBroker() throws Exception {
return createBroker("org/apache/activemq/security/simple-auth-broker.xml");