From 444ed8ff230a8459bae36f490afb3886d35c8004 Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 25 Nov 2014 15:30:10 +0000 Subject: [PATCH] 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 --- config/alfresco/application-context-core.xml | 2 + config/alfresco/core-services-context.xml | 6 ++- .../spring/encrypted-properties-context.xml | 15 ++++++ .../AbstractPropertyBackedBean.java | 49 +++++++++++++++++-- 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 config/alfresco/spring/encrypted-properties-context.xml diff --git a/config/alfresco/application-context-core.xml b/config/alfresco/application-context-core.xml index c350107e8c..ec272e3af7 100644 --- a/config/alfresco/application-context-core.xml +++ b/config/alfresco/application-context-core.xml @@ -13,6 +13,8 @@ + + diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 9624c43f87..f8a9094c6a 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -4,8 +4,6 @@ - - @@ -129,6 +127,10 @@ + + + + + + empty + + + + \ No newline at end of file diff --git a/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java b/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java index 0201c9ca91..823db808c9 100644 --- a/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java +++ b/source/java/org/alfresco/repo/management/subsystems/AbstractPropertyBackedBean.java @@ -86,6 +86,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(); @@ -222,6 +225,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); } }