diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-12-05 17:16:36 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-12-05 17:16:36 +0100 |
commit | 0229a6a9e46062d0795e1086468b1d6e2d48c257 (patch) | |
tree | 3b93205a941141e013ebebc01c66a20db61b62c8 /plugins/sonar-email-notifications-plugin | |
parent | 8bcb717cb947410b24de20900f61b16a3c49de4f (diff) | |
download | sonarqube-0229a6a9e46062d0795e1086468b1d6e2d48c257.tar.gz sonarqube-0229a6a9e46062d0795e1086468b1d6e2d48c257.zip |
Fix some quality flaw
Diffstat (limited to 'plugins/sonar-email-notifications-plugin')
-rw-r--r-- | plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java index 757295d0818..73fe20265b4 100644 --- a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java +++ b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationChannel.java @@ -173,22 +173,7 @@ public class EmailNotificationChannel extends NotificationChannel { email.setMsg(emailMessage.getMessage()); // Send email.setHostName(configuration.getSmtpHost()); - if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "ssl")) { - email.setSSLOnConnect(true); - email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort())); - - // this port is not used except in EmailException message, that's why it's set with the same value than SSL port. - // It prevents from getting bad message. - email.setSmtpPort(configuration.getSmtpPort()); - } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "starttls")) { - email.setStartTLSEnabled(true); - email.setStartTLSRequired(true); - email.setSmtpPort(configuration.getSmtpPort()); - } else if (StringUtils.isBlank(configuration.getSecureConnection())) { - email.setSmtpPort(configuration.getSmtpPort()); - } else { - throw new SonarException("Unknown type of SMTP secure connection: " + configuration.getSecureConnection()); - } + configureSecureConnection(email); if (StringUtils.isNotBlank(configuration.getSmtpUsername()) || StringUtils.isNotBlank(configuration.getSmtpPassword())) { email.setAuthentication(configuration.getSmtpUsername(), configuration.getSmtpPassword()); } @@ -201,6 +186,25 @@ public class EmailNotificationChannel extends NotificationChannel { } } + private void configureSecureConnection(SimpleEmail email) { + if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "ssl")) { + email.setSSLOnConnect(true); + email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort())); + + // this port is not used except in EmailException message, that's why it's set with the same value than SSL port. + // It prevents from getting bad message. + email.setSmtpPort(configuration.getSmtpPort()); + } else if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "starttls")) { + email.setStartTLSEnabled(true); + email.setStartTLSRequired(true); + email.setSmtpPort(configuration.getSmtpPort()); + } else if (StringUtils.isBlank(configuration.getSecureConnection())) { + email.setSmtpPort(configuration.getSmtpPort()); + } else { + throw new SonarException("Unknown type of SMTP secure connection: " + configuration.getSecureConnection()); + } + } + /** * Send test email. This method called from Ruby. * |