summaryrefslogtreecommitdiffstats
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/gitblit/FederationClient.java8
-rw-r--r--src/main/java/com/gitblit/authority/GitblitAuthority.java3
-rw-r--r--src/main/java/com/gitblit/manager/GitblitManager.java10
-rw-r--r--src/main/java/com/gitblit/manager/INotificationManager.java20
-rw-r--r--src/main/java/com/gitblit/manager/NotificationManager.java32
-rw-r--r--src/main/java/com/gitblit/service/MailService.java27
6 files changed, 93 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/FederationClient.java b/src/main/java/com/gitblit/FederationClient.java
index c2757463..4f4b00bc 100644
--- a/src/main/java/com/gitblit/FederationClient.java
+++ b/src/main/java/com/gitblit/FederationClient.java
@@ -188,5 +188,13 @@ public class FederationClient {
@Override
public void sendHtmlMail(String subject, String message, String... toAddresses) {
}
+
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, Collection<String> toAddresses) {
+ }
+
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, String... toAddresses) {
+ }
}
}
diff --git a/src/main/java/com/gitblit/authority/GitblitAuthority.java b/src/main/java/com/gitblit/authority/GitblitAuthority.java
index 36c016de..51626e64 100644
--- a/src/main/java/com/gitblit/authority/GitblitAuthority.java
+++ b/src/main/java/com/gitblit/authority/GitblitAuthority.java
@@ -43,6 +43,7 @@ import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
@@ -853,7 +854,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
// send email
try {
if (mail.isReady()) {
- Message message = mail.createMessage(user.emailAddress);
+ Message message = mail.createMessage(Arrays.asList(user.emailAddress));
message.setSubject("Your Gitblit client certificate for " + metadata.serverHostname);
// body of email
diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java
index b3911814..75b258a5 100644
--- a/src/main/java/com/gitblit/manager/GitblitManager.java
+++ b/src/main/java/com/gitblit/manager/GitblitManager.java
@@ -593,6 +593,16 @@ public class GitblitManager implements IGitblit {
notificationManager.sendHtmlMail(subject, message, toAddresses);
}
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, Collection<String> toAddresses) {
+ notificationManager.sendHtmlMail(from, subject, message, toAddresses);
+ }
+
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, String... toAddresses) {
+ notificationManager.sendHtmlMail(from, subject, message, toAddresses);
+ }
+
/*
* SESSION MANAGER
*/
diff --git a/src/main/java/com/gitblit/manager/INotificationManager.java b/src/main/java/com/gitblit/manager/INotificationManager.java
index 29d8f549..ce5d3f71 100644
--- a/src/main/java/com/gitblit/manager/INotificationManager.java
+++ b/src/main/java/com/gitblit/manager/INotificationManager.java
@@ -63,4 +63,24 @@ public interface INotificationManager extends IManager {
*/
void sendHtmlMail(String subject, String message, String... toAddresses);
+ /**
+ * Notify users by email of something.
+ *
+ * @param from
+ * @param subject
+ * @param message
+ * @param toAddresses
+ */
+ void sendHtmlMail(String from, String subject, String message, Collection<String> toAddresses);
+
+ /**
+ * Notify users by email of something.
+ *
+ * @param from
+ * @param subject
+ * @param message
+ * @param toAddresses
+ */
+ void sendHtmlMail(String from, String subject, String message, String... toAddresses);
+
} \ No newline at end of file
diff --git a/src/main/java/com/gitblit/manager/NotificationManager.java b/src/main/java/com/gitblit/manager/NotificationManager.java
index a226d1a0..22ae5517 100644
--- a/src/main/java/com/gitblit/manager/NotificationManager.java
+++ b/src/main/java/com/gitblit/manager/NotificationManager.java
@@ -142,7 +142,20 @@ public class NotificationManager implements INotificationManager {
*/
@Override
public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) {
- this.sendHtmlMail(subject, message, toAddresses.toArray(new String[0]));
+ this.sendHtmlMail(null, subject, message, toAddresses.toArray(new String[0]));
+ }
+
+ /**
+ * Notify users by email of something.
+ *
+ * @param from
+ * @param subject
+ * @param message
+ * @param toAddresses
+ */
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, Collection<String> toAddresses) {
+ this.sendHtmlMail(from, subject, message, toAddresses.toArray(new String[0]));
}
/**
@@ -154,12 +167,25 @@ public class NotificationManager implements INotificationManager {
*/
@Override
public void sendHtmlMail(String subject, String message, String... toAddresses) {
+ this.sendHtmlMail(null, message, toAddresses);
+ }
+
+ /**
+ * Notify users by email of something.
+ *
+ * @param from
+ * @param subject
+ * @param message
+ * @param toAddresses
+ */
+ @Override
+ public void sendHtmlMail(String from, String subject, String message, String... toAddresses) {
if (toAddresses == null || toAddresses.length == 0) {
- logger.debug(MessageFormat.format("Dropping message {0} because there are no recipients", subject));
+ logger.debug("Dropping message {} because there are no recipients", subject);
return;
}
try {
- Message mail = mailExecutor.createMessage(toAddresses);
+ Message mail = mailExecutor.createMessage(from, toAddresses);
if (mail != null) {
mail.setSubject(subject);
diff --git a/src/main/java/com/gitblit/service/MailService.java b/src/main/java/com/gitblit/service/MailService.java
index 1d5e91f5..54b6c911 100644
--- a/src/main/java/com/gitblit/service/MailService.java
+++ b/src/main/java/com/gitblit/service/MailService.java
@@ -114,7 +114,6 @@ public class MailService implements Runnable {
return session != null;
}
-
/**
* Create a message.
*
@@ -122,7 +121,7 @@ public class MailService implements Runnable {
* @return a message
*/
public Message createMessage(String... toAddresses) {
- return createMessage(Arrays.asList(toAddresses));
+ return createMessage(null, Arrays.asList(toAddresses));
}
/**
@@ -132,13 +131,35 @@ public class MailService implements Runnable {
* @return a message
*/
public Message createMessage(List<String> toAddresses) {
+ return createMessage(null, toAddresses);
+ }
+
+ /**
+ * Create a message.
+ *
+ * @param fromDisplayName
+ * @param toAddresses
+ * @return a message
+ */
+ public Message createMessage(String fromDisplayName, String... toAddresses) {
+ return createMessage(fromDisplayName, Arrays.asList(toAddresses));
+ }
+
+ /**
+ * Create a message.
+ *
+ * @param fromDisplayName
+ * @param toAddresses
+ * @return a message
+ */
+ public Message createMessage(String fromDisplayName, List<String> toAddresses) {
MimeMessage message = new MimeMessage(session);
try {
String fromAddress = settings.getString(Keys.mail.fromAddress, null);
if (StringUtils.isEmpty(fromAddress)) {
fromAddress = "gitblit@gitblit.com";
}
- InternetAddress from = new InternetAddress(fromAddress, "Gitblit");
+ InternetAddress from = new InternetAddress(fromAddress, fromDisplayName == null ? "Gitblit" : fromDisplayName);
message.setFrom(from);
// determine unique set of addresses