Repository: james-project
Updated Branches:
  refs/heads/master 41c860c17 -> 7abdb538b


JAMES-1924 Guice should bind JSPF DNSService


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/39b5b287
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/39b5b287
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/39b5b287

Branch: refs/heads/master
Commit: 39b5b2876f71a64248bed85733188587bf82a750
Parents: 41c860c
Author: Benoit Tellier <btell...@linagora.com>
Authored: Mon Feb 6 14:45:45 2017 +0700
Committer: Benoit Tellier <btell...@linagora.com>
Committed: Tue Feb 7 16:34:55 2017 +0700

----------------------------------------------------------------------
 .../james/modules/protocols/SMTPServerModule.java     | 12 ++++++++++++
 .../apache/james/smtpserver/fastfail/SPFHandler.java  | 14 ++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/39b5b287/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
index bb5f233..5fa7bc6 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
@@ -21,8 +21,11 @@ package org.apache.james.modules.protocols;
 
 import java.util.List;
 
+import org.apache.james.jspf.core.DNSService;
+import org.apache.james.jspf.impl.DNSServiceXBillImpl;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.smtpserver.SendMailHandler;
+import org.apache.james.smtpserver.fastfail.SPFHandler;
 import org.apache.james.smtpserver.netty.SMTPServerFactory;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.ConfigurationProvider;
@@ -33,6 +36,8 @@ import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
 
@@ -42,8 +47,15 @@ public class SMTPServerModule extends AbstractModule {
 
     @Override
     protected void configure() {
+        bind(DNSServiceXBillImpl.class).in(Scopes.SINGLETON);
+
         Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(SMTPModuleConfigurationPerformer.class);
     }
+    
+    @Provides
+    public DNSServiceXBillImpl provideJSPFDNSService() {
+        return new DNSServiceXBillImpl(new SPFHandler.SPFLogger(LOGGER));
+    }
 
     @Singleton
     public static class SMTPModuleConfigurationPerformer implements 
ConfigurationPerformer {

http://git-wip-us.apache.org/repos/asf/james-project/blob/39b5b287/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
index 0d53bb2..588bd2b 100644
--- 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
+++ 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java
@@ -68,7 +68,7 @@ public class SPFHandler implements JamesMessageHook, 
MailHook, RcptHook, Protoco
 
     private boolean blockPermError = true;
 
-    private SPF spf = new DefaultSPF(new SPFLogger());
+    private SPF spf = new DefaultSPF(new SPFLogger(serviceLog));
 
     /**
      * block the email on a softfail
@@ -97,8 +97,8 @@ public class SPFHandler implements JamesMessageHook, 
MailHook, RcptHook, Protoco
      *            The DNSService
      */
     @Inject
-    public void setDNSService(DNSService dnsService) {
-        spf = new SPF(dnsService, new SPFLogger());
+    public void setDNSService(DNSService dnsService) {
+        spf = new SPF(dnsService, new SPFLogger(serviceLog));
     }
 
     /**
@@ -169,7 +169,13 @@ public class SPFHandler implements JamesMessageHook, 
MailHook, RcptHook, Protoco
     /**
      * Adapts service log.
      */
-    private final class SPFLogger implements org.apache.james.jspf.core.Logger 
{
+    public static class SPFLogger implements org.apache.james.jspf.core.Logger 
{
+
+        private final Logger serviceLog;
+
+        public SPFLogger(Logger serviceLog) {
+            this.serviceLog = serviceLog;
+        }
 
         /**
          * @see org.apache.james.jspf.core.Logger#debug(String)


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

Reply via email to