ARTEMIS-3900 Support management allowlist entries with wildcard domain
This commit is contained in:
parent
e44bd5266f
commit
d250801fcf
|
@ -83,6 +83,11 @@ public class JMXAccessControlList {
|
||||||
|
|
||||||
public boolean isInAllowList(ObjectName objectName) {
|
public boolean isInAllowList(ObjectName objectName) {
|
||||||
TreeMap<String, Access> domainMap = allowList.get(objectName.getDomain());
|
TreeMap<String, Access> domainMap = allowList.get(objectName.getDomain());
|
||||||
|
|
||||||
|
if (domainMap == null) {
|
||||||
|
domainMap = allowList.get(WILDCARD);
|
||||||
|
}
|
||||||
|
|
||||||
if (domainMap != null) {
|
if (domainMap != null) {
|
||||||
if (domainMap.containsKey("")) {
|
if (domainMap.containsKey("")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -60,6 +60,30 @@ public class JMXAccessControlListTest {
|
||||||
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain:type=foo")));
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain:type=foo")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWildcardDomain() throws MalformedObjectNameException {
|
||||||
|
JMXAccessControlList controlList = new JMXAccessControlList();
|
||||||
|
controlList.addToAllowList("*", null);
|
||||||
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain:*")));
|
||||||
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain.foo:*")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWildcardDomainWithProperty() throws MalformedObjectNameException {
|
||||||
|
JMXAccessControlList controlList = new JMXAccessControlList();
|
||||||
|
controlList.addToAllowList("*", "type=foo");
|
||||||
|
controlList.addToAllowList("org.myDomain.foo", "type=bar");
|
||||||
|
Assert.assertFalse(controlList.isInAllowList(new ObjectName("org.myDomain:*")));
|
||||||
|
Assert.assertFalse(controlList.isInAllowList(new ObjectName("org.myDomain.foo:*")));
|
||||||
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain.foo:type=bar")));
|
||||||
|
Assert.assertFalse(controlList.isInAllowList(new ObjectName("org.myDomain.foo:type=foo")));
|
||||||
|
Assert.assertFalse(controlList.isInAllowList(new ObjectName("org.myDomain.bar:*")));
|
||||||
|
Assert.assertFalse(controlList.isInAllowList(new ObjectName("org.myDomain:subType=foo")));
|
||||||
|
|
||||||
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain:type=foo")));
|
||||||
|
Assert.assertTrue(controlList.isInAllowList(new ObjectName("org.myDomain:subType=bar,type=foo")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicRole() throws MalformedObjectNameException {
|
public void testBasicRole() throws MalformedObjectNameException {
|
||||||
JMXAccessControlList controlList = new JMXAccessControlList();
|
JMXAccessControlList controlList = new JMXAccessControlList();
|
||||||
|
|
Loading…
Reference in New Issue