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

The following examples show how to use org.apache.commons.configuration2.HierarchicalConfiguration#getBoolean() . 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: IMAPServer.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Override
public void doConfigure(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    
    super.doConfigure(configuration);
    
    hello = softwaretype + " Server " + getHelloName() + " is ready.";
    compress = configuration.getBoolean("compress", false);
    maxLineLength = configuration.getInt("maxLineLength", DEFAULT_MAX_LINE_LENGTH);
    inMemorySizeLimit = configuration.getInt("inMemorySizeLimit", DEFAULT_IN_MEMORY_SIZE_LIMIT);
    literalSizeLimit = configuration.getInt("literalSizeLimit", DEFAULT_LITERAL_SIZE_LIMIT);

    plainAuthDisallowed = configuration.getBoolean("plainAuthDisallowed", false);
    timeout = configuration.getInt("timeout", DEFAULT_TIMEOUT);
    if (timeout < DEFAULT_TIMEOUT) {
        throw new ConfigurationException("Minimum timeout of 30 minutes required. See rfc2060 5.4 for details");
    }
    
    if (timeout < 0) {
        timeout = 0;
    }

    processor.configure(getImapConfiguration(configuration));
}
 
Example 2
Source File: GlobalRepoUpgradeOperation.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    overwrite = config.getBoolean(CONFIG_KEY_OVERWRITE, true);
    List<HierarchicalConfiguration<ImmutableNode>> fileMappings = config.configurationsAt(CONFIG_KEY_FILES);
    for (HierarchicalConfiguration<ImmutableNode> fileMapping : fileMappings) {
        String src = fileMapping.getString(CONFIG_KEY_SRC);
        String dest = fileMapping.getString(CONFIG_KEY_DEST);

        if (StringUtils.isEmpty(src)) {
            throw new IllegalStateException("'" + CONFIG_KEY_SRC + "' config key not specified");
        }
        if (StringUtils.isEmpty(dest)) {
            throw new IllegalStateException("'" + CONFIG_KEY_DEST + "' config key not specified");
        }

        files.put(loadResource(src), dest);
    }
}
 
Example 3
Source File: AuthenticationProviderFactory.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
private static LdapAuthenticationProvider createLdapAuthenticationProvider(HierarchicalConfiguration<ImmutableNode> providerConfig) {
    LdapAuthenticationProvider provider = new LdapAuthenticationProvider();
    boolean enabled = providerConfig.getBoolean(AUTHENTICATION_CHAIN_PROVIDER_ENABLED);
    provider.setEnabled(enabled);
    provider.setLdapUrl(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LDAP_URL));
    provider.setLdapUsername(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LDAP_USERNAME));
    provider.setLdapPassword(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LDAP_PASSWORD));
    provider.setLdapBaseContext(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LDAP_BASE_CONTEXT));
    provider.setUsernameLdapAttribute(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_USERNAME_LDAP_ATTIBUTE));
    provider.setFirstNameLdapAttribute(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_FIRST_NAME_LDAP_ATTRIBUTE));
    provider.setLastNameLdapAttribute(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LAST_NAME_LDAP_ATTRIBUTE));
    provider.setEmailLdapAttribute(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_EMAIL_LDAP_ATTRIBUTE));
    provider.setGroupNameLdapAttribute(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_GROUP_NAME_LDAP_ATTRIBUTE));
    provider.setGroupNameLdapAttributeRegex(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_GROUP_NAME_REGEX_LDAP_ATTRIBUTE));
    provider.setGroupNameLdapAttributeMatchIndex(
            Integer.parseInt(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_GROUP_NAME_MATCH_INDEX_LDAP_ATTRIBUTE)));
    return provider;
}
 
Example 4
Source File: RecipientRewriteTableConfiguration.java    From james-project with Apache License 2.0 5 votes vote down vote up
public static RecipientRewriteTableConfiguration fromConfiguration(HierarchicalConfiguration<ImmutableNode> config) throws ConfigurationException {
    boolean recursive = config.getBoolean("recursiveMapping", RECURSIVE_MAPPING_ENABLED);
    int mappingLimit;
    if (recursive) {
        mappingLimit = config.getInt("mappingLimit", DEFAULT_ENABLED_MAPPING_LIMIT);
        checkMappingLimit(mappingLimit);
    } else {
        mappingLimit = DISABLED_MAPPING_LIMIT;
    }
    return new RecipientRewriteTableConfiguration(recursive, mappingLimit);
}
 
Example 5
Source File: ConfigAwareAuthenticationSuccessHandler.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean isAlwaysUseDefaultTargetUrl() {
    HierarchicalConfiguration config = ConfigUtils.getCurrentConfig();
    if (config != null) {
        return config.getBoolean(LOGIN_ALWAYS_USE_DEFAULT_SUCCESS_URL_KEY, super.isAlwaysUseDefaultTargetUrl());
    }
    return super.isAlwaysUseDefaultTargetUrl();
}
 
Example 6
Source File: FileMailRepository.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> config) {
    destination = config.getString("[@destinationURL]");
    LOGGER.debug("FileMailRepository.destinationURL: {}", destination);
    fifo = config.getBoolean("[@FIFO]", false);
    cacheKeys = config.getBoolean("[@CACHEKEYS]", true);
    // ignore model
}
 
Example 7
Source File: AbstractStateMailetProcessor.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> config) throws ConfigurationException {
    this.state = config.getString("[@state]", null);
    if (state == null) {
        throw new ConfigurationException("Processor state attribute must be configured");
    }
    if (state.equals(Mail.GHOST)) {
        throw new ConfigurationException("Processor state of " + Mail.GHOST + " is reserved for internal use, choose a different one");
    }

    this.enableJmx = config.getBoolean("[@enableJmx]", true);
    this.config = config;

}
 
Example 8
Source File: RenameUpgradeOperation.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    oldPath = config.getString(CONFIG_KEY_OLD_PATH);
    newPath = config.getString(CONFIG_KEY_NEW_PATH);
    overwrite = config.getBoolean(CONFIG_KEY_OVERWRITE, false);
}
 
Example 9
Source File: SiteAwareCORSFilter.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isDisableCORS() {
    SiteContext siteContext = SiteContext.getCurrent();
    HierarchicalConfiguration config = siteContext.getConfig();
    try {
        HierarchicalConfiguration corsConfig = config.configurationAt(CONFIG_KEY);
        if (corsConfig != null) {
            return !corsConfig.getBoolean(ENABLE_KEY, false);
        }
    } catch (Exception e) {
        logger.debug("Site '{}' has no CORS configuration", siteContext.getSiteName());
    }
    return true;
}
 
Example 10
Source File: AuthenticationProviderFactory.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
private static HeadersAuthenticationProvider createHeadersAuthenticationProvider(HierarchicalConfiguration<ImmutableNode> providerConfig) {
    HeadersAuthenticationProvider provider = new HeadersAuthenticationProvider();
    boolean enabled = providerConfig.getBoolean(AUTHENTICATION_CHAIN_PROVIDER_ENABLED);
    provider.setEnabled(enabled);
    provider.setSecureKeyHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_SECURE_KEY_HEADER));
    provider.setSecureKeyHeaderValue(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_SECURE_KEY_HEADER_VALUE));
    provider.setUsernameHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_USERNAME_HEADER));
    provider.setFirstNameHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_FIRST_NAME_HEADER));
    provider.setLastNameHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LAST_NAME_HEADER));
    provider.setEmailHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_EMAIL_HEADER));
    provider.setGroupsHeader(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_GROUPS_HEADER));
    provider.setLogoutEnabled(providerConfig.getBoolean(AUTHENTICATION_CHAIN_PROVIDER_LOGOUT_ENABLED));
    provider.setLogoutUrl(providerConfig.getString(AUTHENTICATION_CHAIN_PROVIDER_LOGOUT_URL));
    return provider;
}
 
Example 11
Source File: DbScriptUpgradeOperation.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    fileName = config.getString(CONFIG_KEY_FILENAME);
    updateIntegrity = config.getBoolean(CONFIG_KEY_INTEGRITY, true);
}
 
Example 12
Source File: NaBL2ConfigReaderWriter.java    From spoofax with Apache License 2.0 4 votes vote down vote up
public static NaBL2Config read(HierarchicalConfiguration<ImmutableNode> config) {
    final boolean incremental = config.getBoolean(PROP_INCREMENTAL, false);
    final NaBL2DebugConfig debug = NaBL2DebugConfig.of(readFlags(config.getString(PROP_DEBUG, "")));
    return new NaBL2Config(incremental, debug);
}
 
Example 13
Source File: ConfigAwarePreAuthenticationFilter.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
public boolean isEnabled() {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    return alwaysEnabled || siteConfig != null && siteConfig.getBoolean(enabledConfigKey, false);
}
 
Example 14
Source File: ProfileRestController.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
protected boolean shouldCleanseAttributes() {
    HierarchicalConfiguration siteConfig = ConfigUtils.getCurrentConfig();
    return siteConfig != null && siteConfig.getBoolean(CLEANSE_ATTRS_CONFIG_KEY, true);
}
 
Example 15
Source File: AuthenticationProviderFactory.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
private static DbAuthenticationProvider createDbAuthenticationProvider(HierarchicalConfiguration<ImmutableNode> providerConfig) {
    DbAuthenticationProvider provider = new DbAuthenticationProvider();
    boolean enabled = providerConfig.getBoolean(AUTHENTICATION_CHAIN_PROVIDER_ENABLED);
    provider.setEnabled(enabled);
    return provider;
}
 
Example 16
Source File: SMTPServer.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
public void doConfigure(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    super.doConfigure(configuration);
    if (isEnabled()) {
        String authRequiredString = configuration.getString("authRequired", "false").trim().toLowerCase(Locale.US);
        if (authRequiredString.equals("true")) {
            authRequired = AUTH_REQUIRED;
        } else if (authRequiredString.equals("announce")) {
            authRequired = AUTH_ANNOUNCE;
        } else {
            authRequired = AUTH_DISABLED;
        }
        if (authRequired != AUTH_DISABLED) {
            LOGGER.info("This SMTP server requires authentication.");
        } else {
            LOGGER.info("This SMTP server does not require authentication.");
        }

        authorizedAddresses = configuration.getString("authorizedAddresses", null);
        if (authRequired == AUTH_DISABLED && authorizedAddresses == null) {
            /*
             * if SMTP AUTH is not required then we will use
             * authorizedAddresses to determine whether or not to relay
             * e-mail. Therefore if SMTP AUTH is not required, we will not
             * relay e-mail unless the sending IP address is authorized.
             * 
             * Since this is a change in behavior for James v2, create a
             * default authorizedAddresses network of 0.0.0.0/0, which
             * matches all possible addresses, thus preserving the current
             * behavior.
             * 
             * James v3 should require the <authorizedAddresses> element.
             */
            authorizedAddresses = "0.0.0.0/0.0.0.0";
        }

      
        if (authorizedNetworks != null) {
            LOGGER.info("Authorized addresses: {}", authorizedNetworks);
        }

        // get the message size limit from the conf file and multiply
        // by 1024, to put it in bytes
        maxMessageSize = configuration.getLong("maxmessagesize", maxMessageSize) * 1024;
        if (maxMessageSize > 0) {
            LOGGER.info("The maximum allowed message size is {} bytes.", maxMessageSize);
        } else {
            LOGGER.info("No maximum message size is enforced for this server.");
        }

        heloEhloEnforcement = configuration.getBoolean("heloEhloEnforcement", true);

        if (authRequiredString.equals("true")) {
            authRequired = AUTH_REQUIRED;
        }

        // get the smtpGreeting
        smtpGreeting = configuration.getString("smtpGreeting", null);

        addressBracketsEnforcement = configuration.getBoolean("addressBracketsEnforcement", true);

        verifyIdentity = configuration.getBoolean("verifyIdentity", true);

    }
}
 
Example 17
Source File: UsersRepositoryImpl.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    virtualHosting = configuration.getBoolean("enableVirtualHosting", usersDAO.getDefaultVirtualHostingValue());
    administratorId = Optional.ofNullable(configuration.getString("administratorId"))
        .map(Username::of);
}
 
Example 18
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);
}
 
Example 19
Source File: AbstractStateCompositeProcessor.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> config) {
    this.config = config;
    this.enableJmx = config.getBoolean("[@enableJmx]", true);

}