You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/10/03 01:34:06 UTC

[james-project] branch master updated (d395434d44 -> 923f967ada)

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


    from d395434d44 JAMES-3825 Cancel tasks upon graceful shutdown (#1214)
     new ff8fb4b687 JAMES-3820 implement DNSRBLHandler as a MailHook instead of RcptHook to call it as soon as possible after SMTP authentication
     new 195d98f9f4 JAMES-3820 change SenderAuthIdentifyVerificationHook from RcptHook to MailHook (sender verification happens on MAIL FROM)
     new fa812bae67 JAMES-3820 change ResolvableEhloHeloHandler from RcptHook to MailHook (bad helo names should fail unless AUTH is successful)
     new d9ec6995f1 JAMES-3820 remove RcptHook from SPFHandler because handling SPF happens on MAIL FROM and not RCPT TO
     new 5d22d4d907 JAMES-3820 fix checkstyle warnings for SPFHandler
     new 454370daba JAMES-3820 fix missing renames of SenderAuthIdentifyVerificationHook
     new 8e93634705 JAMES-3820 reintroduce RcptHook for handlers that allow running James as MSA or MTA and update SMTP integration tests
     new 923f967ada JAMES-3820 fix mailet integration tests

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 examples/custom-smtp-command/README.md             |   2 +-
 .../apache/james/examples/MyCmdHandlerLoader.java  |   4 +-
 ...bstractSenderAuthIdentifyVerificationHook.java} |  59 ++++---
 .../smtp/core/fastfail/DNSRBLHandler.java          | 178 ++++++++++++---------
 .../core/fastfail/ResolvableEhloHeloHandler.java   |  23 +--
 .../smtp/core/fastfail/DNSRBLHandlerTest.java      |  40 ++---
 .../fastfail/ResolvableEhloHeloHandlerTest.java    |  23 ++-
 .../james/smtp/SmtpIdentityVerificationTest.java   |   6 +-
 .../james/smtpserver/CoreCmdHandlerLoader.java     |   2 +-
 ...ava => SenderAuthIdentifyVerificationHook.java} |  12 +-
 .../james/smtpserver/fastfail/SPFHandler.java      |  14 +-
 .../apache/james/smtpserver/SMTPServerTest.java    |  15 +-
 .../apache/james/smtpserver/SPFHandlerTest.java    |  28 +---
 src/homepage/howTo/custom-smtp-commands.html       |   2 +-
 14 files changed, 212 insertions(+), 196 deletions(-)
 rename protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/{AbstractSenderAuthIdentifyVerificationRcptHook.java => AbstractSenderAuthIdentifyVerificationHook.java} (71%)
 rename server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/{SenderAuthIdentifyVerificationRcptHook.java => SenderAuthIdentifyVerificationHook.java} (88%)


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


[james-project] 07/08: JAMES-3820 reintroduce RcptHook for handlers that allow running James as MSA or MTA and update SMTP integration tests

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 8e936347050f33bd8ebf2cc810bf20ca4b7dd6d9
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Tue Sep 27 22:03:29 2022 +0200

    JAMES-3820 reintroduce RcptHook for handlers that allow running James as MSA or MTA and update SMTP integration tests
---
 ...AbstractSenderAuthIdentifyVerificationHook.java |  57 ++++---
 .../smtp/core/fastfail/DNSRBLHandler.java          | 171 +++++++++++----------
 .../core/fastfail/ResolvableEhloHeloHandler.java   |  24 +--
 .../smtp/core/fastfail/DNSRBLHandlerTest.java      |  28 ++--
 .../SenderAuthIdentifyVerificationHook.java        |   4 +-
 .../apache/james/smtpserver/SMTPServerTest.java    |  15 +-
 6 files changed, 170 insertions(+), 129 deletions(-)

diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
index 6f89c73987..edf54e4c5f 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
@@ -28,13 +28,14 @@ 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.MailHook;
+import org.apache.james.protocols.smtp.hook.RcptHook;
 
 import com.google.common.base.Preconditions;
 
 /**
  * Handler which check if the authenticated user is the same as the one used as MAIL FROM
  */
-public abstract class AbstractSenderAuthIdentifyVerificationHook implements MailHook {
+public abstract class AbstractSenderAuthIdentifyVerificationHook implements MailHook, RcptHook {
     private static final HookResult INVALID_AUTH = HookResult.builder()
         .hookReturnCode(HookReturnCode.deny())
         .smtpReturnCode(SMTPRetCode.BAD_SEQUENCE)
@@ -47,28 +48,46 @@ public abstract class AbstractSenderAuthIdentifyVerificationHook implements Mail
         .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH)
             + " Authentication Required")
         .build();
+
+    /*
+     * Check if the sender address is the same as the user which was used to authenticate.
+     * Its important to ignore case here to fix JAMES-837. This is save to do because if the handler is called
+     * the user was already authenticated
+     */
+    private boolean senderDoesNotMatchAuthUser(SMTPSession session, MaybeSender sender) {
+        return session.getUsername() != null &&
+            (isAnonymous(sender) || !senderMatchSessionUser(sender, session) || !belongsToLocalDomain(sender));
+    }
+
+    /*
+     * Validate that unauthenticated users do not use local addresses in MAIL FROM
+     */
+    private boolean unauthenticatedSenderIsLocalUser(SMTPSession session, MaybeSender sender) {
+        return session.getUsername() == null && !session.isRelayingAllowed() && belongsToLocalDomain(sender);
+    }
+
+    protected HookResult doCheck(SMTPSession session, MaybeSender sender) {
+        if (senderDoesNotMatchAuthUser(session, sender)) {
+            return INVALID_AUTH;
+        } else if (unauthenticatedSenderIsLocalUser(session, sender)) {
+            return AUTH_REQUIRED;
+        } else {
+            return HookResult.DECLINED;
+        }
+    }
     
     @Override
     public HookResult doMail(SMTPSession session, MaybeSender sender) {
-        if (session.getUsername() != null) {
-            // Check if the sender address is the same as the user which was used to authenticate.
-            // Its important to ignore case here to fix JAMES-837. This is save to do because if the handler is called
-            // the user was already authenticated
+        return doCheck(session, sender);
+    }
 
-            if (isAnonymous(sender)
-                || !senderMatchSessionUser(sender, session)
-                || !belongsToLocalDomain(sender)) {
-                return INVALID_AUTH;
-            }
-            return HookResult.DECLINED;
-        } else {
-            // Validate that unauthenticated users do not use local addresses in MAIL FROM
-            if (belongsToLocalDomain(sender) && !session.isRelayingAllowed()) {
-                return AUTH_REQUIRED;
-            } else {
-                return HookResult.DECLINED;
-            }
-        }
+    /**
+     * If {@link #doMail(SMTPSession, MaybeSender)} was skipped because of successful AUTH
+     * we need to check it here.
+     */
+    @Override
+    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+        return doCheck(session, sender);
     }
 
     private boolean isAnonymous(MaybeSender maybeSender) {
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
index 4a682fa9f8..1e9e6516cb 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
@@ -22,9 +22,9 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Optional;
 import java.util.StringTokenizer;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.ProtocolSession.State;
@@ -33,6 +33,7 @@ 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.MailHook;
+import org.apache.james.protocols.smtp.hook.RcptHook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,7 +46,7 @@ import org.slf4j.LoggerFactory;
   * <a href="https://datatracker.ietf.org/doc/html/rfc4954#section-5">RFC 4954</a> auth information
   * can optionally provided as ESMTP AUTH parameter with a single value in the 'MAIL FROM:' command.
   */
-public class DNSRBLHandler implements MailHook {
+public class DNSRBLHandler implements MailHook, RcptHook {
     private static final Logger LOGGER = LoggerFactory.getLogger(DNSRBLHandler.class);
 
     /**
@@ -55,10 +56,12 @@ public class DNSRBLHandler implements MailHook {
     private String[] blacklist;
         
     private boolean getDetail = false;
+
+    public static final ProtocolSession.AttachmentKey<Boolean> RBL_CHECK_PERFORMED = ProtocolSession.AttachmentKey.of("org.apache.james.smtpserver.rbl.checked", Boolean.class);
+
+    public static final ProtocolSession.AttachmentKey<Boolean> RBL_BLOCKLISTED = ProtocolSession.AttachmentKey.of("org.apache.james.smtpserver.rbl.blocklisted", Boolean.class);
     
-    public static final ProtocolSession.AttachmentKey<Boolean> RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME = ProtocolSession.AttachmentKey.of("org.apache.james.smtpserver.rbl.blocklisted", Boolean.class);
-    
-    public static final ProtocolSession.AttachmentKey<String> RBL_DETAIL_MAIL_ATTRIBUTE_NAME = ProtocolSession.AttachmentKey.of("org.apache.james.smtpserver.rbl.detail", String.class);
+    public static final ProtocolSession.AttachmentKey<String> RBL_DETAIL = ProtocolSession.AttachmentKey.of("org.apache.james.smtpserver.rbl.detail", String.class);
 
     /**
      * Set the whitelist array
@@ -109,96 +112,108 @@ public class DNSRBLHandler implements MailHook {
      * the sender will only be permitted to send e-mail to postmaster (RFC 2821) or
      * abuse (RFC 2142), unless authenticated.
      */
-    public void checkDNSRBL(SMTPSession session, String ipAddress) {
-        
-        /*
-         * don't check against rbllists if the client is allowed to relay..
-         * This whould make no sense.
-         */
-        if (session.isRelayingAllowed()) {
-            LOGGER.info("Ipaddress {} is allowed to relay. Don't check it", session.getRemoteAddress().getAddress());
+    protected void checkDNSRBL(SMTPSession session, String ipAddress) {
+
+        if (whitelist == null && blacklist == null) {
+            // no whitelist/blacklist configured
             return;
         }
-        
-        if (whitelist != null || blacklist != null) {
-            StringBuilder sb = new StringBuilder();
-            StringTokenizer st = new StringTokenizer(ipAddress, " .", false);
-            while (st.hasMoreTokens()) {
-                sb.insert(0, st.nextToken() + ".");
-            }
-            String reversedOctets = sb.toString();
-
-            if (whitelist != null) {
-                String[] rblList = whitelist;
-                for (String rbl : rblList) {
-                    if (resolve(reversedOctets + rbl)) {
-                        LOGGER.info("Connection from {} whitelisted by {}", ipAddress, rbl);
-                        return;
-                    } else {
-                        LOGGER.debug("IpAddress {} not listed on {}", session.getRemoteAddress().getAddress(), rbl);
-                    }
-                }
-            }
-
-            if (blacklist != null) {
-                String[] rblList = blacklist;
-                for (String rbl : rblList) {
-                    if (resolve(reversedOctets + rbl)) {
-                        LOGGER.info("Connection from {} restricted by {} to SMTP AUTH/postmaster/abuse.", ipAddress, rbl);
 
-                        // we should try to retrieve details
-                        if (getDetail) {
-                            Collection<String> txt = resolveTXTRecords(reversedOctets + rbl);
+        StringBuilder sb = new StringBuilder();
+        StringTokenizer st = new StringTokenizer(ipAddress, " .", false);
+        while (st.hasMoreTokens()) {
+            sb.insert(0, st.nextToken() + ".");
+        }
+        String reversedOctets = sb.toString();
 
-                            // Check if we found a txt record
-                            if (!txt.isEmpty()) {
-                                // Set the detail
-                                String blocklistedDetail = txt.iterator().next().toString();
+        if (whitelist != null) {
+            String[] rblList = whitelist;
+            for (String rbl : rblList) {
+                if (resolve(reversedOctets + rbl)) {
+                    LOGGER.info("Connection from {} whitelisted by {}", ipAddress, rbl);
+                    return;
+                } else {
+                    LOGGER.debug("IpAddress {} not listed on {}",
+                        session.getRemoteAddress().getAddress(), rbl);
+                }
+            }
+        }
 
-                                session.setAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, blocklistedDetail, State.Connection);
-                            }
+        if (blacklist != null) {
+            String[] rblList = blacklist;
+            for (String rbl : rblList) {
+                if (resolve(reversedOctets + rbl)) {
+                    LOGGER.info(
+                        "Connection from {} restricted by {} to SMTP AUTH/postmaster/abuse.",
+                        ipAddress, rbl);
+
+                    // we should try to retrieve details
+                    if (getDetail) {
+                        Collection<String> txt = resolveTXTRecords(reversedOctets + rbl);
+
+                        // Check if we found a txt record
+                        if (!txt.isEmpty()) {
+                            // Set the detail
+                            String blocklistedDetail = txt.iterator().next().toString();
+
+                            session.setAttachment(RBL_DETAIL,
+                                blocklistedDetail, State.Connection);
                         }
-
-                        session.setAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, true, State.Connection);
-                        return;
-                    } else {
-                        // if it is unknown, it isn't blocked
-                        LOGGER.debug("unknown host exception thrown: {}", rbl);
                     }
 
+                    session.setAttachment(RBL_BLOCKLISTED, true,
+                        State.Connection);
+                    return;
+                } else {
+                    // if it is unknown, it isn't blocked
+                    LOGGER.debug("unknown host exception thrown: {}", rbl);
                 }
             }
         }
     }
-    
-    @Override
-    public HookResult doMail(SMTPSession session, MaybeSender sender) {
-        checkDNSRBL(session, session.getRemoteAddress().getAddress().getHostAddress());
-    
-        if (!session.isRelayingAllowed()) {
-            Optional<Boolean> blocklisted = session.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, State.Connection);
-            Optional<String> blocklistedDetail = session.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, State.Connection);
-
-            if (blocklisted.isPresent()) { // was found in the RBL
-                if (!blocklistedDetail.isPresent()) {
-                    return HookResult.builder()
-                        .hookReturnCode(HookReturnCode.deny())
-                        .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH)
-                            + " Rejected: unauthenticated e-mail from " + session.getRemoteAddress().getAddress()
-                            + " is restricted.  Contact the postmaster for details.")
-                        .build();
-                } else {
 
-                    return HookResult.builder()
-                        .hookReturnCode(HookReturnCode.deny())
-                        .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH) + " " + blocklistedDetail.get())
-                        .build();
-                }
-               
+    private boolean isBlocklisted(SMTPSession session) {
+        // only check IP addresses that are not authorized to relay
+        if (session.isRelayingAllowed()) {
+            LOGGER.info("Ipaddress {} is allowed to relay. Don't check it", session.getRemoteAddress().getAddress());
+            return false;
+        } else if (session.getAttachment(RBL_CHECK_PERFORMED, State.Connection).isEmpty()) {
+            // perform rbl check only once and store the result in connection state
+            checkDNSRBL(session, session.getRemoteAddress().getAddress().getHostAddress());
+            session.setAttachment(RBL_CHECK_PERFORMED, true, State.Connection);
+        }
+        return session.getAttachment(RBL_BLOCKLISTED, State.Connection).isPresent();
+    }
+
+    private HookResult doCheck(SMTPSession session) {
+        if (isBlocklisted(session)) {
+            String blocklistedDetail = session.getAttachment(RBL_DETAIL, State.Connection).orElse(null);
+            if (blocklistedDetail == null) {
+                return HookResult.builder()
+                    .hookReturnCode(HookReturnCode.deny())
+                    .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH)
+                        + " Rejected: unauthenticated e-mail from " + session.getRemoteAddress().getAddress()
+                        + " is restricted.  Contact the postmaster for details.")
+                    .build();
+            } else {
+                return HookResult.builder()
+                    .hookReturnCode(HookReturnCode.deny())
+                    .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH) + " " + blocklistedDetail)
+                    .build();
             }
         }
         return HookResult.DECLINED;
     }
+    
+    @Override
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
+        return doCheck(session);
+    }
+
+    @Override
+    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+        return doCheck(session);
+    }
 
     /**
      * Check if the given ipaddress is resolvable. 
diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
index cf6a2e341c..a4d57b0263 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
@@ -22,6 +22,7 @@ package org.apache.james.protocols.smtp.core.fastfail;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.ProtocolSession.State;
@@ -32,12 +33,13 @@ import org.apache.james.protocols.smtp.hook.HeloHook;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.protocols.smtp.hook.MailHook;
+import org.apache.james.protocols.smtp.hook.RcptHook;
 
 
 /**
  * This CommandHandler can be used to reject not resolvable EHLO/HELO
  */
-public class ResolvableEhloHeloHandler implements MailHook, HeloHook {
+public class ResolvableEhloHeloHandler implements HeloHook, MailHook, RcptHook {
 
     public static final ProtocolSession.AttachmentKey<Boolean> BAD_EHLO_HELO = ProtocolSession.AttachmentKey.of("BAD_EHLO_HELO", Boolean.class);
 
@@ -71,14 +73,8 @@ public class ResolvableEhloHeloHandler implements MailHook, HeloHook {
         
     }
 
-    protected boolean check(SMTPSession session) {
-        // not reject it
-        return session.getAttachment(BAD_EHLO_HELO, State.Transaction).isPresent();
-    }
-
-    @Override
-    public HookResult doMail(SMTPSession session, MaybeSender sender) {
-        if (check(session)) {
+    protected HookResult doCheck(SMTPSession session) {
+        if (session.getAttachment(BAD_EHLO_HELO, State.Transaction).isPresent()) {
             return HookResult.builder()
                 .hookReturnCode(HookReturnCode.deny())
                 .smtpReturnCode(SMTPRetCode.SYNTAX_ERROR_ARGUMENTS)
@@ -90,6 +86,16 @@ public class ResolvableEhloHeloHandler implements MailHook, HeloHook {
         }
     }
 
+    @Override
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
+        return doCheck(session);
+    }
+
+    @Override
+    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+        return doCheck(session);
+    }
+
     @Override
     public HookResult doHelo(SMTPSession session, String helo) {
         checkEhloHelo(session, helo);
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
index 69c5042839..62cf123a49 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
@@ -21,8 +21,8 @@
 package org.apache.james.protocols.smtp.core.fastfail;
 
 import static org.apache.james.protocols.api.ProtocolSession.State.Connection;
-import static org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler.RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME;
-import static org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler.RBL_DETAIL_MAIL_ATTRIBUTE_NAME;
+import static org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler.RBL_BLOCKLISTED;
+import static org.apache.james.protocols.smtp.core.fastfail.DNSRBLHandler.RBL_DETAIL;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.net.InetSocketAddress;
@@ -192,8 +192,8 @@ public class DNSRBLHandlerTest {
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, State.Connection)).describedAs("Details").contains("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, State.Connection)).describedAs("Details").contains("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Blocked").isPresent();
     }
 
     // ip is blacklisted and has txt details but we don'T want to retrieve the txt record
@@ -205,8 +205,8 @@ public class DNSRBLHandlerTest {
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(false);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, Connection)).withFailMessage("No details").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Blocked").isPresent();
     }
 
     // ip is allowed to relay
@@ -219,8 +219,8 @@ public class DNSRBLHandlerTest {
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, Connection)).withFailMessage("No details").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Not blocked").isEmpty();
     }
 
     // ip not on blacklist
@@ -234,8 +234,8 @@ public class DNSRBLHandlerTest {
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, Connection)).withFailMessage("No details").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Not blocked").isEmpty();
     }
 
     // ip on blacklist without txt details
@@ -249,8 +249,8 @@ public class DNSRBLHandlerTest {
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isEmpty();
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, Connection)).isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Blocked").isPresent();
     }
 
     // ip on whitelist
@@ -264,8 +264,8 @@ public class DNSRBLHandlerTest {
         rbl.setWhitelist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
         rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
-        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isEmpty();
-        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL, Connection)).isEmpty();
+        assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED, Connection)).withFailMessage("Not blocked").isEmpty();
     }
    
 
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
index 28a4edbe82..e5a93c0425 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
@@ -53,10 +53,10 @@ public class SenderAuthIdentifyVerificationHook extends AbstractSenderAuthIdenti
     }
 
     @Override
-    public HookResult doMail(SMTPSession session, MaybeSender sender) {
+    public HookResult doCheck(SMTPSession session, MaybeSender sender) {
         ExtendedSMTPSession nSession = (ExtendedSMTPSession) session;
         if (nSession.verifyIdentity()) {
-            return super.doMail(session, sender);
+            return super.doCheck(session, sender);
         } else {
             return HookResult.DECLINED;
         }
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 549cd37daa..01a880a147 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -803,7 +803,6 @@ public class SMTPServerTest {
 
         smtpProtocol.sendCommand(heloCommand, fictionalDomain);
         smtpProtocol.setSender(mail);
-        smtpProtocol.addRecipient(rcpt);
 
         // this should give a 501 code cause the helo/ehlo could not resolved
         assertThat(smtpProtocol.getReplyCode())
@@ -875,7 +874,6 @@ public class SMTPServerTest {
 
             smtpProtocol1.sendCommand("helo", helo1);
             smtpProtocol1.setSender(mail);
-            smtpProtocol1.addRecipient(rcpt);
 
             // this should give a 501 code cause the helo not equal reverse of
             // ip
@@ -1153,7 +1151,6 @@ public class SMTPServerTest {
 
             smtpProtocol1.sendCommand("ehlo", ehlo1);
             smtpProtocol1.setSender(mail);
-            smtpProtocol1.addRecipient(rcpt);
 
             // this should give a 501 code cause the ehlo not equals reverse of
             // ip
@@ -1295,7 +1292,6 @@ public class SMTPServerTest {
 
         smtpProtocol.setSender(sender);
 
-        smtpProtocol.addRecipient("mail@sample.com");
         assertThat(smtpProtocol.getReplyCode())
             .as("expected 530 error")
             .isEqualTo(530);
@@ -1325,6 +1321,8 @@ public class SMTPServerTest {
             .as("authenticated")
             .isEqualTo(235);
 
+        smtpProtocol.setSender(sender);
+
         smtpProtocol.sendCommand("AUTH PLAIN");
         assertThat(smtpProtocol.getReplyCode())
             .as("expected error: User has previously authenticated.")
@@ -1744,7 +1742,7 @@ public class SMTPServerTest {
         String userName = USER_LOCALHOST;
         String sender = USER_LOCALHOST;
 
-        smtpProtocol.setSender(sender);
+        //smtpProtocol.setSender(sender);
 
         usersRepository.addUser(Username.of(userName), "pwd");
 
@@ -1754,6 +1752,11 @@ public class SMTPServerTest {
             .as("authenticated")
             .isEqualTo(235);
 
+        smtpProtocol.setSender(sender);
+        assertThat(smtpProtocol.getReplyCode())
+            .as("authenticated.. not reject")
+            .isEqualTo(250);
+
         smtpProtocol.addRecipient("mail@sample.com");
         assertThat(smtpProtocol.getReplyCode())
             .as("authenticated.. not reject")
@@ -1786,8 +1789,6 @@ public class SMTPServerTest {
         String sender = USER_LOCALHOST;
 
         smtpProtocol.setSender(sender);
-
-        smtpProtocol.addRecipient("mail@sample.com");
         assertThat(smtpProtocol.getReplyCode())
             .as("reject")
             .isEqualTo(554);


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


[james-project] 02/08: JAMES-3820 change SenderAuthIdentifyVerificationHook from RcptHook to MailHook (sender verification happens on MAIL FROM)

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 195d98f9f426123da78d0c6d18215af76724d259
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Sun Sep 25 20:00:18 2022 +0200

    JAMES-3820 change SenderAuthIdentifyVerificationHook from RcptHook to MailHook (sender verification happens on MAIL FROM)
---
 ....java => AbstractSenderAuthIdentifyVerificationHook.java} |  6 +++---
 .../org/apache/james/smtpserver/CoreCmdHandlerLoader.java    |  2 +-
 ...RcptHook.java => SenderAuthIdentifyVerificationHook.java} | 12 ++++++------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
similarity index 95%
rename from protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
rename to protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
index 1d800bf806..6f89c73987 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationRcptHook.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java
@@ -27,14 +27,14 @@ 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.james.protocols.smtp.hook.MailHook;
 
 import com.google.common.base.Preconditions;
 
 /**
  * Handler which check if the authenticated user is the same as the one used as MAIL FROM
  */
-public abstract class AbstractSenderAuthIdentifyVerificationRcptHook implements RcptHook {  
+public abstract class AbstractSenderAuthIdentifyVerificationHook implements MailHook {
     private static final HookResult INVALID_AUTH = HookResult.builder()
         .hookReturnCode(HookReturnCode.deny())
         .smtpReturnCode(SMTPRetCode.BAD_SEQUENCE)
@@ -49,7 +49,7 @@ public abstract class AbstractSenderAuthIdentifyVerificationRcptHook implements
         .build();
     
     @Override
-    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
         if (session.getUsername() != null) {
             // Check if the sender address is the same as the user which was used to authenticate.
             // Its important to ignore case here to fix JAMES-837. This is save to do because if the handler is called
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
index ce2626c813..e31e1f43b5 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
@@ -69,7 +69,7 @@ public class CoreCmdHandlerLoader implements HandlersPackage {
             MailSizeEsmtpExtension.class,
             UsersRepositoryAuthHook.class,
             AuthRequiredToRelayRcptHook.class,
-            SenderAuthIdentifyVerificationRcptHook.class,
+            SenderAuthIdentifyVerificationHook.class,
             PostmasterAbuseRcptHook.class,
             ReceivedDataLineFilter.class,
             DataLineJamesMessageHookHandler.class,
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
similarity index 88%
rename from server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
rename to server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
index 2543fabd95..28a4edbe82 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java
@@ -27,7 +27,7 @@ import org.apache.james.core.Username;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.smtp.SMTPSession;
-import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
+import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationHook;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.rrt.api.CanSendFrom;
 import org.apache.james.user.api.UsersRepository;
@@ -38,25 +38,25 @@ import org.slf4j.LoggerFactory;
 /**
  * Handler which check if the authenticated user is incorrect
  */
-public class SenderAuthIdentifyVerificationRcptHook extends AbstractSenderAuthIdentifyVerificationRcptHook {
-    private static final Logger LOGGER = LoggerFactory.getLogger(SenderAuthIdentifyVerificationRcptHook.class);
+public class SenderAuthIdentifyVerificationHook extends AbstractSenderAuthIdentifyVerificationHook {
+    private static final Logger LOGGER = LoggerFactory.getLogger(SenderAuthIdentifyVerificationHook.class);
 
     private final DomainList domains;
     private final UsersRepository users;
     private final CanSendFrom canSendFrom;
 
     @Inject
-    public SenderAuthIdentifyVerificationRcptHook(DomainList domains, UsersRepository users, CanSendFrom canSendFrom) {
+    public SenderAuthIdentifyVerificationHook(DomainList domains, UsersRepository users, CanSendFrom canSendFrom) {
         this.domains = domains;
         this.users = users;
         this.canSendFrom = canSendFrom;
     }
 
     @Override
-    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
         ExtendedSMTPSession nSession = (ExtendedSMTPSession) session;
         if (nSession.verifyIdentity()) {
-            return super.doRcpt(session, sender, rcpt);
+            return super.doMail(session, sender);
         } else {
             return HookResult.DECLINED;
         }


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


[james-project] 03/08: JAMES-3820 change ResolvableEhloHeloHandler from RcptHook to MailHook (bad helo names should fail unless AUTH is successful)

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit fa812bae67e67e940c74b264aea5a33521dd1d5d
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Sun Sep 25 20:00:41 2022 +0200

    JAMES-3820 change ResolvableEhloHeloHandler from RcptHook to MailHook (bad helo names should fail unless AUTH is successful)
---
 .../core/fastfail/ResolvableEhloHeloHandler.java   |  7 +++----
 .../fastfail/ResolvableEhloHeloHandlerTest.java    | 23 +++++++++-------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
index 50f77c0fe8..cf6a2e341c 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandler.java
@@ -22,7 +22,6 @@ package org.apache.james.protocols.smtp.core.fastfail;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
-import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.ProtocolSession.State;
@@ -32,13 +31,13 @@ import org.apache.james.protocols.smtp.dsn.DSNStatus;
 import org.apache.james.protocols.smtp.hook.HeloHook;
 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.james.protocols.smtp.hook.MailHook;
 
 
 /**
  * This CommandHandler can be used to reject not resolvable EHLO/HELO
  */
-public class ResolvableEhloHeloHandler implements RcptHook, HeloHook {
+public class ResolvableEhloHeloHandler implements MailHook, HeloHook {
 
     public static final ProtocolSession.AttachmentKey<Boolean> BAD_EHLO_HELO = ProtocolSession.AttachmentKey.of("BAD_EHLO_HELO", Boolean.class);
 
@@ -78,7 +77,7 @@ public class ResolvableEhloHeloHandler implements RcptHook, HeloHook {
     }
 
     @Override
-    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
         if (check(session)) {
             return HookResult.builder()
                 .hookReturnCode(HookReturnCode.deny())
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
index 0486c1909f..c5d395c7ec 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/ResolvableEhloHeloHandlerTest.java
@@ -29,7 +29,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
 
-import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.core.Username;
 import org.apache.james.protocols.smtp.SMTPSession;
@@ -47,7 +46,7 @@ public class ResolvableEhloHeloHandlerTest {
 
 
     private SMTPSession setupMockSession(String argument,
-             final boolean relaying, final boolean authRequired, final Username username, MailAddress recipient) {
+             final boolean relaying, final boolean authRequired, final Username username) {
 
         return new BaseFakeSMTPSession() {
 
@@ -130,35 +129,32 @@ public class ResolvableEhloHeloHandlerTest {
     
     @Test
     void testRejectInvalidHelo() throws Exception {
-        MailAddress mailAddress = new MailAddress("test@localhost");
-        SMTPSession session = setupMockSession(INVALID_HOST, false, false, null, mailAddress);
+        SMTPSession session = setupMockSession(INVALID_HOST, false, false, null);
         ResolvableEhloHeloHandler handler = createHandler();
         
         handler.doHelo(session, INVALID_HOST);
         assertThat(session.getAttachment(BAD_EHLO_HELO, Transaction)).withFailMessage("Invalid HELO").isPresent();
 
-        HookReturnCode result = handler.doRcpt(session, MaybeSender.nullSender(), mailAddress).getResult();
+        HookReturnCode result = handler.doMail(session, MaybeSender.nullSender()).getResult();
         assertThat(HookReturnCode.deny()).describedAs("Reject").isEqualTo(result);
     }
     
     @Test
     void testNotRejectValidHelo() throws Exception {
-        MailAddress mailAddress = new MailAddress("test@localhost");
-        SMTPSession session = setupMockSession(VALID_HOST, false, false, null, mailAddress);
+        SMTPSession session = setupMockSession(VALID_HOST, false, false, null);
         ResolvableEhloHeloHandler handler = createHandler();
 
   
         handler.doHelo(session, VALID_HOST);
         assertThat(session.getAttachment(BAD_EHLO_HELO, Transaction)).withFailMessage("Valid HELO").isEmpty();
 
-        HookReturnCode result = handler.doRcpt(session, MaybeSender.nullSender(), mailAddress).getResult();
+        HookReturnCode result = handler.doMail(session, MaybeSender.nullSender()).getResult();
         assertThat(HookReturnCode.declined()).describedAs("Not reject").isEqualTo(result);
     }
    
     @Test
     void testRejectInvalidHeloAuthUser() throws Exception {
-        MailAddress mailAddress = new MailAddress("test@localhost");
-        SMTPSession session = setupMockSession(INVALID_HOST, false, true, Username.of("valid@user"), mailAddress);
+        SMTPSession session = setupMockSession(INVALID_HOST, false, true, Username.of("valid@user"));
         ResolvableEhloHeloHandler handler = createHandler();
 
 
@@ -166,15 +162,14 @@ public class ResolvableEhloHeloHandlerTest {
         assertThat(session.getAttachment(BAD_EHLO_HELO, Transaction)).withFailMessage("Value stored").isPresent();
 
 
-        HookReturnCode result = handler.doRcpt(session, MaybeSender.nullSender(), mailAddress).getResult();
+        HookReturnCode result = handler.doMail(session, MaybeSender.nullSender()).getResult();
         assertThat(HookReturnCode.deny()).describedAs("Reject").isEqualTo(result);
     }
     
    
     @Test
     void testRejectRelay() throws Exception {
-        MailAddress mailAddress = new MailAddress("test@localhost");
-        SMTPSession session = setupMockSession(INVALID_HOST, true, false, null, mailAddress);
+        SMTPSession session = setupMockSession(INVALID_HOST, true, false, null);
         ResolvableEhloHeloHandler handler = createHandler();
 
 
@@ -182,7 +177,7 @@ public class ResolvableEhloHeloHandlerTest {
         assertThat(session.getAttachment(BAD_EHLO_HELO, Transaction)).withFailMessage("Value stored").isPresent();
 
 
-        HookReturnCode result = handler.doRcpt(session, MaybeSender.nullSender(), mailAddress).getResult();
+        HookReturnCode result = handler.doMail(session, MaybeSender.nullSender()).getResult();
         assertThat(HookReturnCode.deny()).describedAs("Reject").isEqualTo(result);
     }
 }


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


[james-project] 08/08: JAMES-3820 fix mailet integration tests

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 923f967ada07cd54f6c3c86475905c63cd7cee24
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Wed Sep 28 22:28:31 2022 +0200

    JAMES-3820 fix mailet integration tests
---
 .../java/org/apache/james/smtp/SmtpIdentityVerificationTest.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
index 14e07faa4f..38c84f13ed 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpIdentityVerificationTest.java
@@ -100,7 +100,7 @@ class SmtpIdentityVerificationTest {
             messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
                 .authenticate(USER, PASSWORD)
                 .sendMessageNoSender(USER))
-            .isEqualTo(new SMTPSendingException(SmtpSendingStep.RCPT, "503 5.7.1 Incorrect Authentication for Specified Email Address\n"));
+            .isEqualTo(new SMTPSendingException(SmtpSendingStep.Sender, "503 5.7.1 Incorrect Authentication for Specified Email Address\n"));
     }
 
     @Test
@@ -124,7 +124,7 @@ class SmtpIdentityVerificationTest {
         assertThatThrownBy(() ->
             messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
                 .sendMessage(USER, USER))
-            .isEqualTo(new SMTPSendingException(SmtpSendingStep.RCPT, "530 5.7.1 Authentication Required\n"));
+            .isEqualTo(new SMTPSendingException(SmtpSendingStep.Sender, "530 5.7.1 Authentication Required\n"));
     }
 
     @Test
@@ -148,6 +148,6 @@ class SmtpIdentityVerificationTest {
             messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
                 .authenticate(ATTACKER, ATTACKER_PASSWORD)
                 .sendMessage(USER, USER))
-            .isEqualTo(new SMTPSendingException(SmtpSendingStep.RCPT, "503 5.7.1 Incorrect Authentication for Specified Email Address\n"));
+            .isEqualTo(new SMTPSendingException(SmtpSendingStep.Sender, "503 5.7.1 Incorrect Authentication for Specified Email Address\n"));
     }
 }


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


[james-project] 04/08: JAMES-3820 remove RcptHook from SPFHandler because handling SPF happens on MAIL FROM and not RCPT TO

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d9ec6995f149b97428e765f45b218b9dbee527c6
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Sun Sep 25 20:00:59 2022 +0200

    JAMES-3820 remove RcptHook from SPFHandler because handling SPF happens on MAIL FROM and not RCPT TO
---
 .../james/smtpserver/fastfail/SPFHandler.java      | 12 ++++------
 .../apache/james/smtpserver/SPFHandlerTest.java    | 28 ++++------------------
 2 files changed, 9 insertions(+), 31 deletions(-)

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 96191d2f57..0596321564 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
@@ -49,7 +49,7 @@ import org.apache.mailet.Mail;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, ProtocolHandler {
+public class SPFHandler implements JamesMessageHook, MailHook, ProtocolHandler {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(SPFHandler.class);
 
@@ -155,8 +155,10 @@ public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, Protoco
     }
 
     @Override
-    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
         if (!session.isRelayingAllowed()) {
+            doSPFCheck(session, sender);
+
             // Check if session is blocklisted
             if (session.getAttachment(SPF_BLOCKLISTED, State.Transaction).isPresent()) {
 
@@ -175,12 +177,6 @@ public class SPFHandler implements JamesMessageHook, MailHook, RcptHook, Protoco
         return HookResult.DECLINED;
     }
 
-    @Override
-    public HookResult doMail(SMTPSession session, MaybeSender sender) {
-        doSPFCheck(session, sender);
-        return HookResult.DECLINED;
-    }
-
     /**
      * Adapts service log.
      */
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
index 6cd0ecbe97..c949270966 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SPFHandlerTest.java
@@ -183,47 +183,39 @@ public class SPFHandlerTest {
     @Test
     public void testSPFpass() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf1.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf1.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
         spf.setDNSService(mockedDnsService);
 
         assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
     }
 
     @Test
     public void testSPFfail() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf2.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf2.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
         spf.setDNSService(mockedDnsService);
 
-        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("fail").isEqualTo(HookReturnCode.deny());
+        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("fail").isEqualTo(HookReturnCode.deny());
     }
 
     @Test
     public void testSPFsoftFail() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf3.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf3.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
         spf.setDNSService(mockedDnsService);
 
-        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("softfail declined").isEqualTo(HookReturnCode.declined());
+        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("softfail declined").isEqualTo(HookReturnCode.declined());
     }
 
     @Test
     public void testSPFsoftFailRejectEnabled() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf3.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
-
         setupMockedSMTPSession("192.168.100.1", "spf3.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
@@ -231,15 +223,12 @@ public class SPFHandlerTest {
 
         spf.setBlockSoftFail(true);
 
-        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("softfail reject").isEqualTo(HookReturnCode.deny());
+        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("softfail reject").isEqualTo(HookReturnCode.deny());
     }
 
     @Test
     public void testSPFpermError() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf4.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
-
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
@@ -247,14 +236,12 @@ public class SPFHandlerTest {
 
         spf.setBlockSoftFail(true);
 
-        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("permerror reject").isEqualTo(HookReturnCode.deny());
+        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("permerror reject").isEqualTo(HookReturnCode.deny());
     }
 
     @Test
     public void testSPFtempError() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf5.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
 
         setupMockedSMTPSession("192.168.100.1", "spf5.james.apache.org");
 
@@ -262,14 +249,12 @@ public class SPFHandlerTest {
 
         spf.setDNSService(mockedDnsService);
 
-        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("temperror denysoft").isEqualTo(HookReturnCode.denySoft());
+        assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("temperror denysoft").isEqualTo(HookReturnCode.denySoft());
     }
 
     @Test
     public void testSPFNoRecord() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf6.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
 
         setupMockedSMTPSession("192.168.100.1", "spf6.james.apache.org");
         SPFHandler spf = new SPFHandler();
@@ -277,13 +262,11 @@ public class SPFHandlerTest {
         spf.setDNSService(mockedDnsService);
 
         assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
     }
 
     @Test
     public void testSPFpermErrorRejectDisabled() throws Exception {
         MaybeSender sender = MaybeSender.of(new MailAddress("test@spf4.james.apache.org"));
-        MailAddress rcpt = new MailAddress("test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org");
         SPFHandler spf = new SPFHandler();
 
@@ -292,6 +275,5 @@ public class SPFHandlerTest {
         spf.setBlockPermError(false);
 
         assertThat(spf.doMail(mockedSMTPSession, sender).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
-        assertThat(spf.doRcpt(mockedSMTPSession, sender, rcpt).getResult()).describedAs("declined").isEqualTo(HookReturnCode.declined());
     }
 }


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


[james-project] 01/08: JAMES-3820 implement DNSRBLHandler as a MailHook instead of RcptHook to call it as soon as possible after SMTP authentication

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ff8fb4b6876262619bbedf36f7780142c1f03ef7
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Sun Sep 25 16:16:13 2022 +0200

    JAMES-3820 implement DNSRBLHandler as a MailHook instead of RcptHook to call it as soon as possible after SMTP authentication
---
 .../james/protocols/smtp/core/fastfail/DNSRBLHandler.java | 15 ++++++++++-----
 .../protocols/smtp/core/fastfail/DNSRBLHandlerTest.java   | 12 ++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
index 68d3181109..4a682fa9f8 100644
--- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
+++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandler.java
@@ -25,7 +25,6 @@ import java.util.Collections;
 import java.util.Optional;
 import java.util.StringTokenizer;
 
-import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.protocols.api.ProtocolSession;
 import org.apache.james.protocols.api.ProtocolSession.State;
@@ -33,14 +32,20 @@ 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.james.protocols.smtp.hook.MailHook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
-  * Connect handler for DNSRBL processing
+  * Handler for DNSRBL processing. The DNSRBL handler should be called as early as possible to
+  * prevent bad actors to drain James resources. One can argue It makes sense to implement the
+  * handler as a ConnectHandler, so the blocklist check is on connect. However, if authorized
+  * user connects (e.g. SMTP AUTH) it makes sense to check DNSRBL after AUTH stage.Therefore it
+  * makes sense to implement the DNSRBL handler at MAIL FROM stage. One caveat: According to
+  * <a href="https://datatracker.ietf.org/doc/html/rfc4954#section-5">RFC 4954</a> auth information
+  * can optionally provided as ESMTP AUTH parameter with a single value in the 'MAIL FROM:' command.
   */
-public class DNSRBLHandler implements RcptHook {
+public class DNSRBLHandler implements MailHook {
     private static final Logger LOGGER = LoggerFactory.getLogger(DNSRBLHandler.class);
 
     /**
@@ -167,7 +172,7 @@ public class DNSRBLHandler implements RcptHook {
     }
     
     @Override
-    public HookResult doRcpt(SMTPSession session, MaybeSender sender, MailAddress rcpt) {
+    public HookResult doMail(SMTPSession session, MaybeSender sender) {
         checkDNSRBL(session, session.getRemoteAddress().getAddress().getHostAddress());
     
         if (!session.isRelayingAllowed()) {
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
index 3f88d4f388..69c5042839 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/core/fastfail/DNSRBLHandlerTest.java
@@ -191,7 +191,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, State.Connection)).describedAs("Details").contains("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
     }
@@ -204,7 +204,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(false);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
     }
@@ -218,7 +218,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
     }
@@ -233,7 +233,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("No details").isEmpty();
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
     }
@@ -248,7 +248,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setBlacklist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isEmpty();
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Blocked").isPresent();
     }
@@ -263,7 +263,7 @@ public class DNSRBLHandlerTest {
 
         rbl.setWhitelist(new String[] { "bl.spamcop.net." });
         rbl.setGetDetail(true);
-        rbl.doRcpt(mockedSMTPSession, MaybeSender.nullSender(), new MailAddress("test@localhost"));
+        rbl.doMail(mockedSMTPSession, MaybeSender.nullSender());
         assertThat(mockedSMTPSession.getAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, Connection)).isEmpty();
         assertThat(mockedSMTPSession.getAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, Connection)).withFailMessage("Not blocked").isEmpty();
     }


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


[james-project] 06/08: JAMES-3820 fix missing renames of SenderAuthIdentifyVerificationHook

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 454370daba2271cf347228970c3ad3420cdf8e9d
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Mon Sep 26 09:01:29 2022 +0200

    JAMES-3820 fix missing renames of SenderAuthIdentifyVerificationHook
---
 examples/custom-smtp-command/README.md                                | 2 +-
 .../src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java   | 4 ++--
 src/homepage/howTo/custom-smtp-commands.html                          | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/custom-smtp-command/README.md b/examples/custom-smtp-command/README.md
index 6bdbe2e18f..648eee133e 100644
--- a/examples/custom-smtp-command/README.md
+++ b/examples/custom-smtp-command/README.md
@@ -67,7 +67,7 @@ public class MyCmdHandlerLoader implements HandlersPackage {
             MailSizeEsmtpExtension.class,
             UsersRepositoryAuthHook.class,
             AuthRequiredToRelayRcptHook.class,
-            SenderAuthIdentifyVerificationRcptHook.class,
+            SenderAuthIdentifyVerificationHook.class,
             PostmasterAbuseRcptHook.class,
             ReceivedDataLineFilter.class,
             DataLineJamesMessageHookHandler.class,
diff --git a/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java b/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
index d0ddcc7151..d5a4386b18 100644
--- a/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
+++ b/examples/custom-smtp-command/src/main/java/org/apache/james/examples/MyCmdHandlerLoader.java
@@ -49,7 +49,7 @@ import org.apache.james.smtpserver.JamesMailCmdHandler;
 import org.apache.james.smtpserver.JamesRcptCmdHandler;
 import org.apache.james.smtpserver.JamesWelcomeMessageHandler;
 import org.apache.james.smtpserver.SendMailHandler;
-import org.apache.james.smtpserver.SenderAuthIdentifyVerificationRcptHook;
+import org.apache.james.smtpserver.SenderAuthIdentifyVerificationHook;
 import org.apache.james.smtpserver.UsersRepositoryAuthHook;
 
 /**
@@ -78,7 +78,7 @@ public class MyCmdHandlerLoader implements HandlersPackage {
             MailSizeEsmtpExtension.class,
             UsersRepositoryAuthHook.class,
             AuthRequiredToRelayRcptHook.class,
-            SenderAuthIdentifyVerificationRcptHook.class,
+            SenderAuthIdentifyVerificationHook.class,
             PostmasterAbuseRcptHook.class,
             ReceivedDataLineFilter.class,
             DataLineJamesMessageHookHandler.class,
diff --git a/src/homepage/howTo/custom-smtp-commands.html b/src/homepage/howTo/custom-smtp-commands.html
index b557ce2ffd..7b9cd2a47d 100644
--- a/src/homepage/howTo/custom-smtp-commands.html
+++ b/src/homepage/howTo/custom-smtp-commands.html
@@ -100,7 +100,7 @@ public class MyCmdHandlerLoader implements HandlersPackage {
             MailSizeEsmtpExtension.class,
             UsersRepositoryAuthHook.class,
             AuthRequiredToRelayRcptHook.class,
-            SenderAuthIdentifyVerificationRcptHook.class,
+            SenderAuthIdentifyVerificationHook.class,
             PostmasterAbuseRcptHook.class,
             ReceivedDataLineFilter.class,
             DataLineJamesMessageHookHandler.class,


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


[james-project] 05/08: JAMES-3820 fix checkstyle warnings for SPFHandler

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 5d22d4d90792d02506b06735932d3afc5e49d3cf
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Mon Sep 26 08:11:21 2022 +0200

    JAMES-3820 fix checkstyle warnings for SPFHandler
---
 .../src/main/java/org/apache/james/smtpserver/fastfail/SPFHandler.java  | 2 --
 1 file changed, 2 deletions(-)

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 0596321564..5f9d4ec8d4 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
@@ -24,7 +24,6 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration2.Configuration;
 import org.apache.commons.configuration2.ex.ConfigurationException;
-import org.apache.james.core.MailAddress;
 import org.apache.james.core.MaybeSender;
 import org.apache.james.jspf.core.DNSService;
 import org.apache.james.jspf.core.exceptions.SPFErrorConstants;
@@ -40,7 +39,6 @@ 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.MailHook;
-import org.apache.james.protocols.smtp.hook.RcptHook;
 import org.apache.james.smtpserver.JamesMessageHook;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeName;


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