use of com.cloud.utils.crypt.EncryptionSecretKeyChecker in project cloudstack by apache.
the class DbProperties method wrapEncryption.
protected static Properties wrapEncryption(Properties dbProps) throws IOException {
EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker();
checker.check(dbProps);
if (EncryptionSecretKeyChecker.useEncryption()) {
return dbProps;
} else {
EncryptableProperties encrProps = new EncryptableProperties(EncryptionSecretKeyChecker.getEncryptor());
encrProps.putAll(dbProps);
return encrProps;
}
}
use of com.cloud.utils.crypt.EncryptionSecretKeyChecker in project cloudstack by apache.
the class DbProperties method getDbProperties.
public static synchronized Properties getDbProperties() {
if (!loaded) {
Properties dbProps = new Properties();
InputStream is = null;
try {
File props = PropertiesUtil.findConfigFile("db.properties");
if (props != null && props.exists()) {
is = new FileInputStream(props);
}
if (is == null) {
is = PropertiesUtil.openStreamFromURL("db.properties");
}
if (is == null) {
System.err.println("Failed to find db.properties");
log.error("Failed to find db.properties");
}
if (is != null) {
dbProps.load(is);
}
EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker();
checker.check(dbProps);
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
EncryptableProperties encrDbProps = new EncryptableProperties(encryptor);
encrDbProps.putAll(dbProps);
dbProps = encrDbProps;
}
} catch (IOException e) {
throw new IllegalStateException("Failed to load db.properties", e);
} finally {
IOUtils.closeQuietly(is);
}
properties = dbProps;
loaded = true;
}
return properties;
}
Aggregations