Skip to content

Commit 9a6765d

Browse files
committed
Add more transport types to the denied list for JMX
Add on multicast and zeroconf to the list of denied transports through JMX Follow on to #1918
1 parent 2b91f01 commit 9a6765d

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class BrokerView implements BrokerViewMBean {
4444

4545
private static final Logger LOG = LoggerFactory.getLogger(BrokerView.class);
4646

47-
private static final Set<String> DENIED_TRANSPORT_SCHEMES = Set.of("vm", "http");
47+
private static final Set<String> DENIED_TRANSPORT_SCHEMES = Set.of("vm", "http",
48+
"multicast", "zeroconf");
4849

4950
ManagedRegionBroker broker;
5051

activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,18 @@ public void testAddVmConnectorBlockedBrokerView() throws Exception {
20702070
testAddTransportConnectorBlockedBrokerView("vm");
20712071
}
20722072

2073+
// Test to verify multicast transport is not allowed to be added as a connector
2074+
// through the Broker MBean
2075+
public void testAddMulticastConnectorBlockedBrokerView() throws Exception {
2076+
testAddTransportConnectorBlockedBrokerView("multicast");
2077+
}
2078+
2079+
// Test to verify zeroconf transport is not allowed to be added as a connector
2080+
// through the Broker MBean
2081+
public void testAddZeroconfConnectorBlockedBrokerView() throws Exception {
2082+
testAddTransportConnectorBlockedBrokerView("zeroconf");
2083+
}
2084+
20732085
protected void testAddTransportConnectorBlockedBrokerView(String scheme) throws Exception {
20742086
ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
20752087
BrokerViewMBean brokerView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);

activemq-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ public void testHttpBridgeBlocked() throws Exception {
8888
testDeniedBridgeBlocked("http");
8989
}
9090

91+
@Test
92+
public void testMulticastBridgeBlocked() throws Exception {
93+
testDeniedBridgeBlocked("multicast");
94+
}
95+
96+
@Test
97+
public void testZeroconfBridgeBlocked() throws Exception {
98+
testDeniedBridgeBlocked("zeroconf");
99+
}
100+
91101
protected void testDeniedBridgeBlocked(String scheme) throws Exception {
92102
// Test composite network connector uri
93103
try {
@@ -97,13 +107,6 @@ protected void testDeniedBridgeBlocked(String scheme) throws Exception {
97107
assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage());
98108
}
99109

100-
try {
101-
proxy.addNetworkConnector("multicast:(" + scheme + "://localhost)");
102-
fail("Should have failed trying to add connector bridge");
103-
} catch (IllegalArgumentException e) {
104-
assertEquals("Transport scheme '" + scheme + "' is not allowed", e.getMessage());
105-
}
106-
107110
// verify direct connector as well
108111
try {
109112
proxy.addNetworkConnector(scheme + "://localhost");

0 commit comments

Comments
 (0)