FileDocCategorySizeDatePackage
SMTPTestConfiguration.javaAPI DocApache James 2.3.17694Fri Jan 12 12:56:36 GMT 2007org.apache.james.smtpserver

SMTPTestConfiguration

public class SMTPTestConfiguration extends org.apache.avalon.framework.configuration.DefaultConfiguration
Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *

Fields Summary
private int
m_smtpListenerPort
private int
m_maxMessageSizeKB
private String
m_authorizedAddresses
private String
m_authorizingMode
private boolean
m_verifyIdentity
private Integer
m_connectionLimit
private Integer
m_connectionBacklog
private boolean
m_heloResolv
private boolean
m_ehloResolv
private boolean
m_senderDomainResolv
private boolean
m_checkAuthNetworks
private boolean
m_checkAuthClients
private boolean
m_heloEhloEnforcement
private boolean
m_reverseEqualsHelo
private boolean
m_reverseEqualsEhlo
private int
m_maxRcpt
Constructors Summary
public SMTPTestConfiguration(int smtpListenerPort)


    
       
        super("smptserver");

        m_smtpListenerPort = smtpListenerPort;
    
Methods Summary
public java.lang.StringgetAuthorizedAddresses()

        return m_authorizedAddresses;
    
public intgetMaxMessageSize()

        return m_maxMessageSizeKB;
    
public voidinit()


        setAttribute("enabled", true);

        addChild(Util.getValuedConfiguration("port", "" + m_smtpListenerPort));
        if (m_connectionLimit != null) addChild(Util.getValuedConfiguration("connectionLimit", "" + m_connectionLimit.intValue()));
        if (m_connectionBacklog != null) addChild(Util.getValuedConfiguration("connectionBacklog", "" + m_connectionBacklog.intValue()));
        
        DefaultConfiguration handlerConfig = new DefaultConfiguration("handler");
        handlerConfig.addChild(Util.getValuedConfiguration("helloName", "myMailServer"));
        handlerConfig.addChild(Util.getValuedConfiguration("connectiontimeout", "360000"));
        handlerConfig.addChild(Util.getValuedConfiguration("authorizedAddresses", m_authorizedAddresses));
        handlerConfig.addChild(Util.getValuedConfiguration("maxmessagesize", "" + m_maxMessageSizeKB));
        handlerConfig.addChild(Util.getValuedConfiguration("authRequired", m_authorizingMode));
        handlerConfig.addChild(Util.getValuedConfiguration("heloEhloEnforcement", m_heloEhloEnforcement+""));
        if (m_verifyIdentity) handlerConfig.addChild(Util.getValuedConfiguration("verifyIdentity", "" + m_verifyIdentity));
        
        handlerConfig.addChild(Util.createSMTPHandlerChainConfiguration());
        
        // Add Configuration for Helo checks and Ehlo checks
        Configuration[] heloConfig = handlerConfig.getChild("handlerchain").getChildren("handler");
        for (int i = 0; i < heloConfig.length; i++) {
            if (heloConfig[i] instanceof DefaultConfiguration) {
                String cmd = ((DefaultConfiguration) heloConfig[i]).getAttribute("command",null);
                if (cmd != null) {
                    if ("HELO".equals(cmd)) {
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkResolvableHelo",m_heloResolv+""));
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkReverseEqualsHelo",m_reverseEqualsHelo+""));
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthNetworks",m_checkAuthNetworks+""));
                    } else if ("EHLO".equals(cmd)) {
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkResolvableEhlo",m_ehloResolv+""));
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkReverseEqualsEhlo",m_reverseEqualsEhlo+""));
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthNetworks",m_checkAuthNetworks+""));
                    } else if ("MAIL".equals(cmd)) {
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkValidSenderDomain",m_senderDomainResolv+""));
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthClients",m_checkAuthClients+""));
                    } else if ("RCPT".equals(cmd)) {
                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("maxRcpt",m_maxRcpt+""));
                    }
                }
            }
        }
        
        addChild(handlerConfig);
    
public voidsetAuthorizedAddresses(java.lang.String authorizedAddresses)

        m_authorizedAddresses = authorizedAddresses;
    
public voidsetAuthorizingAnnounce()

        m_authorizingMode = "announce";
        m_verifyIdentity = true; 
    
public voidsetAuthorizingNotRequired()

        m_authorizingMode = "false";
        m_verifyIdentity = false; 
    
public voidsetAuthorizingRequired()

        m_authorizingMode = "true";
        m_verifyIdentity = true; 
    
public voidsetCheckAuthClients(boolean ignore)

        m_checkAuthClients = ignore; 
    
public voidsetCheckAuthNetworks(boolean checkAuth)

        m_checkAuthNetworks = checkAuth; 
    
public voidsetConnectionBacklog(int iConnectionBacklog)

        m_connectionBacklog = new Integer(iConnectionBacklog);
    
public voidsetConnectionLimit(int iConnectionLimit)

        m_connectionLimit = new Integer(iConnectionLimit);
    
public voidsetEhloResolv()

        m_ehloResolv = true; 
    
public voidsetHeloEhloEnforcement(boolean heloEhloEnforcement)

        m_heloEhloEnforcement = heloEhloEnforcement; 
    
public voidsetHeloResolv()

        m_heloResolv = true; 
    
public voidsetMaxMessageSize(int kilobytes)

        m_maxMessageSizeKB = kilobytes;
    
public voidsetMaxRcpt(int maxRcpt)

        m_maxRcpt = maxRcpt; 
    
public voidsetReverseEqualsEhlo()

        m_reverseEqualsEhlo = true; 
    
public voidsetReverseEqualsHelo()

        m_reverseEqualsHelo = true; 
    
public voidsetSenderDomainResolv()

        m_senderDomainResolv = true;