karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject karaf git commit: [KARAF-4600] RBAC - MBean fails to resolve ACL if the order of properties in object name differs
Date Thu, 30 Jun 2016 02:56:28 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 54dec7d13 -> 1fe22425f


[KARAF-4600] RBAC - MBean fails to resolve ACL if the order of properties in object name differs

(cherry picked from commit ce1b778138d4eee7992b25386aa19c6a7edaf384)


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1fe22425
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1fe22425
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1fe22425

Branch: refs/heads/karaf-4.0.x
Commit: 1fe22425f9e0d3e0e6e2b40ebb02b9cfcbdbcae1
Parents: 54dec7d
Author: Tadayoshi Sato <sato.tadayoshi@gmail.com>
Authored: Thu Jun 30 11:22:17 2016 +0900
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Thu Jun 30 10:52:48 2016 +0800

----------------------------------------------------------------------
 .../karaf/management/KarafMBeanServerGuard.java |  4 ++--
 .../management/KarafMBeanServerGuardTest.java   | 21 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1fe22425/management/server/src/main/java/org/apache/karaf/management/KarafMBeanServerGuard.java
----------------------------------------------------------------------
diff --git a/management/server/src/main/java/org/apache/karaf/management/KarafMBeanServerGuard.java
b/management/server/src/main/java/org/apache/karaf/management/KarafMBeanServerGuard.java
index 4259326..1e1c430 100644
--- a/management/server/src/main/java/org/apache/karaf/management/KarafMBeanServerGuard.java
+++ b/management/server/src/main/java/org/apache/karaf/management/KarafMBeanServerGuard.java
@@ -405,7 +405,7 @@ public class KarafMBeanServerGuard implements InvocationHandler {
         segments.add(objectName.getDomain());
         // TODO can an ObjectName property contain a comma as key or value ?
         // TODO support quoting as described in http://docs.oracle.com/javaee/1.4/api/javax/management/ObjectName.html
-        for (String s : objectName.getKeyPropertyListString().split("[,]")) {
+        for (String s : objectName.getCanonicalKeyPropertyListString().split("[,]")) {
             int index = s.indexOf('=');
             if (index < 0) {
                 continue;
@@ -417,7 +417,7 @@ public class KarafMBeanServerGuard implements InvocationHandler {
                 segments.add(key);
             }
         }
-        
+
         return segments;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/1fe22425/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
----------------------------------------------------------------------
diff --git a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
index 3f69158..318ec34 100644
--- a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
+++ b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
@@ -353,6 +353,27 @@ public class KarafMBeanServerGuardTest extends TestCase {
                 guard.getRequiredRoles(on3, "foo", new Object[]{}, new String[]{}));
     }
 
+    public void testRequiredRolesHierarchyCanonical() throws Exception {
+        Dictionary<String, Object> conf = new Hashtable<String, Object>();
+        conf.put("foo", "viewer");
+        conf.put(Constants.SERVICE_PID, "jmx.acl.foo.bar.Test.AAA.BBB");
+        ConfigurationAdmin ca = getMockConfigAdmin2(conf);
+
+        KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
+        guard.setConfigAdmin(ca);
+
+        // Canonical object name
+        ObjectName on1 = ObjectName.getInstance("foo.bar:prop1=AAA,prop2=BBB,type=Test");
+        assertEquals("Canonical ObjectName should work",
+                Collections.singletonList("viewer"),
+                guard.getRequiredRoles(on1, "foo", new String[]{}));
+        // Non-canonical object name
+        ObjectName on2 = ObjectName.getInstance("foo.bar:type=Test,prop2=BBB,prop1=AAA");
+        assertEquals("Non-canonical ObjectName should also work",
+                Collections.singletonList("viewer"),
+                guard.getRequiredRoles(on2, "foo", new String[]{}));
+    }
+
     public void testRequiredRolesMethodNameWildcard() throws Exception {
         Dictionary<String, Object> configuration = new Hashtable<String, Object>();
         configuration.put("getFoo", "viewer");


Mime
View raw message