Skip to content

Commit 4c5f792

Browse files
committed
Merge branch '4.5'
2 parents 2b1ca20 + 2cd4ad2 commit 4c5f792

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ public String getValueAndInitIfNotExist(String name, String category, String ini
210210
update(name, category, initValue);
211211
}
212212
} else {
213-
if (category.equals("Hidden") || category.equals("Secure")) {
214-
initValue = DBEncryptionUtil.encrypt(initValue);
215-
}
216213
ConfigurationVO newConfig = new ConfigurationVO(category, "DEFAULT", "management-server", name, initValue, desc);
217214
persist(newConfig);
218215
}

framework/config/src/org/apache/cloudstack/framework/config/impl/ConfigurationVO.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public ConfigurationVO(String category, String instance, String component, Strin
7373
this.instance = instance;
7474
this.component = component;
7575
this.name = name;
76-
this.value = value;
7776
this.description = description;
77+
setValue(value);
7878
}
7979

8080
public ConfigurationVO(String component, ConfigKey<?> key) {
@@ -122,11 +122,23 @@ public void setName(String name) {
122122

123123
@Override
124124
public String getValue() {
125-
return (("Hidden".equals(getCategory()) || "Secure".equals(getCategory())) ? DBEncryptionUtil.decrypt(value) : value);
125+
if(isEncryptedConfig()) {
126+
return DBEncryptionUtil.decrypt(value);
127+
} else {
128+
return value;
129+
}
126130
}
127131

128132
public void setValue(String value) {
129-
this.value = value;
133+
if(isEncryptedConfig()) {
134+
this.value = DBEncryptionUtil.encrypt(value);
135+
} else {
136+
this.value = value;
137+
}
138+
}
139+
140+
private boolean isEncryptedConfig() {
141+
return "Hidden".equals(getCategory()) || "Secure".equals(getCategory());
130142
}
131143

132144
@Override

server/src/com/cloud/server/ConfigurationServerImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ public void persistDefaultValues() throws InternalErrorException {
203203
String instance = "DEFAULT";
204204
String component = c.getComponent();
205205
String value = c.getDefaultValue();
206-
value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value;
207206
String description = c.getDescription();
208207
ConfigurationVO configVO = new ConfigurationVO(category, instance, component, name, value, description);
209208
configVO.setDefaultValue(value);
@@ -635,7 +634,7 @@ protected void updateSSLKeystore() {
635634
}
636635
String base64Keystore = getBase64Keystore(keystorePath);
637636
ConfigurationVO configVO =
638-
new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", DBEncryptionUtil.encrypt(base64Keystore),
637+
new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", base64Keystore,
639638
"SSL Keystore for the management servers");
640639
_configDao.persist(configVO);
641640
s_logger.info("Stored SSL keystore to database.");

0 commit comments

Comments
 (0)