Skip to content

Commit

Permalink
Migrate to jakarta namespace, upgrade to Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobe91 authored and beikov committed Jan 9, 2025
1 parent e297b66 commit bea721f
Show file tree
Hide file tree
Showing 85 changed files with 693 additions and 505 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: java
sudo: false
dist: trusty
dist: jammy
notifications:
slack: "blazebit:$SLACK_API_TOKEN"
cache:
Expand All @@ -21,4 +21,4 @@ env:
matrix:
fast_finish: true
include:
- jdk: oraclejdk8
- jdk: openjdk17
8 changes: 4 additions & 4 deletions channel/ses/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<artifactId>blaze-notify-channel-ses</artifactId>

<properties>
<version.aws.sdk>2.7.27</version.aws.sdk>
<version.aws.sdk>2.29.46</version.aws.sdk>
</properties>

<dependencies>
Expand All @@ -32,8 +32,8 @@
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -98,4 +98,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
import software.amazon.awssdk.services.ses.model.SendRawEmailResponse;
import software.amazon.awssdk.services.ses.model.SesException;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.mail.Address;
import jakarta.mail.MessagingException;
import jakarta.mail.Multipart;
import jakarta.mail.Session;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.internet.MimeUtility;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
Expand Down
33 changes: 18 additions & 15 deletions channel/smtp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
<artifactId>blaze-notify-channel-smtp</artifactId>

<properties>
<version.james>3.2.0</version.james>
<version.james>3.6.2</version.james>
<version.angus>2.0.3</version.angus>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>blaze-notify-core-api</artifactId>
Expand All @@ -31,10 +37,14 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
<groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId>
<version>${version.angus}</version>
</dependency>
<dependency>
<groupId>org.eclipse.angus</groupId>
<artifactId>smtp</artifactId>
<version>${version.angus}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -67,17 +77,10 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>james-server-memory-guice</artifactId>
<version>${version.james}</version>
<artifactId>james-server-memory-app</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-james-mailbox-lucene</artifactId>
<version>${version.james}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -164,4 +167,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,21 @@
import com.blazebit.notify.security.JSSETruststoreConfigurator;
import com.blazebit.notify.security.TruststoreProvider;
import com.blazebit.notify.security.TruststoreProviderFactory;
import com.sun.mail.smtp.SMTPMessage;
import com.sun.mail.smtp.SMTPSendFailedException;
import com.sun.mail.smtp.SMTPTransport;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.NoSuchProviderException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;

import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.mail.Address;
import jakarta.mail.MessagingException;
import jakarta.mail.Multipart;
import jakarta.mail.NoSuchProviderException;
import jakarta.mail.SendFailedException;
import jakarta.mail.Session;
import jakarta.mail.Transport;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.internet.MimeUtility;
import javax.net.ssl.SSLSocketFactory;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
Expand All @@ -58,6 +55,9 @@
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.angus.mail.smtp.SMTPMessage;
import org.eclipse.angus.mail.smtp.SMTPSendFailedException;
import org.eclipse.angus.mail.smtp.SMTPTransport;

/**
* A channel that sends messages via SMTP.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.blazebit.notify.email.message.EmailNotificationMessage;
import com.blazebit.notify.email.message.EmailNotificationRecipient;
import com.sun.mail.smtp.SMTPMessage;
import org.eclipse.angus.mail.smtp.SMTPMessage;

/**
* A filter that allows to control what messages to send.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import com.blazebit.notify.email.message.EmailNotificationMessage;
import com.blazebit.notify.email.message.EmailNotificationRecipient;
import com.sun.mail.smtp.SMTPMessage;

import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.angus.mail.smtp.SMTPMessage;

/**
* A regex pattern based SMTP filter for recipient email addresses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
*/
package com.blazebit.notify.channel.smtp;

import com.blazebit.notify.channel.smtp.james.module.MessageSearchIndexModule;
import com.blazebit.notify.channel.smtp.util.ImapMailClient;
import com.google.inject.Binder;
import com.google.inject.Module;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.apache.james.FakeSearchMailboxModule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.MemoryJamesConfiguration;
import org.apache.james.MemoryJamesServerMain;
import org.apache.james.modules.server.JMXServerModule;
import org.apache.james.server.core.configuration.Configuration;
import org.apache.james.user.memory.MemoryUsersRepository;
import org.apache.james.user.api.UsersRepositoryManagementMBean;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

import static org.apache.james.MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE;

public abstract class AbstractSmtpChannelIntegrationTest {
private final static String TEST_MAIL_SERVER_DOMAIN = "localhost";
protected final static String TEST_MAIL_USER = "blaze-notify-test@" + TEST_MAIL_SERVER_DOMAIN;
Expand Down Expand Up @@ -74,22 +76,32 @@ private static void setupSmtpChannel() {

private static void startMailServer() {
String tempDir = System.getProperty("java.io.tmpdir");
Configuration configuration = Configuration.builder().configurationFromClasspath().workingDirectory(tempDir).build();
final MemoryUsersRepository jamesUsersRepository = MemoryUsersRepository.withVirtualHosting();
jamesServer = GuiceJamesServer.forConfiguration(configuration).combineWith(
IN_MEMORY_SERVER_AGGREGATE_MODULE,
new JMXServerModule(),
new MessageSearchIndexModule()
).overrideWith(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(MemoryUsersRepository.class).toInstance(jamesUsersRepository);

}
});
MemoryJamesConfiguration configuration = MemoryJamesConfiguration.builder()
.configurationFromClasspath()
.workingDirectory(tempDir)
.build();
jamesServer = MemoryJamesServerMain.createServer(configuration)
.combineWith(new FakeSearchMailboxModule(), new JMXServerModule());
try {
jamesServer.start();
jamesUsersRepository.addUser(TEST_MAIL_USER, TEST_MAIL_PWD);
addUser(TEST_MAIL_USER, TEST_MAIL_PWD);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private static void addUser(String email, String password) {
try {
String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi";
String beanNameUser = "org.apache.james:type=component,name=usersrepository";

MBeanServerConnection server =
JMXConnectorFactory.connect(new JMXServiceURL(serverUrl)).getMBeanServerConnection();

UsersRepositoryManagementMBean userBean =
MBeanServerInvocationHandler.newProxyInstance(server, new ObjectName(beanNameUser),
UsersRepositoryManagementMBean.class, false);
userBean.addUser(email, password);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import com.blazebit.notify.email.message.EmailSubject;
import org.junit.Test;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMultipart;
import javax.mail.util.ByteArrayDataSource;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.util.ByteArrayDataSource;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.blazebit.notify.channel.smtp.util;

import javax.mail.Authenticator;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;
import jakarta.mail.Authenticator;
import jakarta.mail.Flags;
import jakarta.mail.Folder;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.Session;
import jakarta.mail.Store;
import java.util.Properties;

public class ImapMailClient extends Authenticator {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ============================================= Deleted Messages Vault Configuration ==================================
# Retention period for your deleted messages into the vault, after which they expire and can be potentially cleaned up
# Optional, default 1y
# retentionPeriod=1y
7 changes: 2 additions & 5 deletions channel/smtp/src/test/resources/dnsservice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
specific language governing permissions and limitations
under the License.
-->
<!-- Read https://james.apache.org/server/config-dnsservice.html for further details -->

<dnsservice>
<servers>
<server>8.8.8.8</server>
<server>62.210.16.6</server>
</servers>
<autodiscover>false</autodiscover>
<autodiscover>true</autodiscover>
<authoritative>false</authoritative>
<maxcachesize>50000</maxcachesize>
</dnsservice>
9 changes: 4 additions & 5 deletions channel/smtp/src/test/resources/domainlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
under the License.
-->

<!-- Read https://james.apache.org/server/config-domainlist.html for further details -->

<domainlist>
<domainnames>
<domainname>localhost</domainname>
</domainnames>
<autodetect>true</autodetect>
<autodetectIP>true</autodetectIP>
<autodetect>false</autodetect>
<autodetectIP>false</autodetectIP>
<defaultDomain>localhost</defaultDomain>
</domainlist>
3 changes: 3 additions & 0 deletions channel/smtp/src/test/resources/droplists.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuration file for DropLists

enabled=false
Loading

0 comments on commit bea721f

Please sign in to comment.