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-5697 - authorization map and composite destinations
Date Tue, 31 Mar 2015 15:13:47 GMT
Repository: activemq
Updated Branches:
  refs/heads/master a39e51e05 -> 8bb58036a


https://issues.apache.org/jira/browse/AMQ-5697 - authorization map and composite destinations


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

Branch: refs/heads/master
Commit: 8bb58036a0251aa03301dc2c79d24076e0e8c8ff
Parents: a39e51e
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Tue Mar 31 17:13:27 2015 +0200
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Tue Mar 31 17:13:37 2015 +0200

----------------------------------------------------------------------
 .../activemq/security/AuthorizationEntry.java   | 24 ++++++++++++++++++++
 .../activemq/security/AuthorizationMapTest.java | 14 ++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8bb58036/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
b/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
index 846732c..777c8a8 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
@@ -111,4 +111,28 @@ public class AuthorizationEntry extends DestinationMapEntry {
         }
         return answer;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof AuthorizationEntry)) return false;
+
+        AuthorizationEntry that = (AuthorizationEntry) o;
+
+        if (adminRoles != null ? !adminRoles.equals(that.adminRoles) : that.adminRoles !=
null) return false;
+        if (groupClass != null ? !groupClass.equals(that.groupClass) : that.groupClass !=
null) return false;
+        if (readRoles != null ? !readRoles.equals(that.readRoles) : that.readRoles != null)
return false;
+        if (writeRoles != null ? !writeRoles.equals(that.writeRoles) : that.writeRoles !=
null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = adminRoles != null ? adminRoles.hashCode() : 0;
+        result = 31 * result + (readRoles != null ? readRoles.hashCode() : 0);
+        result = 31 * result + (writeRoles != null ? writeRoles.hashCode() : 0);
+        result = 31 * result + (groupClass != null ? groupClass.hashCode() : 0);
+        return result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/8bb58036/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 63d39a6..dc4192f 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
@@ -44,12 +44,22 @@ public class AuthorizationMapTest extends TestCase {
 
     }
 
-    public void testCompositeDoesNotBypassAuthorizationMap() {
-        AuthorizationMap map = createAuthorizationMap();
+    public void testComposite() {
+        DefaultAuthorizationMap map = (DefaultAuthorizationMap)createAuthorizationMap();
+        map.put(new ActiveMQQueue("QUEUEA"), createEntry("QUEUEA", "users", "users", "users"));
+        map.put(new ActiveMQQueue("QUEUEB"), createEntry("QUEUEB", "users", "users", "users"));
 
         Set<?> readACLs = map.getReadACLs(new ActiveMQQueue("USERS.FOO.BAR,DENIED"));
         assertEquals("set size: " + readACLs, 1, readACLs.size());
         assertTrue("Contains users group", readACLs.contains(ADMINS));
+
+        readACLs = map.getReadACLs(new ActiveMQQueue("USERS.FOO.BAR,USERS.BAR.FOO"));
+        assertEquals("set size: " + readACLs, 2, readACLs.size());
+        assertTrue("Contains users group", readACLs.contains(USERS));
+
+        readACLs = map.getReadACLs(new ActiveMQQueue("QUEUEA,QUEUEB"));
+        assertEquals("set size: " + readACLs, 2, readACLs.size());
+        assertTrue("Contains users group", readACLs.contains(USERS));
     }
 
     public void testAuthorizationMapWithTempDest() {


Mime
View raw message