ARTEMIS-1492 obfuscate passwords in acceptorControl
This commit is contained in:
parent
5a89fcd098
commit
096d98407f
|
@ -18,6 +18,7 @@ package org.apache.activemq.artemis.core.management.impl;
|
||||||
|
|
||||||
import javax.management.MBeanAttributeInfo;
|
import javax.management.MBeanAttributeInfo;
|
||||||
import javax.management.MBeanOperationInfo;
|
import javax.management.MBeanOperationInfo;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||||
|
@ -73,7 +74,13 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
||||||
public Map<String, Object> getParameters() {
|
public Map<String, Object> getParameters() {
|
||||||
clearIO();
|
clearIO();
|
||||||
try {
|
try {
|
||||||
return configuration.getParams();
|
Map<String, Object> clone = new HashMap(configuration.getParams());
|
||||||
|
for (Map.Entry<String, Object> entry : clone.entrySet()) {
|
||||||
|
if (entry.getKey().toLowerCase().contains("password")) {
|
||||||
|
entry.setValue("****");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return clone;
|
||||||
} finally {
|
} finally {
|
||||||
blockOnIO();
|
blockOnIO();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
|
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
|
||||||
|
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.core.server.management.Notification;
|
import org.apache.activemq.artemis.core.server.management.Notification;
|
||||||
import org.apache.activemq.artemis.tests.integration.SimpleNotificationService;
|
import org.apache.activemq.artemis.tests.integration.SimpleNotificationService;
|
||||||
|
@ -50,6 +51,7 @@ public class AcceptorControlTest extends ManagementTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testAttributes() throws Exception {
|
public void testAttributes() throws Exception {
|
||||||
TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
|
TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
|
||||||
|
acceptorConfig.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "password");
|
||||||
|
|
||||||
Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
|
Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
|
||||||
ActiveMQServer service = createServer(false, config);
|
ActiveMQServer service = createServer(false, config);
|
||||||
|
@ -60,6 +62,8 @@ public class AcceptorControlTest extends ManagementTestBase {
|
||||||
|
|
||||||
Assert.assertEquals(acceptorConfig.getName(), acceptorControl.getName());
|
Assert.assertEquals(acceptorConfig.getName(), acceptorControl.getName());
|
||||||
Assert.assertEquals(acceptorConfig.getFactoryClassName(), acceptorControl.getFactoryClassName());
|
Assert.assertEquals(acceptorConfig.getFactoryClassName(), acceptorControl.getFactoryClassName());
|
||||||
|
Assert.assertNotEquals(acceptorConfig.getParams().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME), acceptorControl.getParameters().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME));
|
||||||
|
Assert.assertEquals("****", acceptorControl.getParameters().get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue