ARTEMIS-3041 Allow encrypted data source property values
This commit is contained in:
parent
a0f464b816
commit
0456b8845a
|
@ -230,6 +230,10 @@ public class DatabaseStorageConfiguration implements StoreConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
public String getDataSourceProperty(String key) {
|
||||
return (String)dataSourceProperties.get(key);
|
||||
}
|
||||
|
||||
public String getDataSourceClassName() {
|
||||
return dataSourceClassName;
|
||||
}
|
||||
|
|
|
@ -1764,7 +1764,12 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
NodeList propertyNodeList = storeNode.getElementsByTagName("data-source-property");
|
||||
for (int i = 0; i < propertyNodeList.getLength(); i++) {
|
||||
Element propertyNode = (Element) propertyNodeList.item(i);
|
||||
conf.addDataSourceProperty(propertyNode.getAttributeNode("key").getValue(), propertyNode.getAttributeNode("value").getValue());
|
||||
final String propertyName = propertyNode.getAttributeNode("key").getValue();
|
||||
String propertyValue = propertyNode.getAttributeNode("value").getValue();
|
||||
if (propertyValue != null && PasswordMaskingUtil.isEncMasked(propertyValue)) {
|
||||
propertyValue = PasswordMaskingUtil.resolveMask(mainConfig.isMaskPassword(), propertyValue, mainConfig.getPasswordCodec());
|
||||
}
|
||||
conf.addDataSourceProperty(propertyName, propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,16 @@ public class DatabaseStoreConfigurationTest extends ActiveMQTestBase {
|
|||
assertEquals("targetpassword", storeConfiguration.getJdbcPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void databaseStoreConfigWithDataSourceTest() throws Exception {
|
||||
Configuration configuration = createConfiguration("database-store-with-data-source-config.xml");
|
||||
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
|
||||
DatabaseStorageConfiguration storeConfiguration = (DatabaseStorageConfiguration) server.getConfiguration().getStoreConfiguration();
|
||||
assertEquals(StoreConfiguration.StoreType.DATABASE, storeConfiguration.getStoreType());
|
||||
assertEquals("sourcepassword", storeConfiguration.getDataSourceProperty("username"));
|
||||
assertEquals("targetpassword", storeConfiguration.getDataSourceProperty("password"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOracle12TableSize() {
|
||||
for (SQLProvider.DatabaseStoreType storeType : SQLProvider.DatabaseStoreType.values()) {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<configuration
|
||||
xmlns="urn:activemq"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:activemq ../../main/resources/schema/artemis-server.xsd">
|
||||
<core xmlns="urn:activemq:core">
|
||||
<store>
|
||||
<database-store>
|
||||
<data-source-properties>
|
||||
<!-- All configuration options: https://commons.apache.org/proper/commons-dbcp/configuration.html -->
|
||||
<data-source-property key="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
|
||||
<data-source-property key="url" value="jdbc:derby:target/derby/database-store;create=true" />
|
||||
<data-source-property key="username" value="ENC(5493dd76567ee5ec269d11823973462f)" />
|
||||
<data-source-property key="password" value="ENC(56a0db3b71043054269d11823973462f)" />
|
||||
<data-source-property key="poolPreparedStatements" value="true" />
|
||||
<data-source-property key="maxConnLifetimeMillis" value="1800000" />
|
||||
</data-source-properties>
|
||||
|
||||
<bindings-table-name>BINDINGS_TABLE</bindings-table-name>
|
||||
<message-table-name>MESSAGE_TABLE</message-table-name>
|
||||
<large-message-table-name>LARGE_MESSAGE_TABLE</large-message-table-name>
|
||||
<page-store-table-name>PAGE_STORE_TABLE</page-store-table-name>
|
||||
</database-store>
|
||||
</store>
|
||||
</core>
|
||||
</configuration>
|
Loading…
Reference in New Issue