james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1228120 - /james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/
Date Fri, 06 Jan 2012 11:35:16 GMT
Author: eric
Date: Fri Jan  6 11:35:16 2012
New Revision: 1228120

URL: http://svn.apache.org/viewvc?rev=1228120&view=rev
Log:
Import and Class rename / usage to use the new protocols 1.6.0-RC2-SNAPSHOT (JAMES-1360)

Modified:
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/DNSRBLHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/MaxRcptHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ResolvableEhloHeloHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ReverseEqualsEhloHeloHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamAssassinHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamTrapHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/URIRBLHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidSenderDomainHandler.java

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/DNSRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/DNSRBLHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/DNSRBLHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/DNSRBLHandler.java
Fri Jan  6 11:35:16 2012
@@ -22,21 +22,12 @@ package org.apache.james.smtpserver.fast
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.annotation.Resource;
-
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
-import org.apache.james.smtpserver.SMTPServerDNSServiceAdapter;
-
-public class DNSRBLHandler extends org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler
implements LifecycleAwareProtocolHandler {
-
-    @Resource(name = "dnsservice")
-    public void setDNSService(DNSService dns) {
-        super.setDNSService(new SMTPServerDNSServiceAdapter(dns));
-    }
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
+
+public class DNSRBLHandler extends org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler
implements InitializingLifecycleAwareProtocolHandler {
 
     @SuppressWarnings("unchecked")
     @Override
@@ -82,7 +73,6 @@ public class DNSRBLHandler extends org.a
 
     @Override
     public void destroy() {
-        // TODO Auto-generated method stub
-        
+        // Do nothing
     }
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/JDBCGreylistHandler.java
Fri Jan  6 11:35:16 2012
@@ -41,7 +41,8 @@ import org.apache.commons.configuration.
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
+import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractGreylistHandler;
 import org.apache.james.protocols.smtp.hook.HookResult;
@@ -49,14 +50,13 @@ import org.apache.james.protocols.smtp.h
 import org.apache.james.util.TimeConverter;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
-import org.apache.mailet.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * GreylistHandler which can be used to activate Greylisting
  */
-public class JDBCGreylistHandler extends AbstractGreylistHandler implements LifecycleAwareProtocolHandler
{
+public class JDBCGreylistHandler extends AbstractGreylistHandler implements InitializingLifecycleAwareProtocolHandler
{
 
     /** This log is the fall back shared by all instances */
     private static final Logger FALLBACK_LOG = LoggerFactory.getLogger(JDBCGreylistHandler.class);
@@ -392,10 +392,10 @@ public class JDBCGreylistHandler extends
      *      org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
-        if ((wNetworks == null) || (!wNetworks.matchInetNetwork(session.getRemoteIPAddress())))
{
+        if ((wNetworks == null) || (!wNetworks.matchInetNetwork(session.getRemoteAddress().getAddress().toString())))
{
             return super.doRcpt(session, sender, rcpt);
         } else {
-            session.getLogger().info("IpAddress " + session.getRemoteIPAddress() + " is whitelisted.
Skip greylisting.");
+            session.getLogger().info("IpAddress " + session.getRemoteAddress().getAddress().toString()
+ " is whitelisted. Skip greylisting.");
         }
         return new HookResult(HookReturnCode.DECLINED);
     }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/MaxRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/MaxRcptHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/MaxRcptHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/MaxRcptHandler.java
Fri Jan  6 11:35:16 2012
@@ -21,9 +21,9 @@ package org.apache.james.smtpserver.fast
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 
-public class MaxRcptHandler extends org.apache.james.protocols.smtp.core.fastfail.MaxRcptHandler
implements LifecycleAwareProtocolHandler {
+public class MaxRcptHandler extends org.apache.james.protocols.smtp.core.fastfail.MaxRcptHandler
implements InitializingLifecycleAwareProtocolHandler {
 
     @Override
     public void init(Configuration config) throws ConfigurationException {

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ResolvableEhloHeloHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ResolvableEhloHeloHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ResolvableEhloHeloHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ResolvableEhloHeloHandler.java
Fri Jan  6 11:35:16 2012
@@ -19,16 +19,6 @@
 
 package org.apache.james.smtpserver.fastfail;
 
-import javax.annotation.Resource;
-
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.smtpserver.SMTPServerDNSServiceAdapter;
-
 public class ResolvableEhloHeloHandler extends org.apache.james.protocols.smtp.core.fastfail.ResolvableEhloHeloHandler
{
 
-    @Resource(name = "dnsservice")
-    public void setDNSService(DNSService dns) {
-        super.setDNSService(new SMTPServerDNSServiceAdapter(dns));
-    }
-
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ReverseEqualsEhloHeloHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ReverseEqualsEhloHeloHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ReverseEqualsEhloHeloHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ReverseEqualsEhloHeloHandler.java
Fri Jan  6 11:35:16 2012
@@ -16,18 +16,8 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.smtpserver.fastfail;
 
-import javax.annotation.Resource;
-
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.smtpserver.SMTPServerDNSServiceAdapter;
-
 public class ReverseEqualsEhloHeloHandler extends org.apache.james.protocols.smtp.core.fastfail.ReverseEqualsEhloHeloHandler
{
 
-    @Resource(name = "dnsservice")
-    public void setDNSService(DNSService dns) {
-        super.setDNSService(new SMTPServerDNSServiceAdapter(dns));
-    }
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
Fri Jan  6 11:35:16 2012
@@ -26,7 +26,8 @@ import org.apache.james.jspf.core.except
 import org.apache.james.jspf.executor.SPFResult;
 import org.apache.james.jspf.impl.DefaultSPF;
 import org.apache.james.jspf.impl.SPF;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
+import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
@@ -36,11 +37,10 @@ import org.apache.james.protocols.smtp.h
 import org.apache.james.protocols.smtp.hook.RcptHook;
 import org.apache.james.smtpserver.JamesMessageHook;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, LifecycleAwareProtocolHandler
{
+public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, InitializingLifecycleAwareProtocolHandler
{
 
     /** This log is the fall back shared by all instances */
     private static final Logger FALLBACK_LOG = LoggerFactory.getLogger(SPFHandler.class);
@@ -112,7 +112,7 @@ public class SPFHandler implements James
             session.getLogger().info("No Sender or HELO/EHLO present");
         } else {
 
-            String ip = session.getRemoteIPAddress();
+            String ip = session.getRemoteAddress().getAddress().toString();
 
             SPFResult result = spf.checkSPF(ip, sender.toString(), heloEhlo);
 

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamAssassinHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamAssassinHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamAssassinHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamAssassinHandler.java
Fri Jan  6 11:35:16 2012
@@ -26,7 +26,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;
@@ -64,7 +64,7 @@ import org.apache.mailet.Mail;
  * 
  * </p>
  */
-public class SpamAssassinHandler implements JamesMessageHook, LifecycleAwareProtocolHandler
{
+public class SpamAssassinHandler implements JamesMessageHook, InitializingLifecycleAwareProtocolHandler
{
 
     /** The port spamd is listen on */
     private int spamdPort = 783;
@@ -134,7 +134,7 @@ public class SpamAssassinHandler impleme
                     // if the hits are bigger the rejectionHits reject the
                     // message
                     if (spamdRejectionHits <= hits) {
-                        StringBuffer buffer = new StringBuffer(256).append("Rejected message
from ").append(session.getState().get(SMTPSession.SENDER).toString()).append(" from host ").append(session.getRemoteHost()).append("
(").append(session.getRemoteIPAddress())
+                        StringBuffer buffer = new StringBuffer(256).append("Rejected message
from ").append(session.getState().get(SMTPSession.SENDER).toString()).append(" from host ").append(session.getRemoteAddress().getHostName()).append("
(").append(session.getRemoteAddress().getAddress().toString())
                                 .append(") This message reach the spam hits treshold. Required
rejection hits: ").append(spamdRejectionHits).append(" hits: ").append(hits);
                         session.getLogger().info(buffer.toString());
 

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamTrapHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamTrapHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamTrapHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/SpamTrapHandler.java
Fri Jan  6 11:35:16 2012
@@ -23,9 +23,9 @@ import java.util.List;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 
-public class SpamTrapHandler extends org.apache.james.protocols.smtp.core.fastfail.SpamTrapHandler
implements LifecycleAwareProtocolHandler {
+public class SpamTrapHandler extends org.apache.james.protocols.smtp.core.fastfail.SpamTrapHandler
implements InitializingLifecycleAwareProtocolHandler {
 
     @SuppressWarnings("unchecked")
     @Override

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/URIRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/URIRBLHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/URIRBLHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/URIRBLHandler.java
Fri Jan  6 11:35:16 2012
@@ -36,7 +36,7 @@ import javax.mail.internet.MimePart;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
  * Extract domains from message and check against URIRBLServer. For more
  * informations see <a href="http://www.surbl.org">www.surbl.org</a>
  */
-public class URIRBLHandler implements JamesMessageHook, LifecycleAwareProtocolHandler {
+public class URIRBLHandler implements JamesMessageHook, InitializingLifecycleAwareProtocolHandler
{
 
     /** This log is the fall back shared by all instances */
     private static final Logger FALLBACK_LOG = LoggerFactory.getLogger(URIRBLHandler.class);

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
Fri Jan  6 11:35:16 2012
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.smtpserver.fastfail;
 
 import java.util.Collection;
@@ -27,20 +26,20 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
+import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler;
 import org.apache.james.rrt.api.RecipientRewriteTable;
-import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
+import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.mailet.MailAddress;
 
 /**
  * Handler which reject invalid recipients
  */
-public class ValidRcptHandler extends AbstractValidRcptHandler implements LifecycleAwareProtocolHandler
{
+public class ValidRcptHandler extends AbstractValidRcptHandler implements InitializingLifecycleAwareProtocolHandler
{
 
     private UsersRepository users;
 

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptMX.java
Fri Jan  6 11:35:16 2012
@@ -32,14 +32,14 @@ import org.apache.commons.configuration.
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
+import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.hook.RcptHook;
-import org.apache.mailet.MailAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
  * This class can be used to reject email with bogus MX which is send from a
  * authorized user or an authorized network.
  */
-public class ValidRcptMX implements LifecycleAwareProtocolHandler, RcptHook {
+public class ValidRcptMX implements InitializingLifecycleAwareProtocolHandler, RcptHook {
 
     /** This log is the fall back shared by all instances */
     private static final Logger FALLBACK_LOG = LoggerFactory.getLogger(ValidRcptMX.class);
@@ -139,7 +139,7 @@ public class ValidRcptMX implements Life
 
                         // Check for invalid MX
                         if (bNetwork.matchInetNetwork(ip)) {
-                            return new HookResult(HookReturnCode.DENY, SMTPRetCode.AUTH_REQUIRED,
DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH) + " Invalid MX " + session.getRemoteIPAddress()
+ " for domain " + domain + ". Reject email");
+                            return new HookResult(HookReturnCode.DENY, SMTPRetCode.AUTH_REQUIRED,
DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH) + " Invalid MX " + session.getRemoteAddress().getAddress().toString()
+ " for domain " + domain + ". Reject email");
                         }
                     } catch (UnknownHostException e) {
                         // Ignore this

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidSenderDomainHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidSenderDomainHandler.java?rev=1228120&r1=1228119&r2=1228120&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidSenderDomainHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidSenderDomainHandler.java
Fri Jan  6 11:35:16 2012
@@ -19,16 +19,41 @@
 
 package org.apache.james.smtpserver.fastfail;
 
+import java.util.Collection;
+
 import javax.annotation.Resource;
 
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.smtpserver.SMTPServerDNSServiceAdapter;
+import org.apache.james.protocols.smtp.SMTPSession;
 
 public class ValidSenderDomainHandler extends org.apache.james.protocols.smtp.core.fastfail.ValidSenderDomainHandler
{
+    
+    private DNSService dnsService;
 
     @Resource(name = "dnsservice")
-    public void setDNSService(DNSService dns) {
-        super.setDNSService(new SMTPServerDNSServiceAdapter(dns));
+    public void setDNSService(DNSService dnsService) {
+        this.dnsService = dnsService;
+    }
+
+    @Override
+    protected boolean hasMXRecord(SMTPSession session, String domain) {
+        // null sender so return
+        if (domain == null) return false;
+
+        Collection<String> records = null;
+            
+        // try to resolv the provided domain in the senderaddress. If it can not resolved
do not accept it.
+            try {
+                records = dnsService.findMXRecords(domain);
+            } catch (org.apache.james.dnsservice.api.TemporaryResolutionException e) {
+                // TODO: Should we reject temporary ?
+            }
+    
+        if (records == null || records.size() == 0) {
+            return true;
+        }
+
+        return false;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message