Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion announcements/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
}

// TODO move resources files into resources directory to avoid this overlap
Expand Down
48 changes: 30 additions & 18 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ List runtime = [
configurations {
// Exclude the bundled org.json library from com.fasterxml.jackson.datatype:jackson-datatype-json-org dependency
all*.exclude group: "org.apache.geronimo.bundles", module: "json"
// Avoid pulling in the Activation API because we don't want to conflict with one loaded from $CATALINA_HOME/lib
all*.exclude group: "jakarta.activation", module: "jakarta.activation-api"

// this configuration and its artifact are declared because the default outgoing variant for the api
// module (runtimeElements) does not include all the class files since the classes compiled from
Expand Down Expand Up @@ -98,11 +96,25 @@ dependencies {
runtimeOnly runtime

BuildUtils.addTomcatBuildDependencies(project, "implementation")
// the following two libraries are required for compilation but we don't want extra ones in the classpath, so we exclude
// them from external dependencies in favor of the versions in the tomcat directory (FIXME seems somewhat sketchy...)

// needed for compilation but Tomcat provides the implementation
api "jakarta.servlet:jakarta.servlet-api:${servletApiVersion}"
api "com.sun.mail:jakarta.mail:${javaMailVersion}"

// Angus Mail is an implementation of the Jakarta Mail API, which it pulls in as a dependency
BuildUtils.addExternalDependency(
project,
new ExternalDependency(
"org.eclipse.angus:angus-mail:${angusMailVersion}",
"Angus Mail",
"Eclipse Foundation",
"https://eclipse-ee4j.github.io/angus-mail/",
"Eclipse Public License 2.0",
"https://projects.eclipse.org/license/epl-2.0",
"Implementation of the Jakarta Mail API",
)
)

// Angus Activation is an implementation of the Jakarta Activation API, which it pulls in as a dependency
BuildUtils.addExternalDependency(
project,
new ExternalDependency(
Expand Down Expand Up @@ -281,7 +293,7 @@ dependencies {
"https://commons.apache.org/proper/commons-text/",
ExternalDependency.APACHE_2_LICENSE_NAME,
ExternalDependency.APACHE_2_LICENSE_URL,
"String algorithms",
"String algorithms"
)
)

Expand All @@ -294,21 +306,21 @@ dependencies {
"http://jakarta.apache.org/commons/validator/",
ExternalDependency.APACHE_2_LICENSE_NAME,
ExternalDependency.APACHE_2_LICENSE_URL,
"Data validation and error messages",
"Data validation and error messages"
)
)

BuildUtils.addExternalDependency(
project,
new ExternalDependency(
"org.apache.commons:commons-vfs2:${commonsVfs2Version}",
"Commons Virtual File System",
"Apache",
"https://commons.apache.org/proper/commons-vfs/",
ExternalDependency.APACHE_2_LICENSE_NAME,
ExternalDependency.APACHE_2_LICENSE_URL,
"Consistent API for accessing files of different types",
)
project,
new ExternalDependency(
"org.apache.commons:commons-vfs2:${commonsVfs2Version}",
"Commons Virtual File System",
"Apache",
"https://commons.apache.org/proper/commons-vfs/",
ExternalDependency.APACHE_2_LICENSE_NAME,
ExternalDependency.APACHE_2_LICENSE_URL,
"Consistent API for accessing files of different types"
)
)


Expand All @@ -322,7 +334,7 @@ dependencies {
"http://code.google.com/p/flying-saucer/",
ExternalDependency.LGPL_LICENSE_NAME,
ExternalDependency.LGPL_LICENSE_URL,
"XHTML/CSS rendering library",
"XHTML/CSS rendering library"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.labkey.api.admin.notification;

import jakarta.mail.MessagingException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
Expand All @@ -25,15 +26,11 @@
import org.labkey.api.util.MailHelper;
import org.labkey.api.view.ActionURL;

import jakarta.mail.MessagingException;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
* Service for adding/getting/removing user notifications attached to specific objects.
* User: cnathe
* Date: 9/14/2015
*/
public interface NotificationService
{
Expand Down
52 changes: 30 additions & 22 deletions api/src/org/labkey/api/util/MailHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMultipart;
import jakarta.servlet.ServletContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
Expand All @@ -48,16 +49,16 @@
import org.labkey.api.settings.StartupPropertyEntry;
import org.labkey.api.util.emailTemplate.EmailTemplate;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.StringTokenizer;

Expand Down Expand Up @@ -114,30 +115,37 @@ public void handle(Collection<StartupPropertyEntry> entries)
entries.forEach(entry -> properties.put("mail.smtp." + entry.getName(), entry.getValue()));
}
});
if (!properties.isEmpty())
{
session = Session.getInstance(properties);
}
else

/* now check if specified in tomcat config instead */
if (properties.isEmpty())
{
/* check if specified in tomcat config */
InitialContext ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
session = (Session) envCtx.lookup("mail/Session");
ServletContext context = ModuleLoader.getServletContext();
Enumeration<String> names = Objects.requireNonNull(context).getInitParameterNames();
while (names.hasMoreElements())
{
String name = names.nextElement();
if (name.startsWith("mail.smtp."))
properties.put(name, context.getInitParameter(name));
}
}

if ("true".equalsIgnoreCase(session.getProperty("mail.smtp.ssl.enable")) ||
"true".equalsIgnoreCase(session.getProperty("mail.smtp.starttls.enable")))
if (!properties.isEmpty())
{
String username = session.getProperty("mail.smtp.user");
String password = session.getProperty("mail.smtp.password");
session = Session.getInstance(session.getProperties(), new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username, password);
}
});
session = Session.getInstance(properties);

if ("true".equalsIgnoreCase(session.getProperty("mail.smtp.ssl.enable")) ||
"true".equalsIgnoreCase(session.getProperty("mail.smtp.starttls.enable")))
{
String username = session.getProperty("mail.smtp.user");
String password = session.getProperty("mail.smtp.password");
session = Session.getInstance(session.getProperties(), new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username, password);
}
});
}
}
}
catch (Exception e)
Expand Down
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ project.tasks.register("serverSideJS", ServerSideJS) {
project.tasks.named('processModuleResources').configure { dependsOn(project.tasks.serverSideJS) }

dependencies {
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
jspImplementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
jspImplementation "org.eclipse.angus:angus-mail:${angusMailVersion}"

BuildUtils.addExternalDependency(
project,
Expand Down
2 changes: 1 addition & 1 deletion issues/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

dependencies {
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "experiment"), depProjectConfig: "published", depExtension: "module")
BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "search"), depProjectConfig: "published", depExtension: "module")
}
2 changes: 1 addition & 1 deletion pipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

dependencies {
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
BuildUtils.addExternalDependency(
project,
new ExternalDependency(
Expand Down
2 changes: 1 addition & 1 deletion query/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configurations {
dependencies {
antlr "org.antlr:antlr:${antlrVersion}"
jspImplementation "org.olap4j:olap4j:${olap4jVersion}"
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
// we add this bridge jar because certain Mondrian classes require the log4j interface
BuildUtils.addExternalDependency(
project,
Expand Down
2 changes: 1 addition & 1 deletion study/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sourceSets {
}

dependencies {
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "assay"), depProjectConfig: "apiJarFile")
BuildUtils.addLabKeyDependency(project: project, config: "jspImplementation", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "assay"), depProjectConfig: "apiJarFile")

Expand Down