You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/10/23 14:23:19 UTC

svn commit: r829023 - in /james/server/trunk: phoenix-deployment/src/conf/ phoenix-deployment/src/java/org/apache/james/phoenix/ smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/ smtp-protocol-library/src/main/java/org/apache/ja...

Author: norman
Date: Fri Oct 23 12:23:18 2009
New Revision: 829023

URL: http://svn.apache.org/viewvc?rev=829023&view=rev
Log:
Add a new DNSService to te smtpserver-protocol module which is just a copy of the one in domain-api. This will help to factor out the smtpserver-protocol and not depend on james anymore
Add a SMTPServerDNSServiceAdapter which act as Adaptor to provide the needed implementation of the DNSService with James specific Implementation
Decouple smtpserver-protocol from James

Added:
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/DNSService.java
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/TemporaryResolutionException.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.java
    james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/
    james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.xinfo
Modified:
    james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
    james/server/trunk/phoenix-deployment/src/java/org/apache/james/phoenix/PhoenixLoader.java
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/AbstractGreylistHandler.java
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/DNSRBLHandler.java
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ResolvableEhloHeloHandler.java
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ValidSenderDomainHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/URIRBLHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.java
    james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/DelegatingSMTPServer.xinfo
    james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo
    james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.xinfo
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/DNSRBLHandlerTest.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java

Modified: james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml Fri Oct 23 12:23:18 2009
@@ -145,6 +145,7 @@
     <provide name="James" role="org.apache.mailet.MailetContext"/>
     <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>
     <provide name="dnsserver" role="org.apache.james.api.dnsservice.DNSService"/>
+    <provide name="org.apache.james.smtpserver.protocol.DNSService" role="org.apache.james.smtpserver.protocol.DNSService"/>
     <provide name="sockets"
              role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
     <provide name="connections"
@@ -152,7 +153,7 @@
     <provide name="James" role="org.apache.james.services.MailServer"/>
     <provide name="thread-manager"
              role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
-    <provide name="database-connections"213
+    <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
     <provide name="filesystem" role="org.apache.james.services.FileSystem" />
     <provide name="defaultvirtualusertable"
@@ -166,7 +167,8 @@
   <block name="smtpserver" class="org.apache.james.smtpserver.mina.AvalonAsyncSMTPServer" >
     <provide name="James" role="org.apache.mailet.MailetContext"/>
     <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>
-    <provide name="dnsserver" role="org.apache.james.api.dnsservice.DNSService"/>
+    <provide name="org.apache.james.smtpserver.protocol.DNSService" role="org.apache.james.smtpserver.protocol.DNSService"/>
+    <provide name="dnsserver" role="org.apache.james.api.dnsservice.DNSService"/>    
     <provide name="James" role="org.apache.james.services.MailServer"/>
     <provide name="database-connections"
              role="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" />
@@ -178,6 +180,10 @@
   </block>
   -->
 
+  <block name="org.apache.james.smtpserver.protocol.DNSService" class="org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter" >
+    <proxy disable='true'/>
+  </block>
+  
   <!-- NNTP Server -->
   <block name="nntpserver" class="org.apache.james.nntpserver.NNTPServer" >
     <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>

Modified: james/server/trunk/phoenix-deployment/src/java/org/apache/james/phoenix/PhoenixLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/java/org/apache/james/phoenix/PhoenixLoader.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/java/org/apache/james/phoenix/PhoenixLoader.java (original)
+++ james/server/trunk/phoenix-deployment/src/java/org/apache/james/phoenix/PhoenixLoader.java Fri Oct 23 12:23:18 2009
@@ -40,13 +40,53 @@
     private Logger logger;
     
     private final Map<String, Object> servicesByName;
-
+    private final Map<String, String> nameMappings;
     public PhoenixLoader() {
-        servicesByName = new HashMap<String, Object>();
+        nameMappings = new HashMap<String, String>();
+        setupNameMappings();
+        servicesByName = new HashMap<String, Object>();     
         servicesByName.put("org.apache.james.LoaderService", this);
     }
     
+    /**
+     * This is really a ugly thing put it let us refactor step by step
+     */
+    private void setupNameMappings() {
+        nameMappings.put("org.apache.james.services.MailServer", "James");
+        nameMappings.put("org.apache.mailet.MailetContext", "James");
+        nameMappings.put("org.apache.james.services.FileSystem", "filesystem");
+        nameMappings.put("org.apache.james.api.dnsservice.DNSService", "dnsserver");
+        nameMappings.put("org.apache.james.services.MailServer", "James");
+        nameMappings.put("org.apache.james.api.user.UsersRepository", "localusersrepository");
+        nameMappings.put("org.apache.james.services.SpoolRepository", "spoolrepository");
+        nameMappings.put("org.apache.james.api.domainlist.DomainList", "domainlist");
+        nameMappings.put("org.apache.avalon.cornerstone.services.sockets.SocketManager", "sockets");
+        nameMappings.put("org.apache.james.services.SpoolRepository", "spoolrepository");
+        nameMappings.put("org.apache.avalon.cornerstone.services.scheduler.TimeScheduler", "scheduler");
+        nameMappings.put("org.apache.avalon.cornerstone.services.datasources.DataSourceSelector", "database-connections");
+        nameMappings.put("org.apache.james.api.vut.VirtualUserTable", "defaultvirtualusertable");
+        nameMappings.put("org.apache.james.transport.MatcherLoader", "matcherpackages");
+        nameMappings.put("org.apache.james.transport.MailetLoader", "mailetpackages");
+        nameMappings.put("org.apache.avalon.cornerstone.services.store.Store", "mailstore");
+        nameMappings.put("org.apache.james.transport.MatcherLoader", "matcherpackages");
+        nameMappings.put("org.apache.james.api.user.UsersStore", "users-store");
+
+
+        nameMappings.put("org.apache.james.socket.JamesConnectionManager", "connections");
+        nameMappings.put("org.apache.avalon.cornerstone.services.threads.ThreadManager", "thread-manager");
+        nameMappings.put("org.apache.james.management.SpoolManagementService", "spoolmanagement");
+        nameMappings.put("org.apache.james.management.BayesianAnalyzerManagementService", "bayesiananalyzermanagement");
+        nameMappings.put("org.apache.james.management.ProcessorManagementService", "processormanagement");
+
+        nameMappings.put("org.apache.james.api.vut.management.VirtualUserTableManagementService", "virtualusertablemanagement");
+        nameMappings.put("org.apache.james.management.DomainListManagementService", "domainlistmanagement");
+    }
+    
     public Object get(String name) {
+        // re-map if needed
+        if (nameMappings.containsKey(name)) {
+            name = nameMappings.get(name);
+        }
         Object service = servicesByName.get(name);
         return service;
     }

Added: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/DNSService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/DNSService.java?rev=829023&view=auto
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/DNSService.java (added)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/DNSService.java Fri Oct 23 12:23:18 2009
@@ -0,0 +1,107 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+
+
+package org.apache.james.smtpserver.protocol;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.mailet.HostAddress;
+
+
+/**
+ * Provides abstraction for DNS resolutions. The interface is Mail specific.
+ * It may be a good idea to make the interface more generic or expose 
+ * commonly needed DNS methods.
+ *
+ */
+public interface DNSService {
+
+    /**
+     * The component role used by components implementing this service
+     */
+    String ROLE = "org.apache.james.api.dnsservice.DNSService";
+
+    /**
+     * <p>Return a prioritized unmodifiable list of host handling mail
+     * for the domain.</p>
+     * 
+     * <p>First lookup MX hosts, then MX hosts of the CNAME adress, and
+     * if no server is found return the IP of the hostname</p>
+     *
+     * @param hostname domain name to look up
+     *
+     * @return a unmodifiable list of handling servers corresponding to
+     *         this mail domain name
+     * @throws TemporaryResolutionException get thrown on temporary problems 
+     */
+    Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException;
+
+    /**
+     * Get a collection of DNS TXT Records
+     * 
+     * @param hostname The hostname to check
+     * @return collection of strings representing TXT record values
+     */
+    Collection<String> findTXTRecords(String hostname);
+
+
+    /**
+     * Returns an Iterator over org.apache.mailet.HostAddress, a
+     * specialized subclass of javax.mail.URLName, which provides
+     * location information for servers that are specified as mail
+     * handlers for the given hostname.  This is done using MX records,
+     * and the HostAddress instances are returned sorted by MX priority.
+     * If no host is found for domainName, the Iterator returned will be
+     * empty and the first call to hasNext() will return false.  The
+     * Iterator is a nested iterator: the outer iteration is over the
+     * results of the MX record lookup, and the inner iteration is over
+     * potentially multiple A records for each MX record.  DNS lookups
+     * are deferred until actually needed.
+     *
+     * @since v2.2.0a16-unstable
+     * @param domainName - the domain for which to find mail servers
+     * @return an Iterator over HostAddress instances, sorted by priority
+     * @throws TemporaryResolutionException get thrown on temporary problems
+     */
+    Iterator<HostAddress> getSMTPHostAddresses(String domainName) throws TemporaryResolutionException;
+    
+    /**
+     * @see java.net.InetAddress#getAllByName(String)
+     */
+    public InetAddress[] getAllByName(String host) throws UnknownHostException;
+ 
+    /**
+     * @see java.net.InetAddress#getByName(String)
+     */
+    public InetAddress getByName(String host) throws UnknownHostException;
+
+    /**
+     * @see org.xbill.DNS.Address#getHostName(InetAddress)
+     */
+    public String getHostName(InetAddress addr);
+    
+    /**
+     */
+    public InetAddress getLocalHost() throws UnknownHostException;
+}

Added: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/TemporaryResolutionException.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/TemporaryResolutionException.java?rev=829023&view=auto
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/TemporaryResolutionException.java (added)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/TemporaryResolutionException.java Fri Oct 23 12:23:18 2009
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+
+
+
+package org.apache.james.smtpserver.protocol;
+
+import java.io.IOException;
+
+public class TemporaryResolutionException extends IOException {
+
+    public TemporaryResolutionException() {
+        super();
+    }
+
+    public TemporaryResolutionException(String message) {
+        super(message);
+    }
+}

Modified: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/AbstractGreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/AbstractGreylistHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/AbstractGreylistHandler.java (original)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/AbstractGreylistHandler.java Fri Oct 23 12:23:18 2009
@@ -24,8 +24,6 @@
 
 import javax.annotation.Resource;
 
-import org.apache.james.api.dnsservice.DNSService;
-import org.apache.james.api.dnsservice.util.NetMatcher;
 import org.apache.james.api.protocol.Configurable;
 import org.apache.james.dsn.DSNStatus;
 import org.apache.james.smtpserver.protocol.SMTPRetCode;
@@ -53,27 +51,6 @@
     private long unseenLifeTime = 14400000;
 
 
-    private DNSService dnsService;
-
-    private NetMatcher wNetworks;
-    
-    /**
-     * Gets the DNS service.
-     * @return the dnsService
-     */
-    public final DNSService getDNSService() {
-        return dnsService;
-    }
-
-    /**
-     * Sets the DNS service.
-     * @param dnsService the dnsService to set
-     */
-    @Resource(name="dnsserver")
-    public final void setDNSService(DNSService dnsService) {
-        this.dnsService = dnsService;
-    }
-
     
     public void setUnseenLifeTime(long unseenLifeTime) {
         this.unseenLifeTime = unseenLifeTime;
@@ -86,14 +63,7 @@
     public void setTempBlockTime(long tempBlockTime) {
         this.tempBlockTime = tempBlockTime;
     }
-    
-    public void setWhiteListedNetworks(NetMatcher wNetworks) {
-        this.wNetworks = wNetworks;
-    }
-    
-    protected NetMatcher getWhiteListedNetworks() {
-        return wNetworks;
-    }
+
 
     private HookResult doGreyListCheck(SMTPSession session, MailAddress senderAddress, MailAddress recipAddress) {
         String recip = "";
@@ -240,12 +210,7 @@
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
         if (!session.isRelayingAllowed()) {
-
-            if ((wNetworks == null) || (!wNetworks.matchInetNetwork(session.getRemoteIPAddress()))) {
-                return doGreyListCheck(session, sender,rcpt);
-            } else {
-                session.getLogger().info("IpAddress " + session.getRemoteIPAddress() + " is whitelisted. Skip greylisting.");
-            }
+            return doGreyListCheck(session, sender,rcpt);
         } else {
             session.getLogger().info("IpAddress " + session.getRemoteIPAddress() + " is allowed to send. Skip greylisting.");
         }

Modified: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/DNSRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/DNSRBLHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/DNSRBLHandler.java (original)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/DNSRBLHandler.java Fri Oct 23 12:23:18 2009
@@ -32,10 +32,10 @@
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.protocol.Configurable;
 import org.apache.james.dsn.DSNStatus;
 import org.apache.james.smtpserver.protocol.ConnectHandler;
+import org.apache.james.smtpserver.protocol.DNSService;
 import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.hook.HookResult;
 import org.apache.james.smtpserver.protocol.hook.HookReturnCode;
@@ -82,7 +82,7 @@
      * Sets the DNS service.
      * @param dnsService the dnsService to set
      */
-    @Resource(name="dnsserver")
+    @Resource(name="org.apache.james.smtpserver.protocol.DNSService")
     public final void setDNSService(DNSService dnsService) {
         this.dnsService = dnsService;
     }
@@ -222,7 +222,7 @@
                     
                     // we should try to retrieve details
                     if (getDetail) {
-                        Collection txt = dnsService.findTXTRecords(reversedOctets + rblList[i]);
+                        Collection<String> txt = dnsService.findTXTRecords(reversedOctets + rblList[i]);
                         
                         // Check if we found a txt record
                         if (!txt.isEmpty()) {

Modified: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ResolvableEhloHeloHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ResolvableEhloHeloHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ResolvableEhloHeloHandler.java (original)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ResolvableEhloHeloHandler.java Fri Oct 23 12:23:18 2009
@@ -25,9 +25,9 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.protocol.Configurable;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.smtpserver.protocol.DNSService;
 import org.apache.james.smtpserver.protocol.SMTPRetCode;
 import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.hook.HeloHook;
@@ -60,11 +60,10 @@
      * Sets the DNS service.
      * @param dnsService the dnsService to set
      */
-    @Resource(name="dnsserver")
+    @Resource(name="org.apache.james.smtpserver.protocol.DNSService")
     public final void setDNSService(DNSService dnsService) {
         this.dnsService = dnsService;
     }
-    
 
     /**
      * (non-Javadoc)

Modified: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ValidSenderDomainHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ValidSenderDomainHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ValidSenderDomainHandler.java (original)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/fastfail/ValidSenderDomainHandler.java Fri Oct 23 12:23:18 2009
@@ -24,12 +24,12 @@
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.api.dnsservice.DNSService;
-import org.apache.james.api.dnsservice.TemporaryResolutionException;
 import org.apache.james.api.protocol.Configurable;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.smtpserver.protocol.DNSService;
 import org.apache.james.smtpserver.protocol.SMTPRetCode;
 import org.apache.james.smtpserver.protocol.SMTPSession;
+import org.apache.james.smtpserver.protocol.TemporaryResolutionException;
 import org.apache.james.smtpserver.protocol.hook.HookResult;
 import org.apache.james.smtpserver.protocol.hook.HookReturnCode;
 import org.apache.james.smtpserver.protocol.hook.MailHook;
@@ -56,7 +56,7 @@
      * Sets the DNS service.
      * @param dnsService the dnsService to set
      */
-    @Resource(name="dnsserver")
+    @Resource(name="org.apache.james.smtpserver.protocol.DNSService")
     public final void setDNSService(DNSService dnsService) {
         this.dnsService = dnsService;
     }
@@ -90,7 +90,7 @@
         	return false;
         }
 
-        Collection records = null;
+        Collection<String> records = null;
             
         // try to resolv the provided domain in the senderaddress. If it can not resolved do not accept it.
         try {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/JDBCGreylistHandler.java Fri Oct 23 12:23:18 2009
@@ -42,13 +42,18 @@
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.james.api.dnsservice.DNSService;
 import org.apache.james.api.dnsservice.util.NetMatcher;
 import org.apache.james.api.protocol.LogEnabled;
 import org.apache.james.services.FileSystem;
+import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.core.fastfail.AbstractGreylistHandler;
+import org.apache.james.smtpserver.protocol.hook.HookResult;
+import org.apache.james.smtpserver.protocol.hook.HookReturnCode;
 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;
 
 /**
  * GreylistHandler which can be used to activate Greylisting
@@ -97,7 +102,13 @@
      * The repositoryPath
      */
     private String repositoryPath;
+
+    private DNSService dnsService;
     
+
+    private NetMatcher wNetworks;
+    
+
     
     /**
      * Gets the file system service.
@@ -112,7 +123,7 @@
      * 
      * @param system The filesystem service
      */
-    @Resource(name="filesystem")
+    @Resource(name="org.apache.james.services.FileSystem")
     public void setFileSystem(FileSystem system) {
         this.fileSystem = system;
     }
@@ -178,6 +189,21 @@
         setUnseenLifeTime(TimeConverter.getMilliSeconds(unseenLifeTime));
     }
     
+    @Resource(name="org.apache.james.api.dnsservice.DNSService")
+    public final void setDNSService(DNSService dnsService) {
+        this.dnsService = dnsService;
+    }
+    
+    
+    public void setWhiteListedNetworks(NetMatcher wNetworks) {
+        this.wNetworks = wNetworks;
+    }
+    
+    protected NetMatcher getWhiteListedNetworks() {
+        return wNetworks;
+    }
+    
+    
     /**
      * @see org.apache.james.smtpserver.protocol.core.fastfail.AbstractGreylistHandler#configure(org.apache.commons.configuration.Configuration)
      */
@@ -207,7 +233,7 @@
         if (nets != null) {
 
             if (nets != null) {
-                setWhiteListedNetworks( new NetMatcher(nets,getDNSService()));
+                setWhiteListedNetworks( new NetMatcher(nets ,dnsService));
                 serviceLog.info("Whitelisted addresses: " + getWhiteListedNetworks().toString());
             }
         }    	
@@ -495,6 +521,19 @@
         return true;
     }
 
+    
+    /**
+     * @see org.apache.james.smtpserver.protocol.core.fastfail.AbstractGreylistHandler#doRcpt(org.apache.james.smtpserver.protocol.SMTPSession, org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
+     */
+    public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
+        if ((wNetworks == null) || (!wNetworks.matchInetNetwork(session.getRemoteIPAddress()))) {
+            return super.doRcpt(session, sender, rcpt);
+        } else {
+            session.getLogger().info("IpAddress " + session.getRemoteIPAddress() + " is whitelisted. Skip greylisting.");
+        }
+        return new HookResult(HookReturnCode.DECLINED);
+    }
+
     /**
      * @see org.apache.james.api.protocol.LogEnabled#setLog(org.apache.commons.logging.Log)
      */

Added: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.java?rev=829023&view=auto
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.java (added)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.java Fri Oct 23 12:23:18 2009
@@ -0,0 +1,104 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+package org.apache.james.smtpserver.integration;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.annotation.Resource;
+
+import org.apache.james.smtpserver.protocol.DNSService;
+import org.apache.james.smtpserver.protocol.TemporaryResolutionException;
+import org.apache.mailet.HostAddress;
+
+public class SMTPServerDNSServiceAdapter implements DNSService{
+
+    private org.apache.james.api.dnsservice.DNSService dns;
+
+    
+    public SMTPServerDNSServiceAdapter() {    
+    
+    }
+    
+    @Resource(name="org.apache.james.api.dnsservice.DNSService")
+    public void setDNSService(org.apache.james.api.dnsservice.DNSService dns) {
+        this.dns = dns;
+    }
+    
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#findMXRecords(java.lang.String)
+     */
+    public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException {
+        try {
+            return dns.findMXRecords(hostname);
+        } catch (org.apache.james.api.dnsservice.TemporaryResolutionException e) {
+            throw new TemporaryResolutionException(e.getMessage());
+        }
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#findTXTRecords(java.lang.String)
+     */
+    public Collection<String> findTXTRecords(String hostname) {
+        return dns.findTXTRecords(hostname);
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#getAllByName(java.lang.String)
+     */
+    public InetAddress[] getAllByName(String host) throws UnknownHostException {
+        return dns.getAllByName(host);
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#getByName(java.lang.String)
+     */
+    public InetAddress getByName(String host) throws UnknownHostException {
+        return dns.getByName(host);
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#getHostName(java.net.InetAddress)
+     */
+    public String getHostName(InetAddress addr) {
+        return dns.getHostName(addr);
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#getLocalHost()
+     */
+    public InetAddress getLocalHost() throws UnknownHostException {
+        return dns.getLocalHost();
+    }
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.DNSService#getSMTPHostAddresses(java.lang.String)
+     */
+    @SuppressWarnings("unchecked")
+    public Iterator<HostAddress> getSMTPHostAddresses(String domainName) throws TemporaryResolutionException {
+        try {
+            return dns.getSMTPHostAddresses(domainName);
+        } catch (org.apache.james.api.dnsservice.TemporaryResolutionException e) {
+            throw new TemporaryResolutionException(e.getMessage());
+        }
+    }
+
+}

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/URIRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/URIRBLHandler.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/URIRBLHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/integration/URIRBLHandler.java Fri Oct 23 12:23:18 2009
@@ -98,6 +98,7 @@
         this.dnsService = dnsService;
     }
     
+    
 
     
     /**

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.java Fri Oct 23 12:23:18 2009
@@ -66,6 +66,7 @@
 	private UsersRepository userRepos;
 	private DataSourceSelector dselector;
 	private VirtualUserTableStore vutStore;
+    private org.apache.james.smtpserver.protocol.DNSService dnsServiceAdapter;
    
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
@@ -89,6 +90,7 @@
         userRepos = (UsersRepository) manager.lookup(UsersRepository.ROLE);
         dselector = (DataSourceSelector) manager.lookup(DataSourceSelector.ROLE);
         vutStore = (VirtualUserTableStore) manager.lookup(VirtualUserTableStore.ROLE);
+        dnsServiceAdapter = (org.apache.james.smtpserver.protocol.DNSService) manager.lookup("org.apache.james.smtpserver.protocol.DNSService");
     }
 
     /**
@@ -116,6 +118,7 @@
         protected void configure() {
             bind(AsyncSMTPServer.class).in(Singleton.class);
             bind(DNSService.class).annotatedWith(Names.named("org.apache.james.api.dnsservice.DNSService")).toInstance(dns);
+            bind(org.apache.james.smtpserver.protocol.DNSService.class).annotatedWith(Names.named("org.apache.james.smtpserver.protocol.DNSService")).toInstance(dnsServiceAdapter);
             bind(MailServer.class).annotatedWith(Names.named("org.apache.james.services.MailServer")).toInstance(mailserver);
             bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
             bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);

Modified: james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/DelegatingSMTPServer.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/DelegatingSMTPServer.xinfo?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/DelegatingSMTPServer.xinfo (original)
+++ james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/DelegatingSMTPServer.xinfo Fri Oct 23 12:23:18 2009
@@ -40,6 +40,9 @@
       <service name="org.apache.james.api.dnsservice.DNSService" version="1.0"/>
     </dependency>
     <dependency>
+      <service name="org.apache.james.smtpserver.protocol.DNSService" version="1.0"/>
+    </dependency>
+    <dependency>
       <service name="org.apache.james.socket.JamesConnectionManager" version="1.0"/>
     </dependency>
     <dependency>

Modified: james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo (original)
+++ james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/SMTPServer.xinfo Fri Oct 23 12:23:18 2009
@@ -40,6 +40,9 @@
       <service name="org.apache.james.api.dnsservice.DNSService" version="1.0"/>
     </dependency>
     <dependency>
+      <service name="org.apache.james.smtpserver.protocol.DNSService" version="1.0"/>
+    </dependency>
+    <dependency>
       <service name="org.apache.james.socket.JamesConnectionManager" version="1.0"/>
     </dependency>
     <dependency>

Added: james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.xinfo?rev=829023&view=auto
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.xinfo (added)
+++ james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/integration/SMTPServerDNSServiceAdapter.xinfo Fri Oct 23 12:23:18 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+  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.                                           
+ -->
+<blockinfo>
+
+  <!-- section to describe block -->
+  <block>
+    <version>1.0</version>
+  </block>
+  
+  <services>
+    <service name="org.apache.james.smtpserver.protocol.DNSService" version="1.0" />
+  </services>
+</blockinfo>

Modified: james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.xinfo?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.xinfo (original)
+++ james/server/trunk/smtpserver-function/src/main/resources/org/apache/james/smtpserver/mina/AvalonAsyncSMTPServer.xinfo Fri Oct 23 12:23:18 2009
@@ -40,6 +40,9 @@
       <service name="org.apache.james.api.dnsservice.DNSService" version="1.0"/>
     </dependency>
     <dependency>
+      <service name="org.apache.james.smtpserver.protocol.DNSService" version="1.0"/>
+    </dependency>
+    <dependency>
       <service name="org.apache.james.services.MailServer" version="1.0"/>
     </dependency> 
     <dependency>

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/AsyncSMTPServerTest.java Fri Oct 23 12:23:18 2009
@@ -30,6 +30,7 @@
 import org.apache.james.api.vut.VirtualUserTableStore;
 import org.apache.james.services.FileSystem;
 import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
 import org.apache.james.smtpserver.mina.AvalonAsyncSMTPServer;
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.test.mock.avalon.MockStore;
@@ -70,7 +71,10 @@
         m_serviceManager.put(FileSystem.ROLE, new MockFileSystem());
         m_serviceManager.put(VirtualUserTableStore.ROLE, new DummyVirtualUserTableStore());
         m_serviceManager.put(DataSourceSelector.ROLE, new DummyDataSourceSelector());
-
+        
+        SMTPServerDNSServiceAdapter dnsAdapter = new SMTPServerDNSServiceAdapter();
+        dnsAdapter.setDNSService(m_dnsServer);
+        m_serviceManager.put("org.apache.james.smtpserver.protocol.DNSService", dnsAdapter);
         return m_serviceManager;
     }
     

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/DNSRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/DNSRBLHandlerTest.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/DNSRBLHandlerTest.java Fri Oct 23 12:23:18 2009
@@ -40,7 +40,7 @@
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.api.dnsservice.AbstractDNSServer;
-import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
 import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.core.fastfail.DNSRBLHandler;
 import org.apache.james.test.mock.avalon.MockLogger;
@@ -48,7 +48,7 @@
 
 public class DNSRBLHandlerTest extends TestCase {
 
-    private DNSService mockedDnsServer;
+    private SMTPServerDNSServiceAdapter mockedDnsServer;
 
     private SMTPSession mockedSMTPSession;
 
@@ -89,7 +89,7 @@
      *
      */
     private void setupMockedDnsServer() {
-        mockedDnsServer = new AbstractDNSServer() {
+        org.apache.james.api.dnsservice.DNSService dns  = new AbstractDNSServer() {
 
             public Collection findMXRecords(String hostname) {
                 throw new UnsupportedOperationException("Unimplemented in mock");
@@ -119,6 +119,9 @@
                 throw new UnsupportedOperationException("getByName("+host+") not implemented in DNSRBLHandlerTest mock");
             }
         };
+        
+        mockedDnsServer = new SMTPServerDNSServiceAdapter();
+        mockedDnsServer.setDNSService(dns);
     }
 
     /**

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java Fri Oct 23 12:23:18 2009
@@ -33,6 +33,7 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.james.api.dnsservice.AbstractDNSServer;
 import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
 import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.core.fastfail.ResolvableEhloHeloHandler;
 import org.apache.james.smtpserver.protocol.hook.HookReturnCode;
@@ -80,7 +81,7 @@
         return session;
     }
     
-    private DNSService setupMockDNSServer() {
+    private SMTPServerDNSServiceAdapter setupMockDNSServer() {
     	DNSService dns = new AbstractDNSServer(){
             public InetAddress getByName(String host) throws UnknownHostException {
                 if (host.equals(INVALID_HOST)) 
@@ -89,7 +90,9 @@
             }
         };
         
-        return dns;
+        SMTPServerDNSServiceAdapter adapter = new SMTPServerDNSServiceAdapter();
+        adapter.setDNSService(dns);
+        return adapter;
     }
     
     public void testRejectInvalidHelo() throws ParseException {

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java Fri Oct 23 12:23:18 2009
@@ -49,6 +49,7 @@
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.services.FileSystem;
 import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
 import org.apache.james.socket.JamesConnectionManager;
 import org.apache.james.socket.SimpleConnectionManager;
 import org.apache.james.test.mock.avalon.MockLogger;
@@ -217,7 +218,10 @@
         m_serviceManager.put("dnsserver", m_dnsServer);
         m_serviceManager.put(Store.ROLE, new MockStore());
         m_serviceManager.put(FileSystem.ROLE, new MockFileSystem());
-    
+        
+        SMTPServerDNSServiceAdapter dnsAdapter = new SMTPServerDNSServiceAdapter();
+        dnsAdapter.setDNSService(m_dnsServer);
+        m_serviceManager.put("org.apache.james.smtpserver.protocol.DNSService", dnsAdapter);
         return m_serviceManager;
     }
 

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java?rev=829023&r1=829022&r2=829023&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java (original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java Fri Oct 23 12:23:18 2009
@@ -31,6 +31,7 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.james.api.dnsservice.AbstractDNSServer;
 import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.smtpserver.integration.SMTPServerDNSServiceAdapter;
 import org.apache.james.smtpserver.protocol.SMTPSession;
 import org.apache.james.smtpserver.protocol.core.fastfail.ValidSenderDomainHandler;
 import org.apache.james.smtpserver.protocol.hook.HookReturnCode;
@@ -39,7 +40,7 @@
 
 public class ValidSenderDomainHandlerTest extends TestCase {
     
-    private DNSService setupDNSServer() {
+    private SMTPServerDNSServiceAdapter setupDNSServer() {
     	DNSService dns = new AbstractDNSServer(){
 
             public Collection findMXRecords(String hostname) {
@@ -51,7 +52,9 @@
             }
             
         };
-        return dns;
+        SMTPServerDNSServiceAdapter adapter = new SMTPServerDNSServiceAdapter();
+        adapter.setDNSService(dns);
+        return adapter;
     }
     
     private SMTPSession setupMockedSession(final MailAddress sender) {



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