diff options
author | Shawn O. Pearce <sop@google.com> | 2010-07-14 17:04:44 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-07-14 17:08:33 -0700 |
commit | 340e2771bef4562df7c45c0ac5c1f4177679ad3b (patch) | |
tree | 4042edc91f5a670ce2bd8bfae235d92def6d4919 /gerrit-patch-commonsnet | |
parent | 56d8f8824aafae43db1af03cb0f0f7c4f72d6fb5 (diff) |
Move allowrcpt handling up to EmailSender to fix empty envelope
If nobody on the SMTP envelope was actually on the allowrcpt list,
we were still trying to push a message into the SMTP server but
it had no destinations. All SMTP servers refuse to accept the
'DATA' command in this case, as there was no 'RCPT TO' before it.
The breakage occurred when I stopped CC'ing the sender of emails
by default. This meant that I was no longer on the RCPT TO list
for a message in my test environment, but that was the only valid
address in the sendemail.allowrcpt configuration variable.
Change-Id: I2e1810d3e2a8e82aa96c93f2cfd9849f7bed6e8a
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'gerrit-patch-commonsnet')
-rw-r--r-- | gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java b/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java index e380df431e..4db7de631c 100644 --- a/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java +++ b/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java @@ -17,8 +17,6 @@ package org.apache.commons.net.smtp; import com.google.gerrit.util.ssl.BlindSSLSocketFactory; import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -26,20 +24,16 @@ import java.net.SocketException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Arrays; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import javax.net.ssl.SSLSocketFactory; public class AuthSMTPClient extends SMTPClient { - private static final Logger log = LoggerFactory.getLogger(AuthSMTPClient.class); private static final String UTF_8 = "UTF-8"; private String authTypes; - private Set<String> allowedRcptTo; public AuthSMTPClient(final String charset) { super(charset); @@ -68,45 +62,6 @@ public class AuthSMTPClient extends SMTPClient { } } - public void setAllowRcpt(final String[] allowed) { - if (allowed != null && allowed.length > 0) { - if (allowedRcptTo == null) { - allowedRcptTo = new HashSet<String>(); - } - for (final String addr : allowed) { - allowedRcptTo.add(addr); - } - } - } - - @Override - public int rcpt(final String forwardPath) throws IOException { - if (allowRcpt(forwardPath)) { - return super.rcpt(forwardPath); - } else { - log.warn("Not emailing " + forwardPath + " (prohibited by allowrcpt)"); - return SMTPReply.ACTION_OK; - } - } - - private boolean allowRcpt(String addr) { - if (allowedRcptTo == null) { - return true; - } - if (addr.startsWith("<") && addr.endsWith(">")) { - addr = addr.substring(1, addr.length() - 1); - } - if (allowedRcptTo.contains(addr)) { - return true; - } - final int at = addr.indexOf('@'); - if (at > 0) { - return allowedRcptTo.contains(addr.substring(at)) - || allowedRcptTo.contains(addr.substring(at + 1)); - } - return false; - } - @Override public String[] getReplyStrings() { return _replyLines.toArray(new String[_replyLines.size()]); |