From a86e2d2e0e106fa62d94284355e1b67551175bf4 Mon Sep 17 00:00:00 2001 From: markiewb Date: Thu, 23 Oct 2025 21:37:46 +0200 Subject: [PATCH 1/4] #485 Provide an option to disable the quotes for the filename at the content-disposition header --- Server/src/config/partnerships.xml | 5 ++++ .../java/org/openas2/partner/Partnership.java | 1 + .../receiver/MessageBuilderModule.java | 23 ++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Server/src/config/partnerships.xml b/Server/src/config/partnerships.xml index 8071264d..82af7e7b 100644 --- a/Server/src/config/partnerships.xml +++ b/Server/src/config/partnerships.xml @@ -67,6 +67,11 @@ --> + diff --git a/Server/src/main/java/org/openas2/partner/Partnership.java b/Server/src/main/java/org/openas2/partner/Partnership.java index a91b752d..069874d0 100644 --- a/Server/src/main/java/org/openas2/partner/Partnership.java +++ b/Server/src/main/java/org/openas2/partner/Partnership.java @@ -69,6 +69,7 @@ public class Partnership implements Serializable { public static final String PA_SPLIT_FILE_CONTAINS_HEADER_ROW = "split_file_contains_header_row"; public static final String PA_SPLIT_FILE_NAME_PREFIX = "split_file_name_prefix"; public static final String PA_RESEND_ON_SSL_EXCEPTION = "resend_on_ssl_exception"; + public static final String PA_QUOTE_SEND_FILE_NAME = "quote_send_file_name"; // Allow disabling the quoting of the filename in header when send_filename=true (at poller-level) is enabled // A hopefully temporary key to maintain backwards compatibility public static final String USE_NEW_CERTIFICATE_LOOKUP_MODE = "use_new_certificate_lookup_mode"; diff --git a/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java b/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java index 47034ed2..1ad75be8 100644 --- a/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java +++ b/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java @@ -55,7 +55,9 @@ public abstract class MessageBuilderModule extends BaseReceiverModule { public static final String PARAM_DEFAULTS = "defaults"; public static final String PARAM_MIMETYPE = "mimetype"; public static final String PARAM_RESEND_MAX_RETRIES = "resend_max_retries"; - + // Note: When this option is enabled, you can also configure its quoting using "quote_send_file_name" at partnership-level + public static final String PARAM_SEND_FILENAME = "sendfilename"; + private Logger logger = LoggerFactory.getLogger(MessageBuilderModule.class); public void init(Session session, Map options) throws OpenAS2Exception { @@ -403,9 +405,24 @@ private void setAdditionalMetaData(Message msg, MimeBodyPart mimeBodyPart) throw try { // add below statement will tell the receiver to save the filename // as the one sent by sender. 2007-06-01 - String sendFileName = getParameter("sendfilename", false); + String sendFileName = getParameter(PARAM_SEND_FILENAME, false); if (sendFileName != null && sendFileName.equals("true")) { - String contentDisposition = "Attachment; filename=\"" + msg.getAttribute(FileAttribute.MA_FILENAME) + "\""; + // Allow configuration of the quoting at partnership-level + String quoteFileName = msg.getPartnership().getAttribute(Partnership.PA_QUOTE_SEND_FILE_NAME); + + String quoteFileNameSign; + if (quoteFileName == null) { + // For backward compatibility - default + quoteFileNameSign = "\""; + } else if ("true".equals(quoteFileName)) { + // Explicitly enabled (same as the default) + quoteFileNameSign = "\""; + } else { + // Explicitly disabled + quoteFileNameSign = ""; + } + + String contentDisposition = String.format("Attachment; filename=%s%s%s", quoteFileNameSign, msg.getAttribute(FileAttribute.MA_FILENAME), quoteFileNameSign); mimeBodyPart.setHeader("Content-Disposition", contentDisposition); msg.setContentDisposition(contentDisposition); } From bc8e9d1f81eacaae4cfc5056385aa75a165bfa02 Mon Sep 17 00:00:00 2001 From: markiewb Date: Thu, 23 Oct 2025 21:38:45 +0200 Subject: [PATCH 2/4] #485 Prepare release notes (you may discard this commit) --- README.md | 6 +++--- RELEASE-NOTES.md | 38 ++++++++++++++++++++++++++++++-------- changes.txt | 27 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 59bd47c8..76441116 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ More detailed information is available in the DeveloperGuide.odt in the docs fol The following commands can be used in the build process. Updating Maven to a different version: -`./mvnw wrapper:wrapper -Dmaven=3.9.9 +`./mvnw wrapper:wrapper -Dmaven=3.9.9` Checking dependency tree: `./mvnw dependency:tree` @@ -92,7 +92,7 @@ $ docker build -t openas2:latest . ``` Run the OpenAS2 server, with its network set to "host", so that the WebUI can access the server. -NOTE: Some users have reported that using --net=host does not work for them and removing it solves the problem.. +NOTE: Some users have reported that using --net=host does not work for them and removing it solves the problem. ```console $ docker run -it --rm --net=host -p 4080:10080 -p 4081:10081 -p 8443:8080 -v ${PWD}/config:/opt/openas2/config -v ${PWD}/data:/opt/openas2/data openas2:latest @@ -145,7 +145,7 @@ $ docker compose logs openas2_webui ## Dynamically configure your container using environment variables -Here is a short explaination how to override properties in the container's `config.xml` file using environment variables. +Here is a short explanation how to override properties in the container's `config.xml` file using environment variables. **Prerequisites:** diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 8d2101cf..717cef7a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,23 +1,45 @@ # OpenAS2 Server -# Version 4.7.1 +# Version 4.7.2 # RELEASE NOTES ----- -The OpenAS2 project is pleased to announce the release of OpenAS2 4.7.1 +The OpenAS2 project is pleased to announce the release of OpenAS2 4.7.2 -The release download file is: OpenAS2Server-4.7.1.zip +The release download file is: OpenAS2Server-4.7.2.zip The zip file contains a PDF document (OpenAS2HowTo.pdf) providing information on installing and using the application. ## NOTE: Testing covers Java 11 to 21. ## Java 8 is NO LONGER SUPPORTED. -Version 4.7.1 - 2025-10-20 +Version 4.7.2 - 2025-10-23 -This is a minor bufix release. -1. Fix boolean return values from processMDN method causing wrong log message. -2. Fix logging WARN message that should have been a TRACE log. +This is a minor bugfix release. +1. Changes to partnership.xml -##Upgrade Notes + * New optional attribute "quote_send_file_name" for the partnership to specify if + the filename which is to be included in the headers should be quoted or not. + Some target AS2 servers are picky about the quotes. + + Any value other than "true" will be considered false - default: true (previous behaviour). +```` + + + + + + + + + +```` + +## Upgrade Notes See the openAS2HowTo appendix for the general process on upgrading OpenAS2. Below are some specific things to focus on depending on which version you are upgrading from. diff --git a/changes.txt b/changes.txt index d7a49139..1e8b74c9 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,32 @@ **IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading +Version 4.7.2 - 2025-10-23 + +This is a minor enhancement release. +1. Changes to partnership.xml + + * New optional attribute "quote_send_file_name" for the partnership to specify if + the filename which is to be included in the headers should be quoted or not. + Some target AS2 servers are picky about the quotes. + + Any value other than "true" will be considered false - default: true (previous behaviour). + + + + + + + + + + + Version 4.7.1 - 2025-10-20 This is a minor enhancement release. From 1c2699df9396bd110705cff6b7f9e4798662f85a Mon Sep 17 00:00:00 2001 From: markiewb Date: Mon, 27 Oct 2025 14:22:50 +0100 Subject: [PATCH 3/4] #485 Unittest for the changes --- .../receiver/MessageBuilderModule.java | 17 ++--- .../receiver/ContentDispositionTest.java | 73 +++++++++++++++++++ 2 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 Server/src/test/java/org/openas2/processor/receiver/ContentDispositionTest.java diff --git a/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java b/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java index 1ad75be8..fcee1cd5 100644 --- a/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java +++ b/Server/src/main/java/org/openas2/processor/receiver/MessageBuilderModule.java @@ -400,7 +400,8 @@ public String getMessageContentType(Message msg) throws OpenAS2Exception { return contentType; } - private void setAdditionalMetaData(Message msg, MimeBodyPart mimeBodyPart) throws OpenAS2Exception { + // @VisibleForTesting + protected void setAdditionalMetaData(Message msg, MimeBodyPart mimeBodyPart) throws OpenAS2Exception { try { // add below statement will tell the receiver to save the filename @@ -411,16 +412,14 @@ private void setAdditionalMetaData(Message msg, MimeBodyPart mimeBodyPart) throw String quoteFileName = msg.getPartnership().getAttribute(Partnership.PA_QUOTE_SEND_FILE_NAME); String quoteFileNameSign; - if (quoteFileName == null) { - // For backward compatibility - default - quoteFileNameSign = "\""; - } else if ("true".equals(quoteFileName)) { - // Explicitly enabled (same as the default) - quoteFileNameSign = "\""; - } else { + if ("false".equalsIgnoreCase(quoteFileName)){ // Explicitly disabled quoteFileNameSign = ""; - } + } else { + // For backward compatibility - default + // Or explicitly enabled + quoteFileNameSign = "\""; + } String contentDisposition = String.format("Attachment; filename=%s%s%s", quoteFileNameSign, msg.getAttribute(FileAttribute.MA_FILENAME), quoteFileNameSign); mimeBodyPart.setHeader("Content-Disposition", contentDisposition); diff --git a/Server/src/test/java/org/openas2/processor/receiver/ContentDispositionTest.java b/Server/src/test/java/org/openas2/processor/receiver/ContentDispositionTest.java new file mode 100644 index 00000000..b4ec48f3 --- /dev/null +++ b/Server/src/test/java/org/openas2/processor/receiver/ContentDispositionTest.java @@ -0,0 +1,73 @@ +package org.openas2.processor.receiver; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import jakarta.mail.internet.MimeBodyPart; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.TestMethodOrder; +import org.openas2.OpenAS2Exception; +import org.openas2.app.BaseServerSetup; +import org.openas2.message.FileAttribute; +import org.openas2.partner.Partnership; + +@TestInstance(Lifecycle.PER_CLASS) +@TestMethodOrder(MethodOrderer.MethodName.class) +public class ContentDispositionTest extends BaseServerSetup { + private DirectoryPollingModule poller; + + @BeforeAll + public void setUp() throws Exception { + super.createFileSystemResources(); + super.setup(); + this.poller = session.getPartnershipPoller(simpleTestMsg.getPartnership().getName()); + } + + @AfterAll + public void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void shouldUseSettingFromPartnership() throws Exception { + + // Set the partnership to disable quotes for the filename + assertThat(getContentDispositionForQuoteConfiguration("false"), is("Attachment; filename=filename.ext")); + assertThat(getContentDispositionForQuoteConfiguration("FALSE"), is("Attachment; filename=filename.ext")); + assertThat(getContentDispositionForQuoteConfiguration("False"), is("Attachment; filename=filename.ext")); + + // Set the partnership to enable quotes for the filename + assertThat(getContentDispositionForQuoteConfiguration("true"), is("Attachment; filename=\"filename.ext\"")); + assertThat(getContentDispositionForQuoteConfiguration("TRUE"), is("Attachment; filename=\"filename.ext\"")); + assertThat(getContentDispositionForQuoteConfiguration("tRuE"), is("Attachment; filename=\"filename.ext\"")); + } + + @Test + public void shouldUseDefaultSetting() throws Exception { + + //Check backward compatible configuration + assertThat(getContentDispositionForQuoteConfiguration(""), is("Attachment; filename=\"filename.ext\"")); + assertThat(getContentDispositionForQuoteConfiguration(null), is("Attachment; filename=\"filename.ext\"")); + assertThat(getContentDispositionForQuoteConfiguration("other"), is("Attachment; filename=\"filename.ext\"")); + } + + private String getContentDispositionForQuoteConfiguration(String valueOfQuoteSendFileName) throws OpenAS2Exception { + + if (valueOfQuoteSendFileName != null) { + simpleTestMsg.getPartnership().setAttribute(Partnership.PA_QUOTE_SEND_FILE_NAME, valueOfQuoteSendFileName); + } + + simpleTestMsg.setAttribute(FileAttribute.MA_FILENAME, "filename.ext"); + this.poller.setAdditionalMetaData(simpleTestMsg, new MimeBodyPart()); + + return simpleTestMsg.getContentDisposition(); + } + + +} From 6247562b1f9f271354aa7fdd725e906b6b5b20d2 Mon Sep 17 00:00:00 2001 From: markiewb Date: Mon, 27 Oct 2025 14:44:02 +0100 Subject: [PATCH 4/4] #485 Updated documentation and release notes --- RELEASE-NOTES.md | 43 +++++++++---------- Server/src/config/partnerships.xml | 4 +- .../java/org/openas2/partner/Partnership.java | 2 +- changes.txt | 41 +++++++++--------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 717cef7a..984a2cb0 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -16,28 +16,27 @@ This is a minor bugfix release. 1. Changes to partnership.xml - * New optional attribute "quote_send_file_name" for the partnership to specify if - the filename which is to be included in the headers should be quoted or not. - Some target AS2 servers are picky about the quotes. - - Any value other than "true" will be considered false - default: true (previous behaviour). -```` - - - - - - - - - -```` + * New optional attribute `quote_send_file_name` for the partnership to specify if + the filename which is to be included in header `Content-Disposition: Attachment; filename="filename.ext"` should be quoted or not. + Useful for target AS2 servers which are picky about the quotes. Requires `sendfilename="true"` to be set. + + Any value other than "false" will be considered true - default: true (previous behaviour). + ```` + + + + + + + + + + + + + + + ```` ## Upgrade Notes See the openAS2HowTo appendix for the general process on upgrading OpenAS2. diff --git a/Server/src/config/partnerships.xml b/Server/src/config/partnerships.xml index 82af7e7b..7050e21f 100644 --- a/Server/src/config/partnerships.xml +++ b/Server/src/config/partnerships.xml @@ -69,7 +69,9 @@ --> diff --git a/Server/src/main/java/org/openas2/partner/Partnership.java b/Server/src/main/java/org/openas2/partner/Partnership.java index 069874d0..7f0a97fd 100644 --- a/Server/src/main/java/org/openas2/partner/Partnership.java +++ b/Server/src/main/java/org/openas2/partner/Partnership.java @@ -69,7 +69,7 @@ public class Partnership implements Serializable { public static final String PA_SPLIT_FILE_CONTAINS_HEADER_ROW = "split_file_contains_header_row"; public static final String PA_SPLIT_FILE_NAME_PREFIX = "split_file_name_prefix"; public static final String PA_RESEND_ON_SSL_EXCEPTION = "resend_on_ssl_exception"; - public static final String PA_QUOTE_SEND_FILE_NAME = "quote_send_file_name"; // Allow disabling the quoting of the filename in header when send_filename=true (at poller-level) is enabled + public static final String PA_QUOTE_SEND_FILE_NAME = "quote_send_file_name"; // Allow disabling the quoting of the filename in header when sendfilename=true is set // A hopefully temporary key to maintain backwards compatibility public static final String USE_NEW_CERTIFICATE_LOOKUP_MODE = "use_new_certificate_lookup_mode"; diff --git a/changes.txt b/changes.txt index 1e8b74c9..1d373287 100644 --- a/changes.txt +++ b/changes.txt @@ -4,28 +4,27 @@ Version 4.7.2 - 2025-10-23 This is a minor enhancement release. 1. Changes to partnership.xml - - * New optional attribute "quote_send_file_name" for the partnership to specify if - the filename which is to be included in the headers should be quoted or not. - Some target AS2 servers are picky about the quotes. - Any value other than "true" will be considered false - default: true (previous behaviour). - - - - - - - - - - + * New optional attribute `quote_send_file_name` for the partnership to specify if + the filename which is to be included in header `Content-Disposition: Attachment; filename="filename.ext"` should be quoted or not. + Useful for target AS2 servers which are picky about the quotes. Requires `sendfilename="true"` to be set. + + Any value other than "false" will be considered true - default: true (previous behaviour). + + + + + + + + + + + + + + + Version 4.7.1 - 2025-10-20