activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5644 - authorization map for wildcard subscriptions
Date Fri, 06 Mar 2015 14:35:26 GMT
Repository: activemq
Updated Branches:
  refs/heads/master ad39fc00f -> 7777744dc


https://issues.apache.org/jira/browse/AMQ-5644 - authorization map for wildcard subscriptions


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/7777744d
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/7777744d
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/7777744d

Branch: refs/heads/master
Commit: 7777744dc256c11d2545056c8afb2049bb0ae165
Parents: ad39fc0
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Fri Mar 6 15:33:55 2015 +0100
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Fri Mar 6 15:35:20 2015 +0100

----------------------------------------------------------------------
 .../security/DefaultAuthorizationMap.java         | 15 ++++++++++++++-
 .../activemq/security/AuthorizationMapTest.java   | 18 ++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/7777744d/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
b/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
index e2a3d8e..e320a9f 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.filter.DestinationFilter;
 import org.apache.activemq.filter.DestinationMap;
 import org.apache.activemq.filter.DestinationMapEntry;
 
@@ -170,7 +171,19 @@ public class DefaultAuthorizationMap extends DestinationMap implements
Authoriza
             }
             return answer;
         }
-        return findWildcardMatches(key);
+
+        Set answer = findWildcardMatches(key);
+
+        if (key.isPattern()) {
+            for (Iterator<Object> iterator = answer.iterator(); iterator.hasNext();
) {
+                AuthorizationEntry entry = (AuthorizationEntry)iterator.next();
+                DestinationFilter filter = DestinationFilter.parseFilter(entry.getDestination());
+                if (!filter.matches(key)) {
+                    iterator.remove();
+                }
+            }
+        }
+        return answer;
     }
 
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/7777744d/activemq-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java
index b6ace87..c2b3bc4 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/security/AuthorizationMapTest.java
@@ -89,6 +89,24 @@ public class AuthorizationMapTest extends TestCase {
         assertTrue("Contains users group", tempAdminACLs.contains(TEMP_DESTINATION_ADMINS));
     }
 
+    public void testWildcardSubscriptions() {
+        AuthorizationMap map = createAuthorizationMap();
+        Set<?> readACLs = map.getReadACLs(new ActiveMQQueue(">"));
+        assertEquals("set size: " + readACLs, 1, readACLs.size());
+        assertTrue("Contains admins group", readACLs.contains(ADMINS));
+        assertFalse("Contains users group", readACLs.contains(USERS));
+
+        readACLs = map.getReadACLs(new ActiveMQQueue("USERS.>"));
+        assertEquals("set size: " + readACLs, 2, readACLs.size());
+        assertTrue("Contains admins group", readACLs.contains(ADMINS));
+        assertTrue("Contains users group", readACLs.contains(USERS));
+
+        readACLs = map.getReadACLs(new ActiveMQQueue("USERS.FOO.>"));
+        assertEquals("set size: " + readACLs, 2, readACLs.size());
+        assertTrue("Contains admins group", readACLs.contains(ADMINS));
+        assertTrue("Contains users group", readACLs.contains(USERS));
+    }
+
     protected AuthorizationMap createWildcardAuthorizationMap() {
         DefaultAuthorizationMap answer = new DefaultAuthorizationMap();
 


Mime
View raw message