Java 类org.apache.commons.configuration.PropertiesConfigurationLayout 实例源码

项目:oxTrust    文件:UpdateCASAction.java   
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);
    }
}
项目:oxTrust    文件:UpdateCASAction.java   
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);
    }
}
项目:gocd    文件:AgentAutoRegistrationPropertiesImpl.java   
@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);
    }
}
项目:Equella    文件:UpgradeToEmbeddedTomcat.java   
private void updateMandatoryProperties(final UpgradeResult result, File configDir) throws ConfigurationException,
    IOException
{
    PropertyFileModifier propMod = new PropertyFileModifier(new File(configDir,
        PropertyFileModifier.MANDATORY_CONFIG))
    {
        @Override
        protected boolean modifyProperties(PropertiesConfiguration props)
        {
            // Add Tomcat ports
            String url = (String) props.getProperty("admin.url");
            String port = getPort(url);
            String tomcatComment = System.lineSeparator()
                + "# Tomcat ports. Specify the ports Tomcat should create connectors for";
            PropertiesConfigurationLayout layout = props.getLayout();
            layout.setLineSeparator(System.lineSeparator());
            if( url.contains("https") )
            {
                String httpsProp = "https.port";
                props.setProperty(httpsProp, port);
                layout.setComment(httpsProp, tomcatComment);
                props.setProperty("#http.port", "");
            }
            else
            {
                String httpProp = "http.port";
                props.setProperty(httpProp, port);
                layout.setComment(httpProp, tomcatComment);
                props.setProperty("#https.port", "");
            }
            props.setProperty("#ajp.port", "8009");

            // Remove Tomcat location
            props.clearProperty("tomcat.location");

            return true;
        }
    };
    propMod.updateProperties();
}