Skip to content
Snippets Groups Projects
Commit 44d6308f authored by brinn's avatar brinn
Browse files

[LMS-1890] YeastX: cannot send confirmation email after unarchiving

fix: make the MailClient not request SMTP authentication if it obviously hasn't got valid credentials: deal with the typical Spring injection artefacts like an empty value "" or something like "${propval}" gracefully

SVN: 18746
parent 0aac67c8
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ import javax.mail.internet.MimeBodyPart; ...@@ -40,6 +40,7 @@ import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
...@@ -135,7 +136,7 @@ public final class MailClient extends Authenticator implements IMailClient ...@@ -135,7 +136,7 @@ public final class MailClient extends Authenticator implements IMailClient
{ {
properties.put(JavaMailProperties.MAIL_SMTP_HOST, smtpHost); properties.put(JavaMailProperties.MAIL_SMTP_HOST, smtpHost);
} }
if (smtpPassword != null && smtpUsername != null) if (StringUtils.isNotBlank(smtpPassword) && StringUtils.isNotBlank(smtpUsername))
{ {
properties.put(JavaMailProperties.MAIL_SMTP_AUTH, Boolean.TRUE.toString()); properties.put(JavaMailProperties.MAIL_SMTP_AUTH, Boolean.TRUE.toString());
} }
......
...@@ -52,6 +52,11 @@ public class MailClientParameters implements Serializable ...@@ -52,6 +52,11 @@ public class MailClientParameters implements Serializable
public final void setSmtpUser(String smtpUser) public final void setSmtpUser(String smtpUser)
{ {
// Check for Spring injection artefact
if (smtpUser != null && smtpUser.startsWith("${"))
{
this.smtpUser = null;
}
this.smtpUser = smtpUser; this.smtpUser = smtpUser;
} }
...@@ -62,6 +67,11 @@ public class MailClientParameters implements Serializable ...@@ -62,6 +67,11 @@ public class MailClientParameters implements Serializable
public final void setSmtpPassword(String smtpPassword) public final void setSmtpPassword(String smtpPassword)
{ {
// Check for Spring injection artefact
if (smtpPassword != null && smtpPassword.startsWith("${"))
{
this.smtpPassword = null;
}
this.smtpPassword = smtpPassword; this.smtpPassword = smtpPassword;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment