ARTEMIS-1492 obfuscate passwords in acceptorControl

This commit is contained in:
Justin Bertram 2017-11-01 11:54:01 -05:00 committed by Clebert Suconic
parent 5a89fcd098
commit 096d98407f
2 changed files with 12 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package org.apache.activemq.artemis.core.management.impl;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
@ -73,7 +74,13 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
public Map<String, Object> getParameters() {
clearIO();
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 {
blockOnIO();
}

View File

@ -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.remoting.impl.invm.InVMAcceptorFactory;
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.management.Notification;
import org.apache.activemq.artemis.tests.integration.SimpleNotificationService;
@ -50,6 +51,7 @@ public class AcceptorControlTest extends ManagementTestBase {
@Test
public void testAttributes() throws Exception {
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);
ActiveMQServer service = createServer(false, config);
@ -60,6 +62,8 @@ public class AcceptorControlTest extends ManagementTestBase {
Assert.assertEquals(acceptorConfig.getName(), acceptorControl.getName());
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