use of org.candlepin.common.config.EncryptedConfiguration in project candlepin by candlepin.
the class CandlepinContextListener method readConfiguration.
protected Configuration readConfiguration(ServletContext context) throws ConfigurationException {
// Use StandardCharsets.UTF_8 when we move to Java 7
Charset utf8 = Charset.forName("UTF-8");
EncryptedConfiguration systemConfig = new EncryptedConfiguration();
systemConfig.setEncoding(utf8);
File configFile = new File(ConfigProperties.DEFAULT_CONFIG_FILE);
if (configFile.canRead()) {
log.debug("Loading system configuration");
// First, read the system configuration
systemConfig.load(configFile);
log.debug("System configuration: " + systemConfig);
}
systemConfig.use(PASSPHRASE_SECRET_FILE).toDecrypt(ENCRYPTED_PROPERTIES);
// load the defaults
MapConfiguration defaults = new MapConfiguration(ConfigProperties.DEFAULT_PROPERTIES);
// Default to Postgresql if jpa.config.hibernate.dialect is unset
DatabaseConfigFactory.SupportedDatabase db = determinDatabaseConfiguration(systemConfig.getString("jpa.config.hibernate.dialect", PostgreSQLDialect.class.getName()));
log.info("Running under {}", db.getLabel());
Configuration databaseConfig = DatabaseConfigFactory.fetchConfig(db);
// users should be doing unbidden so it is undocumented.
return EncryptedConfiguration.merge(systemConfig, databaseConfig, defaults);
}
Aggregations