ACE-2919 - ACE-2836 Not all properties can be used when they were encrypted by the Encrypted Properties Management tool

- made encrypted properties work with subsystems.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@91072 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-11-25 15:30:10 +00:00
parent 2012116cf9
commit 444ed8ff23
4 changed files with 67 additions and 5 deletions

View File

@@ -13,6 +13,8 @@
<import resource="classpath*:alfresco/extension/mt/mt-context.xml"/>
<import resource="classpath:alfresco/encryption-context.xml" />
<import resource="classpath*:alfresco/enterprise/jmx/jmx-context.xml" />
<import resource="classpath:alfresco/spring/*-context.xml" />
<import resource="classpath*:alfresco/enterprise/spring/*-context.xml" />
<import resource="classpath:alfresco/core-services-context.xml" />
<import resource="classpath:alfresco/copy-services-context.xml" />
<import resource="classpath:alfresco/public-services-context.xml" />

View File

@@ -4,8 +4,6 @@
<!-- Core and miscellaneous bean definitions -->
<beans>
<!-- -->
<!-- PERSISTENCE -->
<!-- -->
@@ -129,6 +127,10 @@
<property name="propertyDefaults">
<ref local="global-properties" />
</property>
<property name="encryptedPropertyDefaults">
<ref bean="encrypted-properties" />
</property>
</bean>
<!--

View File

@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<util:map id="encrypted-properties" >
<!-- A dummy value -->
<entry key="empty.enc" >
<value>empty</value>
</entry>
</util:map>
</beans>

View File

@@ -87,6 +87,9 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
/** Property defaults provided by the installer or System properties. */
private Properties propertyDefaults;
/** Property defaults provided by the JASYPT decryptor. */
private Properties encryptedPropertyDefaults;
/** Resolves placeholders in the property defaults. */
private DefaultResolver defaultResolver = new DefaultResolver();
@@ -223,6 +226,12 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.propertyDefaults = propertyDefaults;
}
public void setEncryptedPropertyDefaults(Properties propertyDefaults)
{
this.encryptedPropertyDefaults = propertyDefaults;
}
/**
* Gets the property defaults provided by the installer or System properties.
*
@@ -242,7 +251,25 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/
protected String resolveDefault(String name)
{
String value = this.propertyDefaults.getProperty(name);
Properties props = new Properties();
if(propertyDefaults != null)
{
for( Object key : propertyDefaults.keySet())
{
props.setProperty((String)key, propertyDefaults.getProperty((String)key));
}
}
if(encryptedPropertyDefaults != null)
{
for( Object key : encryptedPropertyDefaults.keySet())
{
props.setProperty((String)key, encryptedPropertyDefaults.getProperty((String)key));
}
}
String value = props.getProperty(name);
if (value != null)
{
value = this.defaultResolver.resolveValue(value);
@@ -1094,8 +1121,24 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/
public String resolveValue(String val)
{
return AbstractPropertyBackedBean.this.propertyDefaults == null ? null : replacePlaceholders(
val, AbstractPropertyBackedBean.this.propertyDefaults);
Properties props = new Properties();
if(propertyDefaults != null)
{
for( Object key : propertyDefaults.keySet())
{
props.setProperty((String)key, propertyDefaults.getProperty((String)key));
}
}
if(encryptedPropertyDefaults != null)
{
for( Object key : encryptedPropertyDefaults.keySet())
{
props.setProperty((String)key, encryptedPropertyDefaults.getProperty((String)key));
}
}
return replacePlaceholders(val, props);
}
}