Author: norman Date: Wed Jul 5 06:56:02 2006 New Revision: 419230 URL: http://svn.apache.org/viewvc?rev=419230&view=rev Log: Replace ConntectHandler and MessageHandler with abstract classes. Move basic code from AbstractCommandHandler to AbstractGeneralHandler
Added: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractConnectHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractGeneralHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractMessageHandler.java Removed: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/ConnectHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/MessageHandler.java Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractCommandHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DNSRBLHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SendMailHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractCommandHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractCommandHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractCommandHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractCommandHandler.java Wed Jul 5 06:56:02 2006 @@ -19,38 +19,14 @@ import java.util.List; -import org.apache.avalon.framework.logger.AbstractLogEnabled; - /** * Custom CommandHandlers must extend this class. */ -public abstract class AbstractCommandHandler extends AbstractLogEnabled { +public abstract class AbstractCommandHandler extends AbstractGeneralHandler { /** - * If set to true all handler processing is stopped (fastfail) - */ - private boolean stopHandlerProcessing = false; - - - /** - * Method to set if a after the handler no other command handlers should processed - * @param stopHandlerProcessing true or false - */ - public void setStopHandlerProcessing(boolean stopHandlerProcessing) { - this.stopHandlerProcessing = stopHandlerProcessing; - } - - /** - * Return if the processing of other commandHandlers should be done - * @return true or false - */ - public boolean stopHandlerProcessing() { - return stopHandlerProcessing; - } - - /** * Handle the command - **/ + **/ public abstract void onCommand(SMTPSession session); /** @@ -59,5 +35,5 @@ * @return List which contains implemented commands */ public abstract List getImplCommands(); - + } Added: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractConnectHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractConnectHandler.java?rev=419230&view=auto ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractConnectHandler.java (added) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractConnectHandler.java Wed Jul 5 06:56:02 2006 @@ -0,0 +1,33 @@ +/*********************************************************************** + * Copyright (c) 1999-2006 The Apache Software Foundation. * + * All rights reserved. * + * ------------------------------------------------------------------- * + * Licensed 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. * + ***********************************************************************/ + +package org.apache.james.smtpserver; + +/** + * Custom connect handlers must extend this class + * The connect handlers will be server-wide common to all the SMTPHandlers, + * therefore the handlers must store all the state information + * in the SMTPSession object + */ +public abstract class AbstractConnectHandler extends AbstractGeneralHandler{ + + /** + * Handle connection + **/ + public abstract void onConnect(SMTPSession session); + +} Added: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractGeneralHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractGeneralHandler.java?rev=419230&view=auto ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractGeneralHandler.java (added) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractGeneralHandler.java Wed Jul 5 06:56:02 2006 @@ -0,0 +1,132 @@ +/*********************************************************************** + * Copyright (c) 1999-2006 The Apache Software Foundation. * + * All rights reserved. * + * ------------------------------------------------------------------- * + * Licensed 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. * + ***********************************************************************/ + +package org.apache.james.smtpserver; + +import java.util.List; + +import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector; +import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.context.Contextualizable; +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.avalon.framework.service.Serviceable; +import org.apache.james.services.DNSServer; + +/** + * Custom CommandHandlers must extend this class. + */ +public abstract class AbstractGeneralHandler extends AbstractLogEnabled implements Configurable,Serviceable,Initializable{ + + /** + * If set to true all handler processing is stopped (fastfail) + */ + private boolean stopHandlerProcessing = false; + + private DataSourceSelector dataSource; + + private DNSServer dnsServer; + + /** + * Method to set if a after the handler no other command handlers should + * processed + * + * @param stopHandlerProcessing + * true or false + */ + public void setStopHandlerProcessing(boolean stopHandlerProcessing) { + this.stopHandlerProcessing = stopHandlerProcessing; + } + + /** + * Return if the processing of other commandHandlers should be done + * + * @return true or false + */ + public boolean stopHandlerProcessing() { + return stopHandlerProcessing; + } + + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) + */ + public void configure(Configuration handlerConfiguration) + throws ConfigurationException { + } + + /** + * @see org.apache.avalon.framework.activity.Initializable#initialize() + */ + public void initialize() throws Exception { + // only for overriding + } + + /** + * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) + */ + public void service(ServiceManager serviceMan) throws ServiceException { + setDataSourceSelector((DataSourceSelector) serviceMan + .lookup(DataSourceSelector.ROLE)); + + setDnsServer((DNSServer) serviceMan.lookup(DNSServer.ROLE)); + } + + /** + * Set the DNSServer + * + * @param dnsServer + * The DNSServer + */ + public void setDnsServer(DNSServer dnsServer) { + this.dnsServer = dnsServer; + } + + /** + * Return the DnsServer + * + * @return DNSServer + */ + public DNSServer getDnsServer() { + return dnsServer; + } + + /** + * Set the datasource + * + * @param datasource + * the datasource + */ + public void setDataSourceSelector(DataSourceSelector dataSource) { + + this.dataSource = dataSource; + } + + /** + * Return the DataSourceSelector + * + * @return DataSourceSelector + */ + public DataSourceSelector getDataSourceSelector() { + return dataSource; + } +} Added: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractMessageHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractMessageHandler.java?rev=419230&view=auto ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractMessageHandler.java (added) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/AbstractMessageHandler.java Wed Jul 5 06:56:02 2006 @@ -0,0 +1,33 @@ +/*********************************************************************** + * Copyright (c) 1999-2006 The Apache Software Foundation. * + * All rights reserved. * + * ------------------------------------------------------------------- * + * Licensed 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. * + ***********************************************************************/ + +package org.apache.james.smtpserver; + +/** + * Custom message handlers must extend this class. + * The message handlers will be server-wide common to all the SMTPHandlers, + * therefore the handlers must store all the state information + * in the SMTPSession object + */ +public abstract class AbstractMessageHandler extends AbstractGeneralHandler { + + /** + * Handle Message + **/ + public abstract void onMessage(SMTPSession session); + +} Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DNSRBLHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DNSRBLHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DNSRBLHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/DNSRBLHandler.java Wed Jul 5 06:56:02 2006 @@ -17,33 +17,25 @@ package org.apache.james.smtpserver; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.james.services.DNSServer; - +import java.net.Socket; import java.util.ArrayList; import java.util.Collection; import java.util.StringTokenizer; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; + /** * Connect handler for DNSRBL processing */ public class DNSRBLHandler - extends AbstractLogEnabled - implements ConnectHandler, Configurable, Serviceable { + extends AbstractConnectHandler { /** * The lists of rbl servers to be checked to limit spam */ private String[] whitelist; private String[] blacklist; - private DNSServer dnsServer = null; - private boolean getDetail = false; /** @@ -91,12 +83,6 @@ } - /** - * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) - */ - public void service(ServiceManager serviceMan) throws ServiceException { - setDNSServer((DNSServer) serviceMan.lookup(DNSServer.ROLE)); - } /* * check if the remote Ip address is block listed @@ -126,14 +112,6 @@ this.blacklist = blacklist; } - /** - * Set the DNSServer - * - * @param dnsServer The DNSServer - */ - public void setDNSServer(DNSServer dnsServer) { - this.dnsServer = dnsServer; - } /** * Set for try to get a TXT record for the blocked record. @@ -176,7 +154,7 @@ if (whitelist != null) { String[] rblList = whitelist; for (int i = 0 ; i < rblList.length ; i++) try { - dnsServer.getByName(reversedOctets + rblList[i]); + getDnsServer().getByName(reversedOctets + rblList[i]); if (getLogger().isInfoEnabled()) { getLogger().info("Connection from " + ipAddress + " whitelisted by " + rblList[i]); } @@ -191,14 +169,14 @@ if (blacklist != null) { String[] rblList = blacklist; for (int i = 0 ; i < rblList.length ; i++) try { - dnsServer.getByName(reversedOctets + rblList[i]); + getDnsServer().getByName(reversedOctets + rblList[i]); if (getLogger().isInfoEnabled()) { getLogger().info("Connection from " + ipAddress + " restricted by " + rblList[i] + " to SMTP AUTH/postmaster/abuse."); } // we should try to retrieve details if (getDetail) { - Collection txt = dnsServer.findTXTRecords(reversedOctets + rblList[i]); + Collection txt = getDnsServer().findTXTRecords(reversedOctets + rblList[i]); // Check if we found a txt record if (!txt.isEmpty()) { Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandler.java Wed Jul 5 06:56:02 2006 @@ -232,8 +232,12 @@ if(connectHandlers != null) { int count = connectHandlers.size(); for(int i = 0; i < count; i++) { - ((ConnectHandler)connectHandlers.get(i)).onConnect(this); - if(sessionEnded) { + AbstractConnectHandler aHandler = (AbstractConnectHandler)connectHandlers.get(i); + aHandler.setStopHandlerProcessing(false); + aHandler.onConnect(this); + boolean stopHandlerProcessing = aHandler.stopHandlerProcessing(); + + if(sessionEnded || stopHandlerProcessing) { break; } } @@ -289,9 +293,13 @@ List messageHandlers = handlerChain.getMessageHandlers(); int count = messageHandlers.size(); for(int i =0; i < count; i++) { - ((MessageHandler)messageHandlers.get(i)).onMessage(this); + AbstractMessageHandler aHandler = (AbstractMessageHandler)messageHandlers.get(i); + aHandler.setStopHandlerProcessing(false); + aHandler.onMessage(this); + boolean stopHandlerProcessing = aHandler.stopHandlerProcessing(); + //if the response is received, stop processing of command handlers - if(mode == MESSAGE_ABORT_MODE) { + if(mode == MESSAGE_ABORT_MODE || stopHandlerProcessing) { break; } } Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java Wed Jul 5 06:56:02 2006 @@ -212,8 +212,8 @@ ContainerUtil.configure(handler, config); // if it is a connect handler add it to list of connect handlers - if (handler instanceof ConnectHandler) { - connectHandlers.add((ConnectHandler) handler); + if (handler instanceof AbstractConnectHandler) { + connectHandlers.add((AbstractConnectHandler) handler); if (getLogger().isInfoEnabled()) { getLogger().info("Added ConnectHandler: " + className); } @@ -269,8 +269,8 @@ } // if it is a message handler add it to list of message handlers - if (handler instanceof MessageHandler) { - messageHandlers.add((MessageHandler) handler); + if (handler instanceof AbstractMessageHandler) { + messageHandlers.add((AbstractMessageHandler) handler); if (getLogger().isInfoEnabled()) { getLogger().info("Added MessageHandler: " + className); } Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SendMailHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SendMailHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SendMailHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SendMailHandler.java Wed Jul 5 06:56:02 2006 @@ -34,8 +34,7 @@ * Adds the header to the message */ public class SendMailHandler - extends AbstractLogEnabled - implements MessageHandler, Serviceable { + extends AbstractMessageHandler { private MailServer mailServer; @@ -43,6 +42,8 @@ * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) */ public void service(ServiceManager serviceManager) throws ServiceException { + + //TODO: Maybe we should move this to AbstractGeneralHandler mailServer = (MailServer) serviceManager.lookup(MailServer.ROLE); } Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java Wed Jul 5 06:56:02 2006 @@ -28,8 +28,7 @@ * Adds the header to the message */ public class SetMimeHeaderHandler - extends AbstractLogEnabled - implements MessageHandler, Configurable { + extends AbstractMessageHandler { /** * The header name and value that needs to be added Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ResolvableEhloHeloHandler.java Wed Jul 5 06:56:02 2006 @@ -21,22 +21,16 @@ import java.util.ArrayList; import java.util.List; -import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.james.services.DNSServer; import org.apache.james.smtpserver.AbstractCommandHandler; import org.apache.james.smtpserver.SMTPSession; import org.apache.james.util.mail.dsn.DSNStatus; -public class ResolvableEhloHeloHandler extends AbstractCommandHandler implements Configurable, Serviceable { +public class ResolvableEhloHeloHandler extends AbstractCommandHandler { private boolean checkAuthNetworks = false; - private DNSServer dnsServer = null; /** * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) @@ -51,13 +45,6 @@ } /** - * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) - */ - public void service(ServiceManager serviceMan) throws ServiceException { - setDnsServer((DNSServer) serviceMan.lookup(DNSServer.ROLE)); - } - - /** * Set to true if AuthNetworks should be included in the EHLO check * * @param checkAuthNetworks @@ -68,16 +55,6 @@ } /** - * Set the DNSServer - * - * @param dnsServer - * The DNSServer - */ - public void setDnsServer(DNSServer dnsServer) { - this.dnsServer = dnsServer; - } - - /** * @see org.apache.james.smtpserver.fastfailfilter.HeloFilterHandler#onEhloCommand(SMTPSession) */ public void onCommand(SMTPSession session) { @@ -92,7 +69,7 @@ // try to resolv the provided helo. If it can not resolved do not // accept it. try { - dnsServer.getByName(argument); + getDnsServer().getByName(argument); } catch (UnknownHostException e) { responseString = "501 " + DSNStatus.getStatus(DSNStatus.PERMANENT, Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ReverseEqualsEhloHeloHandler.java Wed Jul 5 06:56:02 2006 @@ -21,22 +21,16 @@ import java.util.ArrayList; import java.util.List; -import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.james.services.DNSServer; import org.apache.james.smtpserver.AbstractCommandHandler; import org.apache.james.smtpserver.SMTPSession; import org.apache.james.util.mail.dsn.DSNStatus; -public class ReverseEqualsEhloHeloHandler extends AbstractCommandHandler implements Configurable, Serviceable { +public class ReverseEqualsEhloHeloHandler extends AbstractCommandHandler { private boolean checkAuthNetworks = false; - private DNSServer dnsServer = null; /** * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) @@ -50,14 +44,6 @@ } } - - /** - * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) - */ - public void service(ServiceManager serviceMan) throws ServiceException { - setDnsServer((DNSServer) serviceMan.lookup(DNSServer.ROLE)); - } - /** * Set to true if AuthNetworks should be included in the EHLO check * @@ -68,15 +54,6 @@ this.checkAuthNetworks = checkAuthNetworks; } - /** - * Set the DNSServer - * - * @param dnsServer - * The DNSServer - */ - public void setDnsServer(DNSServer dnsServer) { - this.dnsServer = dnsServer; - } /** * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) @@ -92,7 +69,7 @@ if (!session.isRelayingAllowed() || checkAuthNetworks) { try { // get reverse entry - String reverse = dnsServer.getByName( + String reverse = getDnsServer().getByName( session.getRemoteIPAddress()).getHostName(); if (!argument.equals(reverse)) { Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/TarpitHandler.java Wed Jul 5 06:56:02 2006 @@ -20,13 +20,12 @@ import java.util.ArrayList; import java.util.List; -import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.james.smtpserver.AbstractCommandHandler; import org.apache.james.smtpserver.SMTPSession; -public class TarpitHandler extends AbstractCommandHandler implements Configurable { +public class TarpitHandler extends AbstractCommandHandler { private int tarpitRcptCount = 0; Modified: james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java?rev=419230&r1=419229&r2=419230&view=diff ============================================================================== --- james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java (original) +++ james/server/sandbox/handlerapi/src/java/org/apache/james/smtpserver/fastfailfilter/ValidSenderDomainHandler.java Wed Jul 5 06:56:02 2006 @@ -21,25 +21,18 @@ import java.util.Collection; import java.util.List; -import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.james.services.DNSServer; import org.apache.james.smtpserver.AbstractCommandHandler; import org.apache.james.smtpserver.SMTPSession; import org.apache.james.util.mail.dsn.DSNStatus; import org.apache.mailet.MailAddress; public class ValidSenderDomainHandler - extends AbstractCommandHandler implements Configurable, Serviceable { + extends AbstractCommandHandler { private boolean checkAuthClients = false; - private DNSServer dnsServer = null; - /** * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) */ @@ -50,22 +43,7 @@ setCheckAuthClients(configRelay.getValueAsBoolean(false)); } } - - /** - * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager) - */ - public void service(ServiceManager serviceMan) throws ServiceException { - setDnsServer((DNSServer) serviceMan.lookup(DNSServer.ROLE)); - } - - /** - * Set the DnsServer - * - * @param dnsServer The DnsServer - */ - public void setDnsServer(DNSServer dnsServer) { - this.dnsServer = dnsServer; - } + /** * Enable checking of authorized clients @@ -95,7 +73,7 @@ // try to resolv the provided domain in the senderaddress. If it can not resolved do not accept it. - records = dnsServer.findMXRecords(senderAddress.getHost()); + records = getDnsServer().findMXRecords(senderAddress.getHost()); if (records == null || records.size() == 0) { responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+ " sender " + senderAddress + " contains a domain with no valid MX records"; session.writeResponse(responseString); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]