activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1080212 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ test/java/org/apache/activemq/test/ test/java/org/apache/activemq/test/message/
Date Thu, 10 Mar 2011 13:24:35 GMT
Author: gtully
Date: Thu Mar 10 13:24:34 2011
New Revision: 1080212

URL: http://svn.apache.org/viewvc?rev=1080212&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3211 - ensure that a JMSXUserID property set by
a client is ignored if an alternative userId mechanism is in place. This ensures that a client
cannot spoof this value when the broker is configured to supply if from credentials. The client
supplied value is only used as a last resourt

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java?rev=1080212&r1=1080211&r2=1080212&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
Thu Mar 10 13:24:34 2011
@@ -593,11 +593,14 @@ public class ActiveMQMessage extends Mes
     }
 
     public String getStringProperty(String name) throws JMSException {
-        Object value = getObjectProperty(name);
-        if (value == null) {
-            if (name.equals("JMSXUserID")) {
-                value = getUserID();
+        Object value = null;
+        if (name.equals("JMSXUserID")) {
+            value = getUserID();
+            if (value == null) {
+                value = getObjectProperty(name);
             }
+        } else {
+            value = getObjectProperty(name);
         }
         if (value == null) {
             return null;

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java?rev=1080212&r1=1080211&r2=1080212&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithEmbeddedBrokerAndUserIDTest.java
Thu Mar 10 13:24:34 2011
@@ -60,4 +60,21 @@ public class JmsTopicSendReceiveWithEmbe
             assertEquals("JMSXUserID header", userName, userID);
         }
     }
+
+    public void testSpoofedJMSXUserIdIsIgnored() throws Exception {
+        Thread.sleep(1000);
+        messages.clear();
+
+        for (int i = 0; i < data.length; i++) {
+            Message message = createMessage(i);
+            configureMessage(message);
+            message.setStringProperty("JMSXUserID", "spoofedId");
+            if (verbose) {
+                LOG.info("About to send a message: " + message + " with text: " + data[i]);
+            }
+            sendMessage(i, message);
+        }
+        assertMessagesAreReceived();
+        LOG.info("" + data.length + " messages(s) received, closing down connections");
+    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java?rev=1080212&r1=1080211&r2=1080212&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java
Thu Mar 10 13:24:34 2011
@@ -66,6 +66,7 @@ public class NestedMapAndListPropertyTes
         assertEquals("listField[0]", "a", list.get(0));
         assertEquals("listField[1]", "b", list.get(1));
         assertEquals("listField[2]", "c", list.get(2));
+        assertEquals("JohnDoe", message.getStringProperty("JMSXUserID"));
     }
 
     protected Message createMessage(int index) throws JMSException {
@@ -85,6 +86,7 @@ public class NestedMapAndListPropertyTes
 
         answer.setObjectProperty("mapField", nestedMap);
         answer.setObjectProperty("listField", Arrays.asList(new Object[] {"a", "b", "c"}));
+        answer.setStringProperty("JMSXUserID", "JohnDoe");
 
         return answer;
     }



Mime
View raw message