ACS-9199 Bump subethasmtp version to 7.1.3 (#3207)

* ACS-9199 Bump subethasmtp to 7.1.3

* ACS-9199 Bump subethasmtp to 7.1.3

* ACS-9199 Use org.eclipse.angus

* ACS-9199 Update notice.txt

* ACS-9199 Remove provided scope for jakarta.mail:mail-api

* ACS-9199 Fix ags

* ACS-9199 Remove verbose
This commit is contained in:
Damian Ujma
2025-02-19 15:42:14 +01:00
committed by GitHub
parent 85c0d7896e
commit 1adddb0f7f
8 changed files with 2069 additions and 2108 deletions

View File

@@ -1377,7 +1377,7 @@
"filename": "repository/src/test/java/org/alfresco/repo/imap/ImapMessageTest.java",
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
"is_verified": false,
"line_number": 118,
"line_number": 116,
"is_secret": false
}
],
@@ -1868,5 +1868,5 @@
}
]
},
"generated_at": "2025-02-11T13:28:51Z"
"generated_at": "2025-02-18T15:50:35Z"
}

View File

@@ -63,10 +63,6 @@
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
</dependency>
<dependency>
<groupId>org.alfresco.surf</groupId>
<artifactId>spring-webscripts</artifactId>

View File

@@ -180,13 +180,13 @@ Lightbox JS http://lokeshdhakar.com/projects/lightbox/
=== Eclipse Public License 1.0 ===
Angus Mail Provider https://eclipse-ee4j.github.io/angus-mail/
AspectJ http://eclipse.org/aspectj/
Bliki http://code.google.com/p/gwtwiki/
JUnit http://junit.org/
TrueLicense http://truelicense.java.net/
truezip http://truezip.java.net/
=== ICU License ===
icu4j http://icu-project.org/

View File

@@ -57,8 +57,8 @@
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-mail</artifactId>
</dependency>
<dependency>

10
pom.xml
View File

@@ -97,6 +97,7 @@
<dependency.jdom2.version>2.0.6.1</dependency.jdom2.version>
<dependency.pooled-jms.version>3.1.6</dependency.pooled-jms.version>
<dependency.kxml2.version>2.3.0</dependency.kxml2.version>
<dependency.angus-mail.version>2.0.3</dependency.angus-mail.version>
<dependency.jakarta-ee-jaxb-api.version>4.0.2</dependency.jakarta-ee-jaxb-api.version>
<dependency.jakarta-ee-jaxb-impl.version>4.0.5</dependency.jakarta-ee-jaxb-impl.version>
@@ -105,7 +106,7 @@
<dependency.jakarta-annotation-api.version>3.0.0</dependency.jakarta-annotation-api.version>
<dependency.jakarta-transaction-api.version>2.0.1</dependency.jakarta-transaction-api.version>
<dependency.jakarta-jws-api.version>3.0.0</dependency.jakarta-jws-api.version>
<dependency.jakarta-ee-mail.version>2.0.1</dependency.jakarta-ee-mail.version>
<dependency.jakarta-ee-mail.version>2.1.3</dependency.jakarta-ee-mail.version>
<dependency.jakarta-ee-activation.version>2.0.1</dependency.jakarta-ee-activation.version>
<dependency.jakarta-ee-jms.version>3.1.0</dependency.jakarta-ee-jms.version>
<dependency.java-ee-activation.version>1.2.0</dependency.java-ee-activation.version>
@@ -219,15 +220,14 @@
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>${dependency.jakarta-ee-mail.version}</version>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-mail</artifactId>
<version>${dependency.angus-mail.version}</version>
</dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>${dependency.jakarta-ee-mail.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>

View File

@@ -56,8 +56,8 @@
<artifactId>jakarta.mail-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-mail</artifactId>
</dependency>
<dependency>
@@ -190,7 +190,7 @@
<dependency>
<groupId>com.github.davidmoten</groupId>
<artifactId>subethasmtp</artifactId>
<version>6.0.6</version>
<version>7.1.3</version>
<exclusions>
<!-- Duplicate classes from com.sun.mail:jakarta.mail -->
<exclusion>

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -25,6 +25,8 @@
*/
package org.alfresco.repo.imap;
import static org.alfresco.model.ContentModel.PROP_MODIFIED;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
@@ -37,7 +39,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import jakarta.mail.Address;
import jakarta.mail.Folder;
import jakarta.mail.Message;
@@ -51,6 +52,23 @@ import jakarta.mail.internet.MimeUtility;
import jakarta.transaction.UserTransaction;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.angus.mail.iap.ProtocolException;
import org.eclipse.angus.mail.iap.Response;
import org.eclipse.angus.mail.imap.IMAPFolder;
import org.eclipse.angus.mail.imap.protocol.BODY;
import org.eclipse.angus.mail.imap.protocol.FetchResponse;
import org.eclipse.angus.mail.imap.protocol.IMAPProtocol;
import org.eclipse.angus.mail.imap.protocol.IMAPResponse;
import org.eclipse.angus.mail.imap.protocol.RFC822DATA;
import org.eclipse.angus.mail.imap.protocol.UID;
import org.eclipse.angus.mail.util.ASCIIUtility;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ImapModel;
@@ -83,26 +101,6 @@ import org.alfresco.util.PropertyMap;
import org.alfresco.util.config.RepositoryFolderConfigBean;
import org.alfresco.util.testing.category.LuceneTests;
import org.alfresco.util.testing.category.RedundantTests;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.MimeMessageHelper;
import com.sun.mail.iap.ProtocolException;
import com.sun.mail.iap.Response;
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.protocol.BODY;
import com.sun.mail.imap.protocol.FetchResponse;
import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.IMAPResponse;
import com.sun.mail.imap.protocol.RFC822DATA;
import com.sun.mail.imap.protocol.UID;
import com.sun.mail.util.ASCIIUtility;
import static org.alfresco.model.ContentModel.PROP_MODIFIED;
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
public class ImapMessageTest extends TestCase
@@ -159,7 +157,6 @@ public class ImapMessageTest extends TestCase
namespaceService = serviceRegistry.getNamespaceService();
fileFolderService = serviceRegistry.getFileFolderService();
// start the transaction
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
@@ -200,7 +197,7 @@ public class ImapMessageTest extends TestCase
ImapServiceImpl imapServiceImpl = (ImapServiceImpl) imapCtx.getBean("imapService");
imapServer = (AlfrescoImapServer) imapCtx.getBean("imapServer");
if(!imapServer.isImapServerEnabled())
if (!imapServer.isImapServerEnabled())
{
imapServer.setImapServerEnabled(true);
imapServer.setHost(HOST);
@@ -220,7 +217,6 @@ public class ImapMessageTest extends TestCase
imapHome.setFolderPath(NamespaceService.CONTENT_MODEL_PREFIX + ":" + IMAP_FOLDER_NAME);
imapServiceImpl.setImapHome(imapHome);
// Starting IMAP
imapServiceImpl.startupInTxn(true);
@@ -228,10 +224,7 @@ public class ImapMessageTest extends TestCase
namespaceService, false);
testImapFolderNodeRef = nodeRefs.get(0);
/*
* Importing test folders: Test folder contains: "___-___folder_a" "___-___folder_a" contains: "___-___folder_a_a", "___-___file_a", "Message_485.eml" (this is IMAP
* Message) "___-___folder_a_a" contains: "____-____file_a_a"
*/
/* Importing test folders: Test folder contains: "___-___folder_a" "___-___folder_a" contains: "___-___folder_a_a", "___-___file_a", "Message_485.eml" (this is IMAP Message) "___-___folder_a_a" contains: "____-____file_a_a" */
importInternal("imap/imapservice_test_folder_a.acp", testImapFolderNodeRef);
txn.commit();
@@ -243,7 +236,7 @@ public class ImapMessageTest extends TestCase
// Get the store
this.store = session.getStore(PROTOCOL);
//this.store.connect(HOST, PORT, anotherUserName, anotherUserName);
// this.store.connect(HOST, PORT, anotherUserName, anotherUserName);
this.store.connect(imapServer.getHost(), imapServer.getPort(), anotherUserName, anotherUserName);
// Get folder
@@ -349,8 +342,7 @@ public class ImapMessageTest extends TestCase
fail("Should raise an IOException");
}
catch (IOException e)
{
}
{}
}
public void dontTestMessageCache() throws Exception
@@ -411,8 +403,7 @@ public class ImapMessageTest extends TestCase
{
Locale.setDefault(Locale.FRENCH);
String dateStr = "12-Jul-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
{
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol)
{
@@ -445,8 +436,7 @@ public class ImapMessageTest extends TestCase
Locale.setDefault(Locale.FRENCH);
String dateStr = "12-juil.-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
{
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol)
{
@@ -512,7 +502,7 @@ public class ImapMessageTest extends TestCase
// InternetAddress.toString(new Address[] {address}) - is used in the RFC822MetadataExtracter
// So, compare with that
assertFalse("Non ASCII characters in the address should be encoded", decodedAddress.equals(InternetAddress.toString(new Address[] {address})));
assertFalse("Non ASCII characters in the address should be encoded", decodedAddress.equals(InternetAddress.toString(new Address[]{address})));
MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
@@ -540,7 +530,7 @@ public class ImapMessageTest extends TestCase
// triggers a metadata extract to take place in a post commit method. Previously this would have been a
// synchronous process. This is no longer true as it may now take place in a T-Engine. So, we need to wait
// for the extract to take place. There does not
long end = System.currentTimeMillis()+10000;
long end = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() <= end && origModified.equals(getModified(nodeRef)))
{
Thread.currentThread().sleep(1000);
@@ -607,8 +597,6 @@ public class ImapMessageTest extends TestCase
lfolder.appendMessages(messages);
// The search is not implemented.
// SearchTerm term = new HeaderTerm("X-Alfresco-Unique", "test8bit");
// messages = folder.search(term);
@@ -619,14 +607,13 @@ public class ImapMessageTest extends TestCase
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
params[0] = new QueryParameterDefImpl(
ContentModel.PROP_TITLE,
serviceRegistry.getDictionaryService().getDataType(DataTypeDefinition.TEXT),
true,
subject);
ContentModel.PROP_TITLE,
serviceRegistry.getDictionaryService().getDataType(DataTypeDefinition.TEXT),
true,
subject);
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, messageXPath, params, namespaceService, true);
// does the message exist
assertEquals(1, nodeRefs.size());
@@ -646,8 +633,10 @@ public class ImapMessageTest extends TestCase
}
finally
{
if (messageFileInputStream1 != null) messageFileInputStream1.close();
if (messageFileInputStream2 != null) messageFileInputStream2.close();
if (messageFileInputStream1 != null)
messageFileInputStream1.close();
if (messageFileInputStream2 != null)
messageFileInputStream2.close();
}
// close connection
@@ -656,11 +645,9 @@ public class ImapMessageTest extends TestCase
}
private static RFC822DATA getRFC822Message(final IMAPFolder folder, final long uid) throws MessagingException
{
return (RFC822DATA) folder.doCommand(new IMAPFolder.ProtocolCommand()
{
return (RFC822DATA) folder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException
{
Response[] r = p.command("UID FETCH " + uid + " (RFC822)", null);
@@ -681,17 +668,20 @@ public class ImapMessageTest extends TestCase
/**
* Returns BODY object containing desired message fragment
*
* @param folder Folder containing the message
* @param uid Message UID
* @param from starting byte
* @param count bytes to read
* @param folder
* Folder containing the message
* @param uid
* Message UID
* @param from
* starting byte
* @param count
* bytes to read
* @return BODY containing desired message fragment
* @throws MessagingException
*/
private static BODY getMessageBodyPart(IMAPFolder folder, final Long uid, final Integer from, final Integer count) throws MessagingException
{
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand()
{
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException
{
Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[]<" + from + "." + count + ">)", null);
@@ -705,7 +695,7 @@ public class ImapMessageTest extends TestCase
}
FetchResponse fetchResponse = (FetchResponse) r[0];
BODY body = (BODY) fetchResponse.getItem(com.sun.mail.imap.protocol.BODY.class);
BODY body = (BODY) fetchResponse.getItem(BODY.class);
return body;
}
});
@@ -715,7 +705,8 @@ public class ImapMessageTest extends TestCase
/**
* Finds node by its path
*
* @param path String
* @param path
* String
* @return NodeRef
*/
private NodeRef findNode(String path)
@@ -727,15 +718,16 @@ public class ImapMessageTest extends TestCase
/**
* Returns the UID of the first message in folder
*
* @param folder Folder containing the message
* @param msn message sequence number
* @param folder
* Folder containing the message
* @param msn
* message sequence number
* @return UID of the first message
* @throws MessagingException
*/
private static Long getMessageUid(IMAPFolder folder, final int msn) throws MessagingException
{
return (Long) folder.doCommand(new IMAPFolder.ProtocolCommand()
{
return (Long) folder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException
{
String command = "FETCH " + msn + " (UID)";
@@ -749,38 +741,37 @@ public class ImapMessageTest extends TestCase
throw new ProtocolException("Unable to retrieve message UID");
}
for(int i = 0 ; i < r.length; i++)
for (int i = 0; i < r.length; i++)
{
if(r[i] instanceof FetchResponse)
if (r[i] instanceof FetchResponse)
{
FetchResponse fetchResponse = (FetchResponse) r[0];
UID uid = (UID) fetchResponse.getItem(UID.class);
logger.debug("SECNUM=" + uid.seqnum + ", UID="+uid.uid);
logger.debug("SECNUM=" + uid.seqnum + ", UID=" + uid.uid);
return uid.uid;
}
}
/**
* Uh-oh - this is where we would intermittently fall over with a class cast exception.
* The following code probes why we don't have a FetchResponse
*/
* Uh-oh - this is where we would intermittently fall over with a class cast exception. The following code probes why we don't have a FetchResponse
*/
StringBuffer sb = new StringBuffer();
sb.append("command="+command);
sb.append("command=" + command);
sb.append('\n');
sb.append("resp length=" + r.length);
sb.append('\n');
for(int i = 0 ; i < r.length; i++)
for (int i = 0; i < r.length; i++)
{
logger.error(r[i]);
sb.append("class=" + r[i].getClass().getName());
IMAPResponse unexpected = (IMAPResponse)r[i];
IMAPResponse unexpected = (IMAPResponse) r[i];
sb.append("key=" + unexpected.getKey());
sb.append("number=" + unexpected.getNumber());
sb.append("rest=" + unexpected.getRest());
sb.append("r[" + i + "]=" + r[i] + '\n');
}
throw new ProtocolException("getMessageUid: "+ sb.toString());
throw new ProtocolException("getMessageUid: " + sb.toString());
}
});
}
@@ -788,8 +779,10 @@ public class ImapMessageTest extends TestCase
/**
* Returns size of the message
*
* @param folder Folder containing the message
* @param uid Message UID
* @param folder
* Folder containing the message
* @param uid
* Message UID
* @return Returns size of the message
* @throws MessagingException
*/
@@ -801,15 +794,16 @@ public class ImapMessageTest extends TestCase
/**
* Returns a full message body
*
* @param folder Folder containing the message
* @param uid Message UID
* @param folder
* Folder containing the message
* @param uid
* Message UID
* @return Returns size of the message
* @throws MessagingException
*/
private static BODY getMessageBody(IMAPFolder folder, final Long uid) throws MessagingException
{
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand()
{
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException
{
Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[])", null);
@@ -831,7 +825,8 @@ public class ImapMessageTest extends TestCase
/**
* Simple util for logging response
*
* @param r response
* @param r
* response
*/
private static void logResponse(Response[] r)
{