Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

108276: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud)
      108214: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.3)
         108154: Merged DEV to V4.2-BUG-FIX (4.2.5)
            107925 : MNT-14140 : MAIL command with a null reverse-path causes java.lang.NullPointerException
               - Allowed null reverse-path, added some tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@108408 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-07-15 17:12:38 +00:00
parent b96fa88669
commit 60451f01f8
5 changed files with 265 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public abstract class EmailServer extends AbstractLifecycleBean
{
private static final String ERR_SENDER_BLOCKED = "email.server.err.sender_blocked";
private static final String ERR_FROM_SYNTAX_INCORRECT = "email.server.err.from_syntax";
private boolean enabled;
private String domain;
@@ -56,6 +57,7 @@ public abstract class EmailServer extends AbstractLifecycleBean
private EmailService emailService;
private AuthenticationComponent authenticationComponent;
private String unknownUser;
protected EmailServer()
{
@@ -184,6 +186,20 @@ public abstract class EmailServer extends AbstractLifecycleBean
{
this.emailService = emailService;
}
/**
* Used only for check "isNullReversePatAllowed".
* @param unknownUser authority name
*/
public void setUnknownUser(String unknownUser)
{
this.unknownUser = unknownUser;
}
protected boolean isNullReversePatAllowed()
{
return isAuthenticate() || (unknownUser != null && !unknownUser.isEmpty());
}
/**
* Filter incoming message by its sender e-mail address.
@@ -193,6 +209,19 @@ public abstract class EmailServer extends AbstractLifecycleBean
*/
protected void filterSender(String sender)
{
if (sender == null)
{
if (isNullReversePatAllowed())
{
// allow null reverse-path: e.g.: an undeliverable mail response
return;
}
else
{
throw new EmailMessageException(ERR_FROM_SYNTAX_INCORRECT);
}
}
// Check if the sender is in the blocked list
for (String blockedSender : blockedSenders)
{