From a2ed3fa5e2fc620ac2145b212ed396d46c2b654d Mon Sep 17 00:00:00 2001 From: kishan Date: Tue, 20 Dec 2011 15:06:39 +0530 Subject: [PATCH] bug 12337: encrypt Hidden category config values only reviewed-by: Abhi --- .../configuration/ConfigurationManager.java | 2 +- .../ConfigurationManagerImpl.java | 11 ++++++----- .../configuration/dao/ConfigurationDao.java | 2 ++ .../dao/ConfigurationDaoImpl.java | 19 ++++++++++++++++++- .../consoleproxy/ConsoleProxyManagerImpl.java | 6 +++--- .../cloud/server/ConfigurationServerImpl.java | 17 +++++++++-------- 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index 0c000550adf..6d05044a202 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -59,7 +59,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager { * @param name * @param value */ - void updateConfiguration(long userId, String name, String value); + void updateConfiguration(long userId, String name, String category, String value); /** * Creates a new service offering diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 57bf4ab456a..b18ca5e1312 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -299,7 +299,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura s_logger.warn("Management network CIDR is not configured originally. Set it default to " + localCidrs[0]); _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management network CIDR is not configured originally. Set it default to " + localCidrs[0], ""); - _configDao.update(Config.ManagementNetwork.key(), localCidrs[0]); + _configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]); } else { s_logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management network CIDR is not properly configured and we are not able to find a default setting", ""); @@ -316,7 +316,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura @Override @DB - public void updateConfiguration(long userId, String name, String value) { + public void updateConfiguration(long userId, String name, String category, String value) { if (value != null && (value.trim().isEmpty() || value.equals("null"))) { value = null; } @@ -332,7 +332,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura Transaction txn = Transaction.currentTxn(); txn.start(); - if (!_configDao.update(name, value)) { + if (!_configDao.update(name, category, value)) { s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value); throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support."); } @@ -435,7 +435,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura String value = cmd.getValue(); UserContext.current().setEventDetails(" Name: " + name + " New Value: " + ((value == null) ? "" : value)); // check if config value exists - if (_configDao.findByName(name) == null) { + ConfigurationVO config = _configDao.findByName(name); + if (config == null) { throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist"); } @@ -443,7 +444,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura return _configDao.findByName(name); } - updateConfiguration(userId, name, value); + updateConfiguration(userId, name, config.getCategory(), value); if (_configDao.getValue(name).equalsIgnoreCase(value)) { return _configDao.findByName(name); } else { diff --git a/server/src/com/cloud/configuration/dao/ConfigurationDao.java b/server/src/com/cloud/configuration/dao/ConfigurationDao.java index 8d1ff17d709..25340b5a1b5 100644 --- a/server/src/com/cloud/configuration/dao/ConfigurationDao.java +++ b/server/src/com/cloud/configuration/dao/ConfigurationDao.java @@ -69,4 +69,6 @@ public interface ConfigurationDao extends GenericDao { boolean isPremium(); ConfigurationVO findByName(String name); + + boolean update(String name, String category, String value); } diff --git a/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java b/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java index 4c180341fc7..88b615eddda 100644 --- a/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java +++ b/server/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java @@ -122,7 +122,8 @@ public class ConfigurationDaoImpl extends GenericDaoBase