Repository: cloudstack Updated Branches: refs/heads/4.5 c15ed74f6 -> c3e5964dc
Fixed CLOUDSTACK-7242: Adding a securing config using configDepo doesnt work In ConfigurationVo, changed the setter to do the encryption if required like the getter. Called the setter in constructor as well. Removed references of encryption check in different places. Reviewed-by: Santhosh Edukulla This closes #35 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c3e5964d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c3e5964d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c3e5964d Branch: refs/heads/4.5 Commit: c3e5964dcbbd3b3ff34562aeeb9f8daa154ee7d1 Parents: c15ed74 Author: Rajani Karuturi <rajanikarut...@gmail.com> Authored: Tue Nov 4 18:16:50 2014 +0530 Committer: Rajani Karuturi <rajanikarut...@gmail.com> Committed: Wed Nov 5 11:49:38 2014 +0530 ---------------------------------------------------------------------- .../config/dao/ConfigurationDaoImpl.java | 3 --- .../framework/config/impl/ConfigurationVO.java | 18 +++++++++++++++--- .../com/cloud/server/ConfigurationServerImpl.java | 3 +-- 3 files changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3e5964d/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java ---------------------------------------------------------------------- diff --git a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java index 2934b01..f3f0495 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java @@ -210,9 +210,6 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String update(name, category, initValue); } } else { - if (category.equals("Hidden") || category.equals("Secure")) { - initValue = DBEncryptionUtil.encrypt(initValue); - } ConfigurationVO newConfig = new ConfigurationVO(category, "DEFAULT", "management-server", name, initValue, desc); persist(newConfig); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3e5964d/framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java ---------------------------------------------------------------------- diff --git a/framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java b/framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java index cda96c9..b317ea2 100644 --- a/framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java +++ b/framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java @@ -73,8 +73,8 @@ public class ConfigurationVO implements Configuration { this.instance = instance; this.component = component; this.name = name; - this.value = value; this.description = description; + setValue(value); } public ConfigurationVO(String component, ConfigKey<?> key) { @@ -122,11 +122,23 @@ public class ConfigurationVO implements Configuration { @Override public String getValue() { - return (("Hidden".equals(getCategory()) || "Secure".equals(getCategory())) ? DBEncryptionUtil.decrypt(value) : value); + if(isEncryptedConfig()) { + return DBEncryptionUtil.decrypt(value); + } else { + return value; + } } public void setValue(String value) { - this.value = value; + if(isEncryptedConfig()) { + this.value = DBEncryptionUtil.encrypt(value); + } else { + this.value = value; + } + } + + private boolean isEncryptedConfig() { + return "Hidden".equals(getCategory()) || "Secure".equals(getCategory()); } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c3e5964d/server/src/com/cloud/server/ConfigurationServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 990f2ff..7b0d898 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -203,7 +203,6 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio String instance = "DEFAULT"; String component = c.getComponent(); String value = c.getDefaultValue(); - value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value; String description = c.getDescription(); ConfigurationVO configVO = new ConfigurationVO(category, instance, component, name, value, description); configVO.setDefaultValue(value); @@ -635,7 +634,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } String base64Keystore = getBase64Keystore(keystorePath); ConfigurationVO configVO = - new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", DBEncryptionUtil.encrypt(base64Keystore), + new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", base64Keystore, "SSL Keystore for the management servers"); _configDao.persist(configVO); s_logger.info("Stored SSL keystore to database.");