ARTEMIS-1846 fix activemq.usemaskedpassword in URL
This commit is contained in:
parent
541dfc6951
commit
a6fe25599c
|
@ -162,7 +162,13 @@ public class ConfigurationHelper {
|
|||
}
|
||||
|
||||
String value = prop.toString();
|
||||
Boolean useMask = (Boolean) props.get(defaultMaskPassword);
|
||||
Object useMaskObject = props.get(defaultMaskPassword);
|
||||
Boolean useMask;
|
||||
if (useMaskObject instanceof String) {
|
||||
useMask = Boolean.parseBoolean((String)useMaskObject);
|
||||
} else {
|
||||
useMask = (Boolean) useMaskObject;
|
||||
}
|
||||
final String classImpl = (String) props.get(defaultPasswordCodec);
|
||||
try {
|
||||
return PasswordMaskingUtil.resolveMask(useMask, value, classImpl);
|
||||
|
|
|
@ -44,6 +44,8 @@ import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
|
||||
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -132,6 +134,84 @@ public class CoreClientOverOneWaySSLTest extends ActiveMQTestBase {
|
|||
Assert.assertEquals(text, m.getBodyBuffer().readString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneWaySSLwithURL() throws Exception {
|
||||
createCustomSslServer();
|
||||
String text = RandomUtil.randomString();
|
||||
|
||||
ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider=" + storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=" + PASSWORD));
|
||||
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
|
||||
ClientSession session = addClientSession(sf.createSession(false, true, true));
|
||||
session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false);
|
||||
ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
|
||||
ClientMessage message = createTextMessage(session, text);
|
||||
producer.send(message);
|
||||
|
||||
ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
session.start();
|
||||
|
||||
ClientMessage m = consumer.receive(1000);
|
||||
Assert.assertNotNull(m);
|
||||
Assert.assertEquals(text, m.getBodyBuffer().readString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneWaySSLwithURLandMaskedPasswordProperty() throws Exception {
|
||||
createCustomSslServer();
|
||||
String text = RandomUtil.randomString();
|
||||
|
||||
DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
codec.init(params);
|
||||
|
||||
String masked = codec.encode(PASSWORD);
|
||||
|
||||
ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider=" + storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=" + masked + ";activemq.usemaskedpassword=true"));
|
||||
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
|
||||
ClientSession session = addClientSession(sf.createSession(false, true, true));
|
||||
session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false);
|
||||
ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
|
||||
ClientMessage message = createTextMessage(session, text);
|
||||
producer.send(message);
|
||||
|
||||
ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
session.start();
|
||||
|
||||
ClientMessage m = consumer.receive(1000);
|
||||
Assert.assertNotNull(m);
|
||||
Assert.assertEquals(text, m.getBodyBuffer().readString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneWaySSLwithURLandMaskedPasswordENCSyntax() throws Exception {
|
||||
createCustomSslServer();
|
||||
String text = RandomUtil.randomString();
|
||||
|
||||
DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
codec.init(params);
|
||||
|
||||
String masked = codec.encode(PASSWORD);
|
||||
|
||||
ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider=" + storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=ENC(" + masked + ")"));
|
||||
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
|
||||
ClientSession session = addClientSession(sf.createSession(false, true, true));
|
||||
session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false);
|
||||
ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
|
||||
ClientMessage message = createTextMessage(session, text);
|
||||
producer.send(message);
|
||||
|
||||
ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
|
||||
session.start();
|
||||
|
||||
ClientMessage m = consumer.receive(1000);
|
||||
Assert.assertNotNull(m);
|
||||
Assert.assertEquals(text, m.getBodyBuffer().readString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneWaySSLUsingDefaultSslContext() throws Exception {
|
||||
createCustomSslServer();
|
||||
|
|
Loading…
Reference in New Issue