Java Code Examples for org.apache.commons.configuration2.HierarchicalConfiguration#containsKey()

The following examples show how to use org.apache.commons.configuration2.HierarchicalConfiguration#containsKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractStateCompositeProcessor.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() throws Exception {
    List<HierarchicalConfiguration<ImmutableNode>> processorConfs = config.configurationsAt("processor");
    for (HierarchicalConfiguration<ImmutableNode> processorConf : processorConfs) {
        String processorName = processorConf.getString("[@state]");

        // if the "child" processor has no jmx config we just use the one of
        // the composite
        if (!processorConf.containsKey("[@enableJmx]")) {
            processorConf.addProperty("[@enableJmx]", enableJmx);
        }
        processors.put(processorName, createMailProcessor(processorName, processorConf));
    }

    if (enableJmx) {
        this.jmxListener = new JMXStateCompositeProcessorListener(this);
        addListener(jmxListener);
    }

    // check if all needed processors are configured
    checkProcessors();
}
 
Example 2
Source File: ConfigAwareLogoutSuccessHandler.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected String determineTargetUrl(final HttpServletRequest request, final HttpServletResponse response) {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    if (siteConfig != null && siteConfig.containsKey(LOGOUT_SUCCESS_URL_KEY)) {
        return siteConfig.getString(LOGOUT_SUCCESS_URL_KEY);
    }
    return super.determineTargetUrl(request, response);
}
 
Example 3
Source File: ConfigAwareAuthenticationFailureHandler.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
protected String determineFailureUrl() {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    if (siteConfig != null && siteConfig.containsKey(LOGIN_FAILURE_URL_KEY)) {
        return siteConfig.getString(LOGIN_FAILURE_URL_KEY);
    }
    return defaultFailureUrl;
}
 
Example 4
Source File: AbstractHeadersAuthenticationFilter.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
protected String getTokenExpectedValue() {
    HierarchicalConfiguration config = ConfigUtils.getCurrentConfig();
    if (config != null && config.containsKey(HEADERS_TOKEN_CONFIG_KEY)) {
        return config.getString(HEADERS_TOKEN_CONFIG_KEY);
    }
    return defaultTokenValue;
}
 
Example 5
Source File: ConfigAwareAccessDeniedHandler.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
public String getErrorPage() {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    if (siteConfig != null && siteConfig.containsKey(ACCESS_DENIED_ERROR_PAGE_URL_KEY)) {
        return siteConfig.getString(ACCESS_DENIED_ERROR_PAGE_URL_KEY);
    }
    return null;
}
 
Example 6
Source File: ConfigAwareLoginUrlAuthenticationEntryPoint.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected String determineUrlToUseForThisRequest(final HttpServletRequest request,
                                                 final HttpServletResponse response,
                                                 final AuthenticationException exception) {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    if (siteConfig != null && siteConfig.containsKey(LOGIN_FORM_URL_KEY)) {
        return siteConfig.getString(LOGIN_FORM_URL_KEY);
    }
    return super.getLoginFormUrl();
}
 
Example 7
Source File: ProjectConfig.java    From spoofax with Apache License 2.0 5 votes vote down vote up
public ProjectConfig(HierarchicalConfiguration<ImmutableNode> config) {
    super(config);

    // Set metaborgVersion to default if it was not set in the config.
    if(!config.containsKey(PROP_METABORG_VERSION)) {
        config.setProperty(PROP_METABORG_VERSION, MetaborgConstants.METABORG_VERSION);
    }
}
 
Example 8
Source File: LdapRepositoryConfiguration.java    From james-project with Apache License 2.0 4 votes vote down vote up
public static LdapRepositoryConfiguration from(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    String ldapHost = configuration.getString("[@ldapHost]", "");
    String principal = configuration.getString("[@principal]", "");
    String credentials = configuration.getString("[@credentials]", "");
    String userBase = configuration.getString("[@userBase]");
    String userIdAttribute = configuration.getString("[@userIdAttribute]");
    String userObjectClass = configuration.getString("[@userObjectClass]");
    // Default is to use connection pooling
    boolean useConnectionPool = configuration.getBoolean("[@useConnectionPool]", USE_CONNECTION_POOL);
    int connectionTimeout = configuration.getInt("[@connectionTimeout]", NO_CONNECTION_TIMEOUT);
    int readTimeout = configuration.getInt("[@readTimeout]", NO_READ_TIME_OUT);
    // Default maximum retries is 1, which allows an alternate connection to
    // be found in a multi-homed environment
    int maxRetries = configuration.getInt("[@maxRetries]", 1);
    boolean supportsVirtualHosting = configuration.getBoolean(SUPPORTS_VIRTUAL_HOSTING, !ENABLE_VIRTUAL_HOSTING);
    // Default retry start interval is 0 second
    long retryStartInterval = configuration.getLong("[@retryStartInterval]", 0);
    // Default maximum retry interval is 60 seconds
    long retryMaxInterval = configuration.getLong("[@retryMaxInterval]", 60);
    int scale = configuration.getInt("[@retryIntervalScale]", 1000); // seconds

    HierarchicalConfiguration<ImmutableNode> restrictionConfig = null;
    // Check if we have a restriction we can use
    // See JAMES-1204
    if (configuration.containsKey("restriction[@memberAttribute]")) {
        restrictionConfig = configuration.configurationAt("restriction");
    }
    ReadOnlyLDAPGroupRestriction restriction = new ReadOnlyLDAPGroupRestriction(restrictionConfig);

    //see if there is a filter argument
    String filter = configuration.getString("[@filter]");

    Optional<String> administratorId = Optional.ofNullable(configuration.getString("[@administratorId]"));

    return new LdapRepositoryConfiguration(
        ldapHost,
        principal,
        credentials,
        userBase,
        userIdAttribute,
        userObjectClass,
        useConnectionPool,
        connectionTimeout,
        readTimeout,
        maxRetries,
        supportsVirtualHosting,
        retryStartInterval,
        retryMaxInterval,
        scale,
        restriction,
        filter,
        administratorId);
}