Skip to content

Commit

Permalink
Migrated and upgraded some libraries to jakarta namespace (#285)
Browse files Browse the repository at this point in the history
* Migrated and upgraded some libraries to jakarta namespace

* Certs update

* Updated actions.yml

* Update actions.yml

Fix indentation

* Update actions.yml

* Update mvnw

Debug CI/CD run

* Update mvnw

Further debug - Remove SSL debug and leave the exec out

* Update mvnw

More test debug

* Update mvnw

* Update mvnw

* Use correct Jakarta package

* Update pom.xml

* Use correct Jakarta version

* Use BouncyCastle mail lib that uses Jakarta

* Update pom.xml

---------

Co-authored-by: pegeorgiev <pegeorgiev@axway.com>
Co-authored-by: Christopher Broderick <uhurusurfa@gmail.com>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 58ab9a3 commit 2570704
Show file tree
Hide file tree
Showing 37 changed files with 159 additions and 145 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ jobs:
$ENV:cert_file=gci -Path $ENV:JAVA_HOME -Filter cacerts -File -Recurse -ErrorAction SilentlyContinue | %{$_.FullName}
copy cacerts "$ENV:cert_file"
- name: Build with Maven
run: ./mvnw test --file pom.xml --log-file maven.log
run: |
./mvnw clean -e --debug --file pom.xml --log-file maven.log
./mvnw test -e --debug --file pom.xml --log-file maven.log
- name: Archive logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: execution-logs-${{ matrix.java_version }}-${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: openas2-server-osgi.jar,
Server/lib/commons-lang3-3.4.jar,
Server/lib/commons-logging-1.2.jar,
Server/lib/javax.mail.jar,
Server/lib/jakarta.mail.jar,
Server/lib/bcmail-jdk15on-154.jar,
Server/lib/bcpg-jdk15on-154.jar,
Server/lib/bcpkix-jdk15on-154.jar,
Expand Down
12 changes: 6 additions & 6 deletions Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</copy>
<echo message="OS Name: ${os.name}"/>
<exec executable="sh" osfamily="unix">
<arg value="-c"/>
<arg value="-c"/>
<arg line="'chmod uga+x ${package.assembly.dir}/bin/*.sh'"/>
</exec>
<!--Copy config directory to assembly directory -->
Expand Down Expand Up @@ -162,7 +162,7 @@
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk18on</artifactId>
<artifactId>bcjmail-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
Expand All @@ -186,7 +186,7 @@
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down Expand Up @@ -271,8 +271,8 @@
</dependency>
<!-- Removed JavaEE APIs removed from Java 9+ -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
Expand All @@ -284,7 +284,7 @@
</dependency>
<!--
<dependency>
<groupId>javax.activation</groupId>
<groupId>jakarta.activation</groupId>
<artifactId>activation</artifactId>
</dependency>
-->
Expand Down
4 changes: 2 additions & 2 deletions Server/src/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
userid="userID"
password="pWd"
response_format="xml"/>
<commandProcessor classname="org.openas2.cmd.processor.RestCommandProcessor"
<commandProcessor classname="org.openas2.cmd.processor.RestCommandProcessor"
enabled="$properties.restapi.command.processor.enabled$"
baseuri="$properties.restapi.command.processor.baseuri$"
ssl_protocol="TLS"
Expand All @@ -147,7 +147,7 @@
<!-- This directory polling module will parse the filename to get a sender, receiver and name of file to send to partner.
For instance, a file named MyComapny_OID-PartnerB_OID-OrderID-745634.edi would be sent from MyCompany to PartnerB.
The name of the file sent to the partner will be "OrderID-745634.edi" -->
<!--
<!--
<module classname="org.openas2.processor.receiver.AS2DirectoryPollingModule"
outboxdir="$properties.storageBaseDir$/toAny"
errordir="$properties.storageBaseDir$/toAny/error"
Expand Down
6 changes: 3 additions & 3 deletions Server/src/main/java/org/openas2/BaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.openas2.util.XMLUtil;
import org.w3c.dom.Node;

import javax.activation.CommandMap;
import javax.activation.MailcapCommandMap;
import jakarta.activation.CommandMap;
import jakarta.activation.MailcapCommandMap;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -172,7 +172,7 @@ public void destroyPartnershipPollers(String configSourceFilter) {
// something went wrong stopping it - report and keep going but make sure the key is still removed
LOGGER.error("Failed to stop a partnership poller for directory " + entry.getKey() + ": " + meta, e);
stoppedPollerKeys.add(entry.getKey());
}
}
}
for (String pollerKey : stoppedPollerKeys) {
// Remove the poller entry in the map now that we have killed the active poller
Expand Down
12 changes: 6 additions & 6 deletions Server/src/main/java/org/openas2/lib/helper/BCCryptoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
import org.openas2.util.DispositionType;
import org.openas2.util.Properties;

import javax.activation.CommandMap;
import javax.activation.MailcapCommandMap;
import javax.mail.MessagingException;
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import jakarta.activation.CommandMap;
import jakarta.activation.MailcapCommandMap;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.ContentType;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.openas2.message.AS2Message;
import org.openas2.message.Message;

import javax.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeBodyPart;
import java.io.InputStream;
import java.security.Key;
import java.security.KeyStore;
Expand Down
10 changes: 5 additions & 5 deletions Server/src/main/java/org/openas2/lib/util/MimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import org.openas2.Session;
import org.openas2.lib.util.javamail.ByteArrayDataSource;

import javax.activation.DataHandler;
import javax.mail.MessagingException;
import javax.mail.internet.InternetHeaders;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import jakarta.activation.DataHandler;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.InternetHeaders;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openas2.lib.util.javamail;

import javax.activation.DataSource;
import jakarta.activation.DataSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import org.openas2.lib.message.AS2Standards;

import javax.activation.ActivationDataFlavor;
import javax.activation.DataContentHandler;
import javax.activation.DataSource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import jakarta.activation.ActivationDataFlavor;
import jakarta.activation.DataContentHandler;
import jakarta.activation.DataSource;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
import java.awt.datatransfer.DataFlavor;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Expand All @@ -18,11 +18,11 @@

public class DispositionDataContentHandler implements DataContentHandler {
private static final ActivationDataFlavor ADF1;
private static final DataFlavor[] ADFs;
private static final ActivationDataFlavor[] ADFs;

static {
ADF1 = new ActivationDataFlavor(MimeBodyPart.class, AS2Standards.DISPOSITION_TYPE, "Disposition Notification");
ADFs = new DataFlavor[]{ADF1};
ADFs = new ActivationDataFlavor[]{ADF1};
}

public DispositionDataContentHandler() {
Expand Down Expand Up @@ -54,10 +54,15 @@ public Object getTransferData(DataFlavor df, DataSource ds) throws IOException {
return null;
}

public DataFlavor[] getTransferDataFlavors() {
public ActivationDataFlavor[] getTransferDataFlavors() {
return ADFs;
}

@Override
public Object getTransferData(ActivationDataFlavor activationDataFlavor, DataSource dataSource) throws IOException {
return null;
}

public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException {
if (obj instanceof MimeBodyPart) {
try {
Expand Down
26 changes: 13 additions & 13 deletions Server/src/main/java/org/openas2/logging/EmailLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import org.openas2.params.MessageParameters;
import org.openas2.params.ParameterParser;

import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import jakarta.mail.MessagingException;
import jakarta.mail.PasswordAuthentication;
import jakarta.mail.Transport;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -50,9 +50,9 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2
getParameter(PARAM_SMTPSERVER, true);

onlyActiveMsgTransferErrors = "true".equalsIgnoreCase(getParameter(PARAM_ONLY_ACTIVE_MSG_TRANSFER_ERRORS, "false"));
// copy system properties then allow override by javax.mail.properties.file
// copy system properties then allow override by jakarta.mail.properties.file
props.putAll(System.getProperties());
String filename = getParameter("javax.mail.properties.file", false);
String filename = getParameter("jakarta.mail.properties.file", false);
if (filename != null) {
ParameterParser parser = createParser();
filename = ParameterParser.parse(filename, parser);
Expand All @@ -61,10 +61,10 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2
in = new FileInputStream(filename);
props.load(in);
} catch (FileNotFoundException e) {
System.out.println("File not found for attribute javax.mail.properties.file: " + filename);
System.out.println("File not found for attribute jakarta.mail.properties.file: " + filename);
e.printStackTrace();
} catch (IOException e) {
System.out.println("File for attribute javax.mail.properties.file cannot be accessed: " + filename);
System.out.println("File for attribute jakarta.mail.properties.file cannot be accessed: " + filename);
e.printStackTrace();
} finally {
if (in != null) {
Expand Down Expand Up @@ -249,7 +249,7 @@ protected void sendMessage(String subject, String text) throws OpenAS2Exception
String userName = null;
String password = null;
boolean isAuth = false;
javax.mail.Session jmSession = null;
jakarta.mail.Session jmSession = null;
try {
isAuth = "true".equalsIgnoreCase(getParameter("smtpauth", "false"));
} catch (InvalidParameterException e) {
Expand All @@ -276,13 +276,13 @@ protected void sendMessage(String subject, String text) throws OpenAS2Exception
final String pwd = password;
if (isAuth) {
props.put("mail." + protocol + ".user", uid);
jmSession = javax.mail.Session.getDefaultInstance(props, new javax.mail.Authenticator() {
jmSession = jakarta.mail.Session.getDefaultInstance(props, new jakarta.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(uid, pwd);
}
});
} else {
jmSession = javax.mail.Session.getDefaultInstance(props);
jmSession = jakarta.mail.Session.getDefaultInstance(props);
}

if (isDebugOn) {
Expand All @@ -304,7 +304,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
m.setFrom(new InternetAddress(from));
}
m.setSender(new InternetAddress(getParameter(PARAM_FROM, true)));
m.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(getParameter(PARAM_TO, true)));
m.setRecipient(jakarta.mail.Message.RecipientType.TO, new InternetAddress(getParameter(PARAM_TO, true)));

m.setSentDate(new Date());
m.setSubject(subject);
Expand Down
24 changes: 12 additions & 12 deletions Server/src/main/java/org/openas2/mail/EmailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.openas2.params.MessageParameters;
import org.openas2.params.ParameterParser;

import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import jakarta.mail.MessagingException;
import jakarta.mail.PasswordAuthentication;
import jakarta.mail.Transport;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand All @@ -43,7 +43,7 @@ public class EmailSender extends BaseComponent {


public void init(Session session, Map<String, String> parameters) throws OpenAS2Exception {
// copy system properties then allow override by javax.mail.properties.file
// copy system properties then allow override by jakarta.mail.properties.file
props.putAll(System.getProperties());
String filename = "Emailer.Parameters.getJavaxMailPropFile";
if (filename != null) {
Expand All @@ -54,10 +54,10 @@ public void init(Session session, Map<String, String> parameters) throws OpenAS2
in = new FileInputStream(filename);
props.load(in);
} catch (FileNotFoundException e) {
System.out.println("File not found for attribute javax.mail.properties.file: " + filename);
System.out.println("File not found for attribute jakarta.mail.properties.file: " + filename);
e.printStackTrace();
} catch (IOException e) {
System.out.println("File for attribute javax.mail.properties.file cannot be accessed: " + filename);
System.out.println("File for attribute jakarta.mail.properties.file cannot be accessed: " + filename);
e.printStackTrace();
} finally {
if (in != null) {
Expand Down Expand Up @@ -152,7 +152,7 @@ protected void sendMessage(String subject, String text) throws OpenAS2Exception
String userName = null;
String password = null;
boolean isAuth = false;
javax.mail.Session jmSession = null;
jakarta.mail.Session jmSession = null;
try {
isAuth = "true".equalsIgnoreCase(getParameter("smtpauth", "false"));
} catch (InvalidParameterException e) {
Expand All @@ -179,13 +179,13 @@ protected void sendMessage(String subject, String text) throws OpenAS2Exception
final String pwd = password;
if (isAuth) {
props.put("mail." + protocol + ".user", uid);
jmSession = javax.mail.Session.getDefaultInstance(props, new javax.mail.Authenticator() {
jmSession = jakarta.mail.Session.getDefaultInstance(props, new jakarta.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(uid, pwd);
}
});
} else {
jmSession = javax.mail.Session.getDefaultInstance(props);
jmSession = jakarta.mail.Session.getDefaultInstance(props);
}

if (isDebugOn) {
Expand All @@ -207,7 +207,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
m.setFrom(new InternetAddress(from));
}
m.setSender(new InternetAddress(getParameter(PARAM_FROM, true)));
m.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(getParameter(PARAM_TO, true)));
m.setRecipient(jakarta.mail.Message.RecipientType.TO, new InternetAddress(getParameter(PARAM_TO, true)));

m.setSentDate(new Date());
m.setSubject(subject);
Expand Down
Loading

0 comments on commit 2570704

Please sign in to comment.