Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.HierarchicalConfiguration


    }

   
    public void doConfigure(final HierarchicalConfiguration configuration) throws ConfigurationException {
        if (isEnabled()) {
            HierarchicalConfiguration handlerConfiguration = configuration.configurationAt("handler");
            String authRequiredString = handlerConfiguration.getString("authRequired","false").trim().toLowerCase();
            if (authRequiredString.equals("true")) authRequired = AUTH_REQUIRED;
            else if (authRequiredString.equals("announce")) authRequired = AUTH_ANNOUNCE;
            else authRequired = AUTH_DISABLED;
            if (authRequired != AUTH_DISABLED) {
                getLogger().info("This SMTP server requires authentication.");
            } else {
                getLogger().info("This SMTP server does not require authentication.");
            }

            String authorizedAddresses = handlerConfiguration.getString("authorizedAddresses",null);
            if (authRequired == AUTH_DISABLED && authorizedAddresses == null) {
                /* if SMTP AUTH is not requred 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 (authorizedAddresses != null) {
                java.util.StringTokenizer st = new java.util.StringTokenizer(authorizedAddresses, ", ", false);
                java.util.Collection<String> networks = new java.util.ArrayList<String>();
                while (st.hasMoreTokens()) {
                    String addr = st.nextToken();
                    networks.add(addr);
                }
                authorizedNetworks = new NetMatcher(networks, getDNSService());
            }

            if (authorizedNetworks != null) {
                getLogger().info("Authorized addresses: " + authorizedNetworks.toString());
            }

            // get the message size limit from the conf file and multiply
            // by 1024, to put it in bytes
            maxMessageSize = handlerConfiguration.getLong( "maxmessagesize",maxMessageSize ) * 1024;
            if (maxMessageSize > 0) {
                getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes.");
            } else {
                getLogger().info("No maximum message size is enforced for this server.");
            }
            // How many bytes to read before updating the timer that data is being transfered
            lengthReset = configuration.getInt("lengthReset", lengthReset);
            if (lengthReset <= 0) {
                throw new ConfigurationException("The configured value for the idle timeout reset, " + lengthReset + ", is not valid.");
            }
            if (getLogger().isInfoEnabled()) {
                getLogger().info("The idle timeout will be reset every " + lengthReset + " bytes.");
            }

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

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

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

            addressBracketsEnforcement = handlerConfiguration.getBoolean("addressBracketsEnforcement",true);
           
            verifyIdentity = handlerConfiguration.getBoolean("verifyIdentity",true);

        }
    }
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
        List<HierarchicalConfiguration> entries = config.configurationsAt("priorityEntries.priorityEntry");
        for (int i = 0; i < entries.size(); i++) {
            HierarchicalConfiguration prioConf = entries.get(i);
            String domain = prioConf.getString("domain");
            int prio = prioConf.getInt("priority", MailPrioritySupport.NORMAL_PRIORITY);
            if (prio > MailPrioritySupport.HIGH_PRIORITY || prio < MailPrioritySupport.LOW_PRIORITY) {
                throw new ConfigurationException("configured priority must be >= " + MailPrioritySupport.LOW_PRIORITY + " and <= " + MailPrioritySupport.HIGH_PRIORITY);
            }
            prioMap.put(domain, prio);
        }
View Full Code Here

        setJavaMailProviderName(
            conf.getString("javaMailProviderName"));
        setJavaMailFolderName(conf.getString("javaMailFolderName"));
        setRecurse(conf.getBoolean("recursesubfolders"));

        HierarchicalConfiguration recipientNotFound = conf.configurationAt("recipientnotfound");
        setDeferRecipientNotFound(
            recipientNotFound.getBoolean("[@defer]"));
        setRejectRecipientNotFound(
            recipientNotFound.getBoolean("[@reject]"));
        setLeaveRecipientNotFound(
            recipientNotFound.getBoolean("[@leaveonserver]"));
        setMarkRecipientNotFoundSeen(
            recipientNotFound.getBoolean("[@markseen]"));
        setDefaultDomainName(conf.getString("defaultdomain", "localhost"));

        setFetchAll(conf.getBoolean("fetchall"));

        HierarchicalConfiguration fetched = conf.configurationAt("fetched");
        setLeave(fetched.getBoolean("[@leaveonserver]"));
        setMarkSeen(fetched.getBoolean("[@markseen]"));

        HierarchicalConfiguration remoterecipient = conf.configurationAt("remoterecipient");
        setRejectRemoteRecipient(
            remoterecipient.getBoolean("[@reject]"));
        setLeaveRemoteRecipient(
            remoterecipient.getBoolean("[@leaveonserver]"));
        setMarkRemoteRecipientSeen(
            remoterecipient.getBoolean("[@markseen]"));

        HierarchicalConfiguration blacklist = conf.configurationAt("blacklist");
        setBlacklist(conf.getString("blacklist",""));
        setRejectBlacklisted(blacklist.getBoolean("[@reject]"));
        setLeaveBlacklisted(blacklist.getBoolean("[@leaveonserver]"));
        setMarkBlacklistedSeen(blacklist.getBoolean("[@markseen]"));

        HierarchicalConfiguration userundefined = conf.configurationAt("userundefined");
        setRejectUserUndefined(userundefined.getBoolean("[@reject]"));
        setLeaveUserUndefined(
            userundefined.getBoolean("[@leaveonserver]"));
        setMarkUserUndefinedSeen(
            userundefined.getBoolean("[@markseen]"));

        HierarchicalConfiguration undeliverable = conf.configurationAt("undeliverable");
        setLeaveUndeliverable(
            undeliverable.getBoolean("[@leaveonserver]"));
        setMarkUndeliverableSeen(
            undeliverable.getBoolean("[@markseen]"));

        if (conf.getKeys("remotereceivedheader").hasNext())
        {
            HierarchicalConfiguration remotereceivedheader = conf.configurationAt("remotereceivedheader");

            setRemoteReceivedHeaderIndex(
                remotereceivedheader.getInt("[@index]"));
            setRejectRemoteReceivedHeaderInvalid(
                remotereceivedheader.getBoolean("[@reject]"));
            setLeaveRemoteReceivedHeaderInvalid(
                remotereceivedheader.getBoolean("[@leaveonserver]"));
            setMarkRemoteReceivedHeaderInvalidSeen(
                remotereceivedheader.getBoolean("[@markseen]"));
        }           

        if (conf.getKeys("maxmessagesize").hasNext())
        {
            HierarchicalConfiguration maxmessagesize = conf.configurationAt("maxmessagesize");

            setMaxMessageSizeLimit(
                maxmessagesize.getInt("[@limit]") * 1024);
            setRejectMaxMessageSizeExceeded(
                maxmessagesize.getBoolean("[@reject]"));
            setLeaveMaxMessageSizeExceeded(
                maxmessagesize.getBoolean("[@leaveonserver]"));
            setMarkMaxMessageSizeExceededSeen(
                maxmessagesize.getBoolean("[@markseen]"));
        }

        if (getLogger().isDebugEnabled())
        {
            getLogger().info(
View Full Code Here

    this.instanceFactory = instanceFactory;
  }

  @PostConstruct
  public void init() throws Exception {
    HierarchicalConfiguration conf = config.configurationAt("table");

    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    String repName = conf.getString("[@name]", null);
    String repClass = conf.getString("[@class]");

    if (repName == null) {
      repName = repClass;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void init() throws Exception {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        List<HierarchicalConfiguration> repConfs = config.configurationsAt("repository");
        for (int i = 0; i < repConfs.size(); i++) {
            final HierarchicalConfiguration repConf = repConfs.get(i);
            String repName = repConf.getString("[@name]", null);
            String repClass = repConf.getString("[@class]");

            if (repName == null) {
                repName = repClass;
            }
           
View Full Code Here

    @SuppressWarnings("unchecked")
    private List<MatcherManagement> loadCompositeMatchers(String processorName, Map<String,MatcherManagement> compMap, List<HierarchicalConfiguration> compMatcherConfs) throws ConfigurationException, MessagingException, NotCompliantMBeanException {
        List<MatcherManagement> matchers = new ArrayList<MatcherManagement>();

        for (int j= 0 ; j < compMatcherConfs.size(); j++) {
            HierarchicalConfiguration c = compMatcherConfs.get(j);
            String compName = c.getString("[@name]", null);
            String matcherName = c.getString("[@match]", null);
            String invertedMatcherName = c.getString("[@notmatch]", null);

            Matcher matcher = null;
            if (matcherName != null && invertedMatcherName != null) {
                // if no matcher is configured throw an Exception
                throw new ConfigurationException("Please configure only match or nomatch per mailet");
            } else if (matcherName != null) {
                matcher = matcherLoader.getMatcher(matcherName);
                if (matcher instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) matcher;
                   
                    List<MatcherManagement> childMatcher = loadCompositeMatchers(processorName, compMap,c.configurationsAt("matcher"));
                    for (int i = 0 ; i < childMatcher.size(); i++) {
                        compMatcher.add(childMatcher.get(i));
                    }
                }
            } else if (invertedMatcherName != null) {
                Matcher m = matcherLoader.getMatcher(invertedMatcherName);
                if (m instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) m;
                   
                    List<MatcherManagement> childMatcher = loadCompositeMatchers(processorName, compMap,c.configurationsAt("matcher"));
                    for (int i = 0 ; i < childMatcher.size(); i++) {
                        compMatcher.add(childMatcher.get(i));
                    }
                }
                matcher = new MatcherInverter(m);
View Full Code Here

        return "LMTP Service";
    }
   
    public void doConfigure(final HierarchicalConfiguration configuration) throws ConfigurationException {
        if (isEnabled()) {
            HierarchicalConfiguration handlerConfiguration = configuration.configurationAt("handler");
          

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


        }
    }
View Full Code Here

        this.instanceFactory = instanceFactory;
    }

    @PostConstruct
    public void init() throws Exception {
        HierarchicalConfiguration conf = config.configurationAt("domainlist");

        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        String repName = conf.getString("[@name]", null);
        String repClass = conf.getString("[@class]");

        if (repName == null) {
            repName = repClass;
        }
View Full Code Here

        XMLConfiguration conf1 = new XMLConfiguration(CONF1);
        XMLConfiguration conf2 = new XMLConfiguration(CONF2);
        ConfigurationNode cn = combiner.combine(conf1.getRootNode(), conf2
                .getRootNode());

        HierarchicalConfiguration result = new HierarchicalConfiguration();
        result.setRootNode(cn);

        return result;
    }
View Full Code Here

public class TestHierarchicalConfigurationEvents extends
        AbstractTestConfigurationEvents
{
    protected AbstractConfiguration createConfiguration()
    {
        return new HierarchicalConfiguration();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.HierarchicalConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.