use of org.apache.commons.configuration2.FileBasedConfiguration in project cas by apereo.
the class CasConfigurationPropertiesEnvironmentManager method savePropertyForStandaloneProfile.
/**
* Save property for standalone profile.
*
* @param pair the pair
*/
@SneakyThrows
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
final File file = getStandaloneProfileConfigurationDirectory();
final Parameters params = new Parameters();
final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class).configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));
final Configuration config = builder.getConfiguration();
config.setProperty(pair.getKey(), pair.getValue());
builder.save();
}
use of org.apache.commons.configuration2.FileBasedConfiguration in project ranger by apache.
the class LdapConfig method updateInputPropFile.
public void updateInputPropFile(String ldapUrl, String bindDn, String bindPassword, String userSearchBase, String userSearchFilter, String authUser, String authPass) {
try {
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class).configure(params.fileBased().setFileName(CONFIG_FILE));
FileBasedConfiguration config = builder.getConfiguration();
// Update properties in memory and update the file as well
prop.setProperty(LGSYNC_LDAP_URL, ldapUrl);
prop.setProperty(LGSYNC_LDAP_BIND_DN, bindDn);
prop.setProperty(LGSYNC_LDAP_BIND_PASSWORD, bindPassword);
prop.setProperty(LGSYNC_USER_SEARCH_BASE, userSearchBase);
prop.setProperty(LGSYNC_USER_SEARCH_FILTER, userSearchFilter);
prop.setProperty(AUTH_USERNAME, authUser);
prop.setProperty(AUTH_PASSWORD, authPass);
config.setProperty(LGSYNC_LDAP_URL, ldapUrl);
config.setProperty(LGSYNC_LDAP_BIND_DN, bindDn);
// config.setProperty(LGSYNC_LDAP_BIND_PASSWORD, bindPassword);
config.setProperty(LGSYNC_USER_SEARCH_BASE, userSearchBase);
config.setProperty(LGSYNC_USER_SEARCH_FILTER, userSearchFilter);
config.setProperty(AUTH_USERNAME, authUser);
// config.setProperty(AUTH_PASSWORD, authPass);
builder.save();
} catch (ConfigurationException e) {
System.out.println("Failed to update " + CONFIG_FILE + ": " + e);
}
}
Aggregations