Search in sources :

Example 1 with PropertiesConfigurationLayout

use of org.apache.commons.configuration.PropertiesConfigurationLayout in project gocd by gocd.

the class AgentAutoRegistrationPropertiesImpl method scrubRegistrationProperties.

@Override
public void scrubRegistrationProperties() {
    if (!exist()) {
        return;
    }
    try {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setIOFactory(new FilteringOutputWriterFactory());
        PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config);
        layout.setLineSeparator("\n");
        layout.load(reader());
        try (FileWriter out = new FileWriter(this.configFile)) {
            layout.save(out);
        }
        loadProperties();
    } catch (ConfigurationException | IOException e) {
        LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e);
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) FileWriter(java.io.FileWriter) IOException(java.io.IOException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Example 2 with PropertiesConfigurationLayout

use of org.apache.commons.configuration.PropertiesConfigurationLayout in project oxTrust by GluuFederation.

the class UpdateCASAction method disable.

public void disable() {
    try {
        log.info("disable() CAS call");
        // enable server-side storage in idp.properties
        String idpConfFolder = shibboleth3ConfService.getIdpConfDir();
        PropertiesConfiguration idpPropertiesConfiguration = new PropertiesConfiguration(idpConfFolder + Shibboleth3ConfService.SHIB3_IDP_PROPERTIES_FILE);
        PropertiesConfigurationLayout layoutConfiguration = new PropertiesConfigurationLayout(idpPropertiesConfiguration);
        // Restore default - client session storage
        layoutConfiguration.getConfiguration().setProperty(IDP_SESSION_STORAGESERVICE, CLIENT_SESSION_STORAGESERVICE);
        layoutConfiguration.getConfiguration().setProperty(IDP_CAS_STORAGESERVICE, configuration.getSessionStorageType());
        layoutConfiguration.getConfiguration().save();
        // disable CAS beans in relying-party.xml
        updateShibboleth3Configuration();
        log.info("disable() CAS - enabled");
    } catch (Exception e) {
        log.error("disable() CAS exception", e);
    }
}
Also used : PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Example 3 with PropertiesConfigurationLayout

use of org.apache.commons.configuration.PropertiesConfigurationLayout in project jangaroo-tools by CoreMedia.

the class PropertiesClass method getProps.

public List<Property> getProps() {
    PropertiesConfigurationLayout layout = properties.getLayout();
    List<Property> props = new ArrayList<Property>();
    Iterator keys = properties.getKeys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        props.add(new Property(adjustComment(layout.getCanonicalComment(key, true)), key, isIdentifier(key), properties.getString(key)));
    }
    return props;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Example 4 with PropertiesConfigurationLayout

use of org.apache.commons.configuration.PropertiesConfigurationLayout in project oxTrust by GluuFederation.

the class UpdateCASAction method enable.

public void enable() {
    try {
        log.info("enable() CAS call");
        // enable server-side storage in idp.properties
        String idpConfFolder = shibboleth3ConfService.getIdpConfDir();
        PropertiesConfiguration idpPropertiesConfiguration = new PropertiesConfiguration(idpConfFolder + Shibboleth3ConfService.SHIB3_IDP_PROPERTIES_FILE);
        PropertiesConfigurationLayout layoutConfiguration = new PropertiesConfigurationLayout(idpPropertiesConfiguration);
        // CAS require server-side storage
        layoutConfiguration.getConfiguration().setProperty(IDP_SESSION_STORAGESERVICE, configuration.getSessionStorageType());
        layoutConfiguration.getConfiguration().setProperty(IDP_CAS_STORAGESERVICE, configuration.getSessionStorageType());
        layoutConfiguration.getConfiguration().save();
        // enable CAS beans in relying-party.xml
        updateShibboleth3Configuration();
        log.info("enable() CAS - enabled");
    } catch (Exception e) {
        log.error("enable() CAS exception", e);
    }
}
Also used : PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Aggregations

PropertiesConfigurationLayout (org.apache.commons.configuration.PropertiesConfigurationLayout)4 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)3 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1