You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by mw...@apache.org on 2016/07/25 09:36:52 UTC
[15/47] incubator-eagle git commit: EAGLE-297 Email with
authentication Email with authentication can not be validated and sent out
EAGLE-297 Email with authentication
Email with authentication can not be validated and sent out
https://issues.apache.org/jira/browse/EAGLE-297
Author: Huizhi Lu, ihuizhi.lu@gmail.com
Reviewer: Qingwen, Zhao
Closes #187
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/8df78b18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/8df78b18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/8df78b18
Branch: refs/heads/master
Commit: 8df78b185eaba1c094ae7b713b4342a476e9b92a
Parents: 8dbbf71
Author: yonzhang <yo...@gmail.com>
Authored: Mon May 23 17:17:32 2016 -0700
Committer: yonzhang <yo...@gmail.com>
Committed: Mon May 23 17:17:32 2016 -0700
----------------------------------------------------------------------
.../eagle/common/email/EagleMailClient.java | 21 ++++++++++++--------
.../src/test/resources/application.conf | 9 +++++++--
2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8df78b18/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
index e647a2f..6edac0a 100755
--- a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
@@ -58,7 +58,7 @@ public class EagleMailClient {
private static final String AUTH_CONFIG = "mail.smtp.auth";
private static final String DEBUG_CONFIG = "mail.debug";
private static final String USER_CONFIG = "mail.user";
- private static final String PWD_CONFIG = "mail.pwd";
+ private static final String PASSWORD_CONFIG = "mail.password";
private VelocityEngine velocityEngine;
private Session session;
@@ -67,7 +67,7 @@ public class EagleMailClient {
public EagleMailClient() {
this(new ConcurrentMapConfiguration());
}
-
+
public EagleMailClient(AbstractConfiguration configuration) {
try {
ConcurrentMapConfiguration con = (ConcurrentMapConfiguration)configuration;
@@ -81,13 +81,13 @@ public class EagleMailClient {
if(Boolean.parseBoolean(config.getProperty(AUTH_CONFIG))){
session = Session.getDefaultInstance(config, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(config.getProperty(USER_CONFIG), config.getProperty(PWD_CONFIG));
+ return new PasswordAuthentication(config.getProperty(USER_CONFIG), config.getProperty(PASSWORD_CONFIG));
}
});
}
else session = Session.getDefaultInstance(config, new Authenticator() {});
- final String debugMode = config.getProperty(DEBUG_CONFIG, "false");
- final boolean debug = Boolean.parseBoolean(debugMode);
+ final String debugMode = config.getProperty(DEBUG_CONFIG, "false");
+ final boolean debug = Boolean.parseBoolean(debugMode);
session.setDebug(debug);
} catch (Exception e) {
LOG.error("Failed connect to smtp server",e);
@@ -111,7 +111,9 @@ public class EagleMailClient {
//msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(DEFAULT_BCC_ADDRESS));
msg.setContent(content, "text/html;charset=utf-8");
LOG.info(String.format("Going to send mail: from[%s], to[%s], cc[%s], title[%s]", from, to, cc, title));
+
Transport.send(msg);
+
return true;
} catch (AddressException e) {
LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
@@ -123,7 +125,7 @@ public class EagleMailClient {
}
private boolean _send(String from,String to,String cc,String title,String content,List<MimeBodyPart> attachments){
- MimeMessage mail = new MimeMessage(session);
+ MimeMessage mail = new MimeMessage(session);
try {
mail.setFrom(new InternetAddress(from));
mail.setSubject(title);
@@ -135,13 +137,13 @@ public class EagleMailClient {
mail.setRecipients(Message.RecipientType.CC,
InternetAddress.parse(cc));
}
-
+
//mail.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(DEFAULT_BCC_ADDRESS));
MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setContent(content,"text/html;charset=utf-8");
- Multipart multipart = new MimeMultipart();
+ Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mimeBodyPart);
for(MimeBodyPart attachment:attachments){
@@ -151,7 +153,9 @@ public class EagleMailClient {
mail.setContent(multipart);
// mail.setContent(content, "text/html;charset=utf-8");
LOG.info(String.format("Going to send mail: from[%s], to[%s], cc[%s], title[%s]", from, to, cc, title));
+
Transport.send(mail);
+
return true;
} catch (AddressException e) {
LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
@@ -173,6 +177,7 @@ public class EagleMailClient {
try {
t = velocityEngine.getTemplate(BASE_PATH + templatePath);
} catch (ResourceNotFoundException ex) {
+
}
if (t == null) {
try {
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/8df78b18/eagle-security/eagle-security-hbase-securitylog/src/test/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-hbase-securitylog/src/test/resources/application.conf b/eagle-security/eagle-security-hbase-securitylog/src/test/resources/application.conf
index 2fc60a5..0f11452 100644
--- a/eagle-security/eagle-security-hbase-securitylog/src/test/resources/application.conf
+++ b/eagle-security/eagle-security-hbase-securitylog/src/test/resources/application.conf
@@ -48,8 +48,13 @@
"site" : "sandbox",
"application": "hbaseSecurityLog",
"dataJoinPollIntervalSec" : 30,
- "mailHost" : "mailHost.com",
- "mailSmtpPort":"25",
+ "mailHost" : "smtp.office365.com",
+ "mailSmtpPort":"587",
+ "mailSmtpAuth" : "true",
+ "mailSmtpUser" : "username",
+ "mailSmtpPassword" : "password",
+ #"mailSmtpSslEnable" : "true",
+ "mailSmtpTlsEnable" : "true",
"mailDebug" : "true",
"eagleService": {
"host": "localhost",