use of org.osgi.service.cm.ConfigurationAdmin in project karaf by apache.
the class KarafMBeanServerGuardTest method testRequiredRolesMethodNameWildcard.
public void testRequiredRolesMethodNameWildcard() throws Exception {
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("getFoo", "viewer");
configuration.put("get*", " tester , editor,manager");
configuration.put("*", "admin");
ConfigurationAdmin ca = getMockConfigAdmin(configuration);
KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
guard.setConfigAdmin(ca);
ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
assertEquals(Collections.singletonList("viewer"), guard.getRequiredRoles(on, "getFoo", new Object[] {}, new String[] {}));
assertEquals(Arrays.asList("tester", "editor", "manager"), guard.getRequiredRoles(on, "getBar", new Object[] {}, new String[] {}));
assertEquals(Collections.singletonList("admin"), guard.getRequiredRoles(on, "test", new Object[] { new Long(17) }, new String[] { "java.lang.Long" }));
}
use of org.osgi.service.cm.ConfigurationAdmin in project karaf by apache.
the class KarafMBeanServerGuardTest method testRequiredRolesMethodNameWildcard3.
public void testRequiredRolesMethodNameWildcard3() throws Exception {
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("get*", "viewer");
configuration.put("*", "admin");
ConfigurationAdmin ca = getMockConfigAdmin(configuration);
KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
guard.setConfigAdmin(ca);
ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
assertEquals(Collections.singletonList("viewer"), guard.getRequiredRoles(on, "getFoo", new Object[] {}, new String[] {}));
assertEquals(Collections.singletonList("viewer"), guard.getRequiredRoles(on, "get", new Object[] {}, new String[] {}));
assertEquals(Collections.singletonList("admin"), guard.getRequiredRoles(on, "ge", new Object[] {}, new String[] {}));
}
use of org.osgi.service.cm.ConfigurationAdmin in project karaf by apache.
the class KarafMBeanServerGuardTest method testRequiredRolesExact2.
public void testRequiredRolesExact2() throws Exception {
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("foo(java.lang.String,java.lang.String)[\"a\",\",\"]", "editor #this is the editor rule");
configuration.put("foo(java.lang.String,java.lang.String)[\",\" , \"a\"]", "viewer");
ConfigurationAdmin ca = getMockConfigAdmin(configuration);
KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
guard.setConfigAdmin(ca);
ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
assertEquals(Collections.singletonList("editor"), guard.getRequiredRoles(on, "foo", new Object[] { "a", "," }, new String[] { "java.lang.String", "java.lang.String" }));
assertEquals(Collections.singletonList("viewer"), guard.getRequiredRoles(on, "foo", new Object[] { ",", "a" }, new String[] { "java.lang.String", "java.lang.String" }));
assertEquals(Collections.emptyList(), guard.getRequiredRoles(on, "foo", new Object[] { "a", "a" }, new String[] { "java.lang.String", "java.lang.String" }));
}
use of org.osgi.service.cm.ConfigurationAdmin in project karaf by apache.
the class KarafMBeanServerGuardTest method testRequiredRolesMethodNameEmpty.
@SuppressWarnings("unchecked")
public void testRequiredRolesMethodNameEmpty() throws Exception {
Dictionary<String, Object> conf1 = new Hashtable<>();
conf1.put("doit", "");
conf1.put("fryit", "editor, viewer");
conf1.put(Constants.SERVICE_PID, "jmx.acl.foo.bar.Test");
Dictionary<String, Object> conf2 = new Hashtable<>();
conf2.put("doit", "editor");
conf2.put(Constants.SERVICE_PID, "jmx.acl.foo.bar");
ConfigurationAdmin ca = getMockConfigAdmin2(conf1, conf2);
KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
guard.setConfigAdmin(ca);
ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
assertEquals(Collections.emptyList(), guard.getRequiredRoles(on, "doit", new Object[] {}, new String[] {}));
assertEquals(Arrays.asList("editor", "viewer"), guard.getRequiredRoles(on, "fryit", new Object[] { "blah" }, new String[] { "java.lang.String" }));
}
use of org.osgi.service.cm.ConfigurationAdmin in project karaf by apache.
the class KarafMBeanServerGuardTest method testRequiredRolesMethodNameOnly.
public void testRequiredRolesMethodNameOnly() throws Exception {
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("doit", "master");
configuration.put("fryit", "editor,viewer");
ConfigurationAdmin ca = getMockConfigAdmin(configuration);
KarafMBeanServerGuard guard = new KarafMBeanServerGuard();
guard.setConfigAdmin(ca);
ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
assertEquals(Collections.singletonList("master"), guard.getRequiredRoles(on, "doit", new Object[] {}, new String[] {}));
assertEquals(Arrays.asList("editor", "viewer"), guard.getRequiredRoles(on, "fryit", new Object[] { "blah" }, new String[] { "java.lang.String" }));
}
Aggregations