ARTEMIS-2976 Remove password before creating server locator
This commit is contained in:
parent
71a9cbb53a
commit
14ec3cb7b0
|
@ -71,6 +71,10 @@ public class BeanSupport {
|
|||
return obj;
|
||||
}
|
||||
|
||||
public static <T> void stripPasswords(Map<String, T> properties) {
|
||||
properties.entrySet().removeIf(entry -> entry.getKey().toLowerCase().contains("password"));
|
||||
}
|
||||
|
||||
public static <P> P setProperties(P bean, Properties properties)
|
||||
throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
|
||||
synchronized (beanUtils) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public class InVMServerLocatorSchema extends AbstractServerLocatorSchema {
|
|||
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
|
||||
TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory");
|
||||
ServerLocator factory = ActiveMQClient.createServerLocatorWithoutHA(tc);
|
||||
BeanSupport.stripPasswords(query);
|
||||
return BeanSupport.setData(uri, factory, query);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@ public class JGroupsServerLocatorSchema extends AbstractServerLocatorSchema {
|
|||
|
||||
@Override
|
||||
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
|
||||
DiscoveryGroupConfiguration dcConfig = getDiscoveryGroupConfiguration(uri, query, name);
|
||||
|
||||
BeanSupport.stripPasswords(query);
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
if (options.isHa()) {
|
||||
return ActiveMQClient.createServerLocatorWithHA(dcConfig);
|
||||
} else {
|
||||
|
|
|
@ -39,11 +39,12 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
|||
|
||||
@Override
|
||||
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
|
||||
List<TransportConfiguration> configurations = TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
|
||||
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
|
||||
configurations.toArray(tcs);
|
||||
|
||||
BeanSupport.stripPasswords(query);
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
if (options.isHa()) {
|
||||
return BeanSupport.setData(uri, ActiveMQClient.createServerLocatorWithHA(tcs), query);
|
||||
} else {
|
||||
|
|
|
@ -44,10 +44,11 @@ public class UDPServerLocatorSchema extends AbstractServerLocatorSchema {
|
|||
|
||||
@Override
|
||||
protected ServerLocator internalNewObject(URI uri, Map<String, String> query, String name) throws Exception {
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
|
||||
DiscoveryGroupConfiguration dgc = getDiscoveryGroupConfiguration(uri, query, getHost(uri), getPort(uri), name);
|
||||
|
||||
BeanSupport.stripPasswords(query);
|
||||
ConnectionOptions options = newConnectionOptions(uri, query);
|
||||
if (options.isHa()) {
|
||||
return ActiveMQClient.createServerLocatorWithHA(dgc);
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ProtonProtocolManagerFactory extends AbstractProtocolManagerFactory
|
|||
final Map<String, Object> parameters,
|
||||
List<BaseInterceptor> incomingInterceptors,
|
||||
List<BaseInterceptor> outgoingInterceptors) throws Exception {
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new ProtonProtocolManager(this, server, incomingInterceptors, outgoingInterceptors), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class HornetQProtocolManagerFactory extends CoreProtocolManagerFactory {
|
|||
hqIncoming.add(new HQFilterConversionInterceptor());
|
||||
hqOutgoing.add(new HQPropertiesConversionInterceptor(false));
|
||||
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new HornetQProtocolManager(this, server, hqIncoming, hqOutgoing), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MQTTProtocolManagerFactory extends AbstractProtocolManagerFactory<M
|
|||
final Map<String, Object> parameters,
|
||||
List<BaseInterceptor> incomingInterceptors,
|
||||
List<BaseInterceptor> outgoingInterceptors) throws Exception {
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new MQTTProtocolManager(server, connectedClients, sessionStates, incomingInterceptors, outgoingInterceptors), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class OpenWireProtocolManagerFactory extends AbstractProtocolManagerFacto
|
|||
Map<String, Object> parameters,
|
||||
final List<BaseInterceptor> incomingInterceptors,
|
||||
List<BaseInterceptor> outgoingInterceptors) throws Exception {
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new OpenWireProtocolManager(this, server), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class StompProtocolManagerFactory extends AbstractProtocolManagerFactory<
|
|||
final Map<String, Object> parameters,
|
||||
final List<BaseInterceptor> incomingInterceptors,
|
||||
List<BaseInterceptor> outgoingInterceptors) throws Exception {
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new StompProtocolManager(this, server, filterInterceptors(incomingInterceptors), filterInterceptors(outgoingInterceptors)), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CoreProtocolManagerFactory extends AbstractProtocolManagerFactory<I
|
|||
Map<String, Object> parameters,
|
||||
final List<BaseInterceptor> incomingInterceptors,
|
||||
List<BaseInterceptor> outgoingInterceptors) throws Exception {
|
||||
stripPasswordParameters(parameters);
|
||||
BeanSupport.stripPasswords(parameters);
|
||||
return BeanSupport.setData(new CoreProtocolManager(this, server, filterInterceptors(incomingInterceptors), filterInterceptors(outgoingInterceptors)), parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.activemq.artemis.spi.core.protocol;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.BaseInterceptor;
|
||||
|
@ -51,18 +50,6 @@ public abstract class AbstractProtocolManagerFactory<P extends BaseInterceptor>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* org.apache.commons.beanutils.BeanUtils will log all the parameters so we strip out any password parameters
|
||||
* (e.g. passwords for SSL keystore and truststore)
|
||||
*
|
||||
* @param parameters
|
||||
*/
|
||||
protected void stripPasswordParameters(Map<String, Object> parameters) {
|
||||
if (parameters != null) {
|
||||
parameters.entrySet().removeIf(entries -> entries.getKey().toLowerCase().contains("password"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProtocolServices(ActiveMQServer server, List<ActiveMQComponent> services) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue