diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 3d9be7d9..03c8e20d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: [11, 17, 21] + java_version: [11, 17, 21, 24] os: [windows-latest, ubuntu-latest] steps: - name: Checkout diff --git a/.gitignore b/.gitignore index 8dad7d3e..3b4f66b7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ pom.xml.versionsBackup /Bundle/target/ /lib/ /Server/src/logs/ +/Server/src/test/resources/config/ **/.DS_Store **/.settings **/*.class -.metadata/* \ No newline at end of file +.metadata/* diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index c6feb8bb..cb28b0e3 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index eb919476..d58ddb0c 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,18 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip \ No newline at end of file +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/README.md b/README.md index 0c47278d..59bd47c8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ # As2Server The OpenAS2 application enables you to transmit and receive AS2 messages with EDI-X12, EDIFACT, XML, or binary payloads between trading partners. +The application supports Java 11 and up. ## Development @@ -12,6 +13,9 @@ More detailed information is available in the DeveloperGuide.odt in the docs fol ## Test, Build and Package The following commands can be used in the build process. +Updating Maven to a different version: +`./mvnw wrapper:wrapper -Dmaven=3.9.9 + Checking dependency tree: `./mvnw dependency:tree` @@ -38,7 +42,7 @@ To deploy the released artifacts requires user ID and password for Sonatype. See `./mvnw nexus-staging:release -Ddescription="Some release comment here"` ## Web UI for configuration -IMPORTANT: The WebUI will NOT work with Java 8 - you need Java 11 or newer +IMPORTANT: You need Java 11 or newer Follow the instructions in the WebUI/README.md file for configuring and using it. diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a36dcecd..6a56a991 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,20 +1,28 @@ # OpenAS2 Server -# Version 4.5.2 +# Version 4.6.0 # RELEASE NOTES ----- -The OpenAS2 project is pleased to announce the release of OpenAS2 4.5.2 +The OpenAS2 project is pleased to announce the release of OpenAS2 4.6.0 -The release download file is: OpenAS2Server-4.5.2.zip +The release download file is: OpenAS2Server-4.6.0.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.5.2 - 2025-06-12 +Version 4.6.0 - 2025-08-04 + +This is a testing enhancement release. + +1. Reworked the resource access class +2. changed tests to use the same config that is provided in the installer package +3. Optimised method to wait for files to appear on file system as part of end-to-end tests +4. Created script to generate test certificates keystore with updated certificates +5. Added maven phase to regenerate test certificates keystore prior to running tests +6. Updated Maven wrapper for project +7. Added Java 24 to test matrix -This is a bugfix release. -1. Fix database connection setup for healthcheck module. ##Upgrade Notes See the openAS2HowTo appendix for the general process on upgrading OpenAS2. @@ -24,7 +32,7 @@ This is a bugfix release. **You must review all notes for the relevant intermediate versions from your version to this release version.** ### Upgrading to 4.0 or newer from any older version: - 1. Ensure you implement all logging that you had configured for ealrier versions using the logback configuration or replace with another framework that works with SLF4J facade. See the OpenAS2HowTo.pdf logging section for more details. + 1. Ensure you implement all logging that you had configured for earlier versions using the logback configuration or replace with another framework that works with SLF4J facade. See the OpenAS2HowTo.pdf logging section for more details. 2. The property for email configuration in the config.xml changed: Change ALL occurrences of javax.mail.properties to jakarta.mail.properties in config.xml and the .properties file if you implemented it. 3. If using an external database for message state tracking, make sure that your configuration will work with the new Hikari JDBC pool that improves performance. See the OpenAS2HowTo.pdf message state tracking section for more details. diff --git a/Server/pom.xml b/Server/pom.xml index 8a294998..86febd97 100644 --- a/Server/pom.xml +++ b/Server/pom.xml @@ -7,7 +7,7 @@ net.sf.openas2 OpenAS2 - 4.5.2 + 4.6.0 ../pom.xml @@ -43,20 +43,54 @@ org.apache.maven.plugins maven-dependency-plugin + + + + properties + + + org.apache.maven.plugins maven-surefire-plugin - + logs - + + org.apache.maven.plugins maven-antrun-plugin + + test-resource-creation + + run + + generate-resources + + + + + + + + + + + + + + default-cli diff --git a/Server/src/bin/create_test_certificates.sh b/Server/src/bin/create_test_certificates.sh new file mode 100755 index 00000000..f22bd889 --- /dev/null +++ b/Server/src/bin/create_test_certificates.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +x=`basename $0` +relBinDir=`dirname $0` +binDir=`realpath $relBinDir` +srcBaseDir=`realpath $binDir/../..` +configDir=${srcBaseDir}/src/config + +cd $configDir +if [ "$?" != 0 ]; then + echo "****** Failed to find the "config" directory. See errors above to correct the problem." + exit 1 +fi +export IS_AUTOMATED_EXEC=1 +export KEYSTORE_PASSWORD=testas2 +echo "************" +echo "Deleting existing keystores..." +alias1=mycompany +alias2=partnera +alias3=partnerb +ks1=as2_certs.p12 +ks2=${alias2}_certs.p12 +ks3=${alias2}_certs.p12 +rm -f $ks1 $ks2 $ks3 +$binDir/gen_p12_key_par.sh ${ks1%.*} ${alias1} SHA256 'CN=as2.${alias1}.com, OU=QA, O=MyCompany, L=Cape Town, S=Western Cape, C=ZA' +if [ "$?" != 0 ]; then + echo "****** Failed to create as2_certs.p12 keystore. See errors above to correct the problem." + exit 1 +fi +$binDir/gen_p12_key_par.sh ${ks2%.*} ${alias2} SHA256 'CN=as2.${alias2}.com, OU=QA, O=PartnerA, L=New York, S=New York, C=US' +if [ "$?" != 0 ]; then + echo "****** Failed to create ${ks2} keystore. See errors above to correct the problem." + exit 1 +fi +$binDir/gen_p12_key_par.sh ${ks3%.*} ${alias3} SHA256 'CN=as2.${alias3}.com, OU=QA, O=PartnerB, L=London, S=London, C=US' +if [ "$?" != 0 ]; then + echo "****** Failed to create ${ks3} keystore. See errors above to correct the problem." + exit 1 +fi +$binDir/import_alias_from_keystore.sh $ks2 ${alias2} $ks1 ${alias2} +if [ "$?" != 0 ]; then + echo "****** Failed to import ${ks2} keystorei into main keystore. See errors above to correct the problem." + exit 1 +fi +$binDir/import_alias_from_keystore.sh $ks3 ${alias3} $ks1 ${alias3} +if [ "$?" != 0 ]; then + echo "****** Failed to import ${ks3} keystorei into main keystore. See errors above to correct the problem." + exit 1 +fi +rm -f ${alias1}* ${alias2}* ${alias3}* +exit 0 diff --git a/Server/src/bin/gen_p12_key_par.sh b/Server/src/bin/gen_p12_key_par.sh index aab6c19d..7c428214 100755 --- a/Server/src/bin/gen_p12_key_par.sh +++ b/Server/src/bin/gen_p12_key_par.sh @@ -3,6 +3,7 @@ x=`basename $0` if test $# -ne 4; then + echo "Invalid parameter list. Expected 4 got $#: $@" echo "Generate a certificate to a PKCS12 key store." echo "You must supply a target key store without the extension (extension will be added as .p12) and an alias for the generated certificate." echo "usage: ${x} " diff --git a/Server/src/config/as2_certs.p12 b/Server/src/config/as2_certs.p12 index 45732c0f..47d0232a 100644 Binary files a/Server/src/config/as2_certs.p12 and b/Server/src/config/as2_certs.p12 differ diff --git a/Server/src/config/config.xml b/Server/src/config/config.xml index e4a3db99..a242e8d6 100644 --- a/Server/src/config/config.xml +++ b/Server/src/config/config.xml @@ -195,8 +195,8 @@ protocol="$properties.module.HealthCheckModule.protocol" address="$properties.module.HealthCheckModule.address$" port="$properties.module.HealthCheckModule.port$" - ssl_keystore="$properties.module.HealthCheckModule.ssl_keystore$" - ssl_keystore_password="$properties.module.HealthCheckModule.ssl_keystore_password$"/> + ssl_keystore="$properties.ssl_keystore$" + ssl_keystore_password="$properties.ssl_keystore_password$"/> 1) { LOGGER.info("Processing OpenAS2 configuration properties file: {}", appPropsFile); java.util.Properties appProps = new java.util.Properties(); - // Support $ENV{some_env_var} reploacement in properties + // Support $ENV{some_env_var} replacement in properties StringEnvVarReplacer envVarReplacer = new StringEnvVarReplacer(); envVarReplacer.setAppHomeDir(getBaseDirectory()); FileInputStream fis = null; @@ -283,7 +283,7 @@ private void loadPartnerships(Node rootNode) throws OpenAS2Exception { PartnershipFactory partnerFx = (PartnershipFactory) XMLUtil.getComponent(rootNode, this); if (partnerFx == null) { - // Must be disable so do nothing + // Must be disabled so do nothing return; } setComponent(PartnershipFactory.COMPID_PARTNERSHIP_FACTORY, partnerFx); diff --git a/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java b/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java index 20761927..03b2059a 100644 --- a/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java +++ b/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java @@ -245,6 +245,9 @@ private void updateTracking() { // if the file length has stayed the same, process the file // and then stop tracking it if (processFilesAsThreads) { + if (logger.isDebugEnabled()) { + logger.debug("Parallel processing mode handling file: " + file.getName()); + } executorService.execute(new Runnable() { @Override public void run() { diff --git a/Server/src/test/java/org/openas2/TestResource.java b/Server/src/test/java/org/openas2/TestResource.java index 671be53c..ce5d5be0 100644 --- a/Server/src/test/java/org/openas2/TestResource.java +++ b/Server/src/test/java/org/openas2/TestResource.java @@ -4,49 +4,66 @@ import java.io.File; import java.io.FileNotFoundException; -import java.net.URISyntaxException; -import java.net.URL; +import java.nio.file.Paths; +import java.util.Map; /** - * A helper class for locating files and directories on the file systems. - * The main reason is to categorize static files used in tests. + * Retrieves resources used for test purposes from the file system + * */ public class TestResource { - - /** - * An absolute path to a test specific resource. + /* Set up a map of resource files that can be generically used by all tests + * and some test specific property files that override the default behaviour + * from the standard config.xml file such as for tests using 2 AS2 server instances. */ - private final String pathPrefix; - - private TestResource(String clazzSimpleName) { - try { - URL resource = Thread.currentThread().getContextClassLoader().getResource("."); - this.pathPrefix = new File(resource.toURI()).getAbsolutePath() + File.separator + clazzSimpleName; - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } + public static final Map resources = Map.of( + "config", new String[]{"config", "config.xml"}, + "partnerships", new String[]{"config", "partnerships.xml"}, + "server1-props", new String[]{"custom", "server1.properties"}, + "server1-partnerships", new String[]{"custom", "server1_partnerships.xml"}, + "server2-props", new String[]{"custom", "server2.properties"}, + "server2-partnerships", new String[]{"custom", "server2_partnerships.xml"}, + "api-server-props", new String[]{"custom", "api-server.properties"} + ); + + static String pathPrefix = Paths.get("src","test","resources").toAbsolutePath().toString(); - public static TestResource forClass(Class clazz) { - return new TestResource(clazz.getSimpleName()); - } - public static TestResource forGroup(String group) { - return new TestResource(group); + public static String getResource(String resourceIdentifier) throws FileNotFoundException { + /** + * Get absolute path to a file identified by the resource identifier passed in. + * + * @param resourceIdentifier - an identifier matching one of the keys in this classes resources map + * @return a file + */ + String[] resourceAttributes = resources.get(resourceIdentifier); + String filePath = get(resourceAttributes); + + return filePath; } /** - * Get a file or directory within {@link #pathPrefix} + * Get the absolute path to a file or directory within {@link #resourceBaseFolder} * - * @param fileName a file or directory name - * @param child a children name + * @param foldersAndFile - a list of optional folders in path with the actual file name as the last in the list * @return a file */ - public File get(String fileName, String... child) throws FileNotFoundException { - File file = new File(pathPrefix + File.separator + fileName + File.separator + StringUtils.join(child, File.separator)); + public static String get(String... foldersAndFile) throws FileNotFoundException { + String filePath = pathPrefix + File.separator + StringUtils.join(foldersAndFile, File.separator); + File file = new File(filePath); if (!file.exists()) { - throw new FileNotFoundException(file.getAbsolutePath()); + throw new FileNotFoundException(filePath); } - return file; + return filePath; + } + + /** + * Get a File object for a file or directory within {@link #resourceBaseFolder} + * + * @param foldersAndFile - a list of optional folders in path with the actual file name as the last in the list + * @return a File object + */ + public static File getFile(String... foldersAndFile) throws FileNotFoundException { + return new File(get(foldersAndFile)); } } diff --git a/Server/src/test/java/org/openas2/TestUtils.java b/Server/src/test/java/org/openas2/TestUtils.java index 7dfe61c0..7526622b 100644 --- a/Server/src/test/java/org/openas2/TestUtils.java +++ b/Server/src/test/java/org/openas2/TestUtils.java @@ -1,12 +1,8 @@ package org.openas2; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.TrueFileFilter; - import java.io.File; import java.io.FileNotFoundException; -import java.util.Collection; +import java.io.FilenameFilter; import java.util.concurrent.TimeUnit; /** @@ -24,31 +20,20 @@ public class TestUtils { * @return a file * @throws FileNotFoundException */ - public static File waitForFile(File parent, IOFileFilter fileFilter, int timeout, TimeUnit unit) throws FileNotFoundException { + public static File waitForFile(File dir, String fileNameSubstr, int timeout, TimeUnit unit) throws FileNotFoundException { long finishAt = System.currentTimeMillis() + unit.toMillis(timeout); - waitForFile(parent, timeout, unit); + FilenameFilter subStringFilter = (d, s) -> { + return s.contains(fileNameSubstr); + }; while (finishAt - System.currentTimeMillis() > 0) { - Collection files = FileUtils.listFiles(parent, fileFilter, TrueFileFilter.INSTANCE); - if (!files.isEmpty()) { - if (files.size() > 1) { + String[] files = dir.list(subStringFilter); + if (files.length == 1) { + return new File(dir.getPath() + File.separator + files[0]); + } else if (files.length > 1) { throw new IllegalStateException("Result is not unique."); - } else { - return files.iterator().next(); - } } } - throw new FileNotFoundException(parent.getAbsolutePath() + ": " + fileFilter.toString()); - } - - /** - * Wait till file will occur on the file system. - * - * @param file a file - * @param timeout an amount of time units to wait - * @param unit a time unit - */ - public static void waitForFile(File file, int timeout, TimeUnit unit) { - FileUtils.waitFor(file, Long.valueOf(unit.toSeconds(timeout)).intValue()); + throw new FileNotFoundException("Directory: " + dir.getAbsolutePath() + " File Name Substring: " + fileNameSubstr); } public static boolean deleteDirectory(File directoryToBeDeleted) { diff --git a/Server/src/test/java/org/openas2/app/BaseServerSetup.java b/Server/src/test/java/org/openas2/app/BaseServerSetup.java index 8a57fc48..cb284336 100644 --- a/Server/src/test/java/org/openas2/app/BaseServerSetup.java +++ b/Server/src/test/java/org/openas2/app/BaseServerSetup.java @@ -19,7 +19,6 @@ public class BaseServerSetup { - private static final TestResource RESOURCE = TestResource.forGroup("SingleServerTest"); static String myCompanyOid = "MyCompany_OID"; static String myPartnerOid = "PartnerA_OID"; private boolean startActiveModules = false; @@ -72,7 +71,7 @@ public void setup() throws Exception { if (openAS2PropertiesFile.exists()) { System.setProperty(Properties.OPENAS2_PROPERTIES_FILE_PROP, openAS2PropertiesFile.getAbsolutePath()); } - session = new XMLSession(RESOURCE.get("MyCompany", "config", "config.xml").getAbsolutePath()); + session = new XMLSession(TestResource.getResource("config")); simpleTestMsg = getSimpleTestMsg(); if (startActiveModules) { session.start(); diff --git a/Server/src/test/java/org/openas2/app/HealthCheckTest.java b/Server/src/test/java/org/openas2/app/HealthCheckTest.java index c0315180..df663cdb 100644 --- a/Server/src/test/java/org/openas2/app/HealthCheckTest.java +++ b/Server/src/test/java/org/openas2/app/HealthCheckTest.java @@ -11,6 +11,7 @@ import org.openas2.TestUtils; import org.openas2.processor.ActiveModule; import org.openas2.processor.receiver.NetModule; +import org.openas2.util.Properties; import java.io.File; import java.io.FileOutputStream; @@ -27,7 +28,6 @@ @ExtendWith(MockitoExtension.class) public class HealthCheckTest { - private static final TestResource RESOURCE = TestResource.forGroup("SingleServerTest"); // private static File openAS2AHome; private static OpenAS2Server serverInstance; private static ExecutorService executorService; @@ -40,7 +40,7 @@ public static void startServer() throws Exception { // to make sure the release package is fully tested scratchpad = Files.createTempDirectory("testResources"); File customPropsFile = Files.createFile(Paths.get(scratchpad.toString(), "openas2.properties")).toFile(); - System.setProperty("openas2.properties.file", customPropsFile.getAbsolutePath()); + System.setProperty(Properties.OPENAS2_PROPERTIES_FILE_PROP, customPropsFile.getAbsolutePath()); FileOutputStream fos = new FileOutputStream(customPropsFile); fos.write("module.HealthCheckModule.enabled=true\n".getBytes()); fos.close(); @@ -49,7 +49,7 @@ public static void startServer() throws Exception { // System.setProperty("OPENAS@_LOG_LEVEL", "TRACE"); executorService = Executors.newFixedThreadPool(20); - HealthCheckTest.serverInstance = new OpenAS2Server.Builder().run(RESOURCE.get("MyCompany", "config", "config.xml").getAbsolutePath()); + HealthCheckTest.serverInstance = new OpenAS2Server.Builder().run(TestResource.getResource("config")); } catch (Throwable e) { // aid for debugging JUnit tests System.err.println("ERROR occurred: " + ExceptionUtils.getStackTrace(e)); diff --git a/Server/src/test/java/org/openas2/app/OpenAS2ServerTest.java b/Server/src/test/java/org/openas2/app/OpenAS2ServerTest.java index 133b00d5..8331ef07 100644 --- a/Server/src/test/java/org/openas2/app/OpenAS2ServerTest.java +++ b/Server/src/test/java/org/openas2/app/OpenAS2ServerTest.java @@ -37,14 +37,13 @@ public class OpenAS2ServerTest { - private static final TestResource RESOURCE = TestResource.forClass(OpenAS2ServerTest.class); - - private static TestPartner serverAPartnerSender; - private static TestPartner serverBPartnerReceiver; - private static TestPartner serverBPartnerSender; - private static TestPartner serverAPartnerReceiver; - private static OpenAS2Server serverA; - private static OpenAS2Server serverB; + + private static TestPartner server1PartnerSender; + private static TestPartner server2PartnerReceiver; + private static TestPartner server2PartnerSender; + private static TestPartner server1PartnerReceiver; + private static OpenAS2Server server1; + private static OpenAS2Server server2; private static String[] dataFolders = new String[2]; private final int msgCnt = 2; @@ -57,19 +56,27 @@ public static void startServers() throws Exception { tmp = Files.createTempDirectory("testResources").toFile(); //System.setProperty("OPENAS2_LOG_LEVEL", "TRACE"); try { - serverA = new OpenAS2Server.Builder().run(RESOURCE.get("OpenAS2A", "config", "config.xml").getAbsolutePath()); + String configFile = TestResource.getResource("config"); + System.setProperty("SERVER1_PARTNERSHIP_FILE", TestResource.getResource("server1-partnerships")); + String props1File = TestResource.getResource("server1-props"); + System.setProperty(Properties.OPENAS2_PROPERTIES_FILE_PROP, props1File); + server1 = new OpenAS2Server.Builder().run(configFile); // Get the data folder from Properties before starting the other server as it overwrites the Properties dataFolders[0] = Properties.getProperty("storageBaseDir", null); // Iterate over the partnerships picking the first one that has a directory poller - serverAPartnerSender = getFromFirstSendingPartnership(serverA); + server1PartnerSender = getFromFirstSendingPartnership(server1); // Use the 2 partners in the initial partnership to get other parnerships to test both way transfer // Get a receiver partnership for the matching partners in the sender partnership for server A - serverAPartnerReceiver = getFromPartnerIds(serverA, serverAPartnerSender.getPartnerAS2Id(), serverAPartnerSender.getAs2Id()); - serverB = new OpenAS2Server.Builder().run(RESOURCE.get("OpenAS2B", "config", "config.xml").getAbsolutePath()); + server1PartnerReceiver = getFromPartnerIds(server1, server1PartnerSender.getPartnerAS2Id(), server1PartnerSender.getAs2Id()); + + System.setProperty("SERVER2_PARTNERSHIP_FILE", TestResource.getResource("server2-partnerships")); + String props2File = TestResource.getResource("server2-props"); + System.setProperty(Properties.OPENAS2_PROPERTIES_FILE_PROP, props2File); + server2 = new OpenAS2Server.Builder().run(configFile); // Set up the receiver fin server B for the sender from server A - serverBPartnerReceiver = getFromPartnerIds(serverB, serverAPartnerSender.getAs2Id(), serverAPartnerSender.getPartnerAS2Id()); + server2PartnerReceiver = getFromPartnerIds(server2, server1PartnerSender.getAs2Id(), server1PartnerSender.getPartnerAS2Id()); // Get a sender partnership for the matching partners in the receiver partnership for server B - serverBPartnerSender = getFromPartnerIds(serverB, serverAPartnerSender.getPartnerAS2Id(), serverAPartnerSender.getAs2Id()); + server2PartnerSender = getFromPartnerIds(server2, server1PartnerSender.getPartnerAS2Id(), server1PartnerSender.getAs2Id()); dataFolders[1] = Properties.getProperty("storageBaseDir", null); executorService = Executors.newFixedThreadPool(20); } catch (FileNotFoundException e) { @@ -86,7 +93,7 @@ public static void startServers() throws Exception { @Test public void shouldSendMessagesSyncMdn() throws Exception { try { - sendMessages(serverAPartnerSender, serverBPartnerReceiver); + sendMessages(server1PartnerSender, server2PartnerReceiver); } catch (Throwable e) { // Aid debugging JUnit test failures System.out.println("shouldSendMessagesSyncMdn ERROR OCCURRED: " + ExceptionUtils.getStackTrace(e)); @@ -97,7 +104,7 @@ public void shouldSendMessagesSyncMdn() throws Exception { @Test public void shouldSendMessagesAsyncMdn() throws Exception { try { - sendMessages(serverBPartnerSender, serverAPartnerReceiver); + sendMessages(server2PartnerSender, server1PartnerReceiver); } catch (Throwable e) { // Aid debugging JUnit test failures System.out.println("shouldSendMessagesAsyncMdn ERROR OCCURRED: " + ExceptionUtils.getStackTrace(e)); @@ -128,8 +135,8 @@ public TestMessage call() throws Exception { public static void tearDown() throws Exception { //executorService.awaitTermination(15, TimeUnit.SECONDS); executorService.shutdown(); - serverAPartnerSender.getServer().shutdown(); - serverBPartnerReceiver.getServer().shutdown(); + server1PartnerSender.getServer().shutdown(); + server2PartnerReceiver.getServer().shutdown(); // Cleanup the folders created so the test does not fail next time round from leftover data // NOTE: For debugging "missing" files it is best to comment this out for (int i = 0; i < dataFolders.length; i++) { @@ -147,7 +154,7 @@ private TestMessage sendMessage(TestPartner fromPartner, TestPartner toPartner) String outgoingMsgBody = RandomStringUtils.secure().nextAlphanumeric(1024); File outgoingMsg = Files.createFile(Paths.get(tmp.toString(), outgoingMsgFileName)).toFile(); FileUtils.write(outgoingMsg, outgoingMsgBody, "UTF-8"); - System.out.println("Copying a file to send to:" + fromPartner.getOutbox()); + System.out.println("Copying " + outgoingMsg.getName() + " file for sending to:" + fromPartner.getOutbox()); FileUtils.copyFileToDirectory(outgoingMsg, fromPartner.getOutbox()); //System.out.println("**** **** FILE COPIED: " + fromPartner.getOutbox() + "/" + outgoingMsg.getName()); @@ -157,7 +164,8 @@ private TestMessage sendMessage(TestPartner fromPartner, TestPartner toPartner) private TestMessage getDeliveredMessage(TestMessage testMessage) throws IOException { // Wait a while - will depend on the sender poller interval how long it takes to arrive - testMessage.deliveredMsg = waitForFile(testMessage.toPartner.getInbox(), new PrefixFileFilter(testMessage.fileName), 20, TimeUnit.SECONDS); + // System.out.println("**** **** INBOX AWAITING FILE: " + testMessage.toPartner.getInbox().getAbsolutePath() + "/***-" + testMessage.fileName); + testMessage.deliveredMsg = waitForFile(testMessage.toPartner.getInbox(), testMessage.fileName, 20, TimeUnit.SECONDS); return testMessage; } @@ -166,10 +174,10 @@ private void verifyMessageDelivery(TestMessage testMessage) throws IOException { String deliveredMsgBody = FileUtils.readFileToString(testMessage.deliveredMsg, "UTF-8"); assertThat("Verify content of delivered message", deliveredMsgBody, is(testMessage.body)); - File rxdMDN = waitForFile(testMessage.toPartner.getRxdMDNs(), new PrefixFileFilter(testMessage.fileName), 10, TimeUnit.SECONDS); + File rxdMDN = waitForFile(testMessage.toPartner.getRxdMDNs(), testMessage.fileName, 10, TimeUnit.SECONDS); assertThat("Verify MDN was received by " + testMessage.toPartner.getName(), rxdMDN.exists(), is(true)); - File sentMDN = waitForFile(testMessage.fromPartner.getSentMDNs(), new PrefixFileFilter(testMessage.fileName), 10, TimeUnit.SECONDS); + File sentMDN = waitForFile(testMessage.fromPartner.getSentMDNs(), testMessage.fileName, 10, TimeUnit.SECONDS); assertThat("Verify sent MDN was stored by " + testMessage.fromPartner.getName(), sentMDN.exists(), is(true)); } diff --git a/Server/src/test/java/org/openas2/app/RestApiTest.java b/Server/src/test/java/org/openas2/app/RestApiTest.java index 56de6068..78fa5c49 100644 --- a/Server/src/test/java/org/openas2/app/RestApiTest.java +++ b/Server/src/test/java/org/openas2/app/RestApiTest.java @@ -47,7 +47,6 @@ @ExtendWith(MockitoExtension.class) @TestMethodOrder(MethodOrderer.MethodName.class) public class RestApiTest { - private static final TestResource RESOURCE = TestResource.forGroup("SingleServerTest"); // private static File openAS2AHome; private static OpenAS2Server serverInstance; private static String TEST_PARTNER_NAME = "partnerX"; @@ -78,7 +77,7 @@ public static void start_A_Server() throws Exception { //System.setProperty(OPENAS2_LOG_LEVEL", "TRACE"); //executorService = Executors.newFixedThreadPool(20); - RestApiTest.serverInstance = new OpenAS2Server.Builder().run(RESOURCE.get("MyCompany", "config", "config.xml").getAbsolutePath()); + RestApiTest.serverInstance = new OpenAS2Server.Builder().run(TestResource.getResource("config")); } catch (Throwable e) { // aid for debugging JUnit tests System.err.println("ERROR occurred: " + ExceptionUtils.getStackTrace(e)); diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/DB/openas2.mv.db b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/DB/openas2.mv.db deleted file mode 100644 index c6610637..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/DB/openas2.mv.db and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/as2_certs.p12 b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/as2_certs.p12 deleted file mode 100644 index 13346b6a..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/as2_certs.p12 and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/commands.xml b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/commands.xml deleted file mode 100644 index 6f095991..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/commands.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/config.xml b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/config.xml deleted file mode 100644 index dae30c2d..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/config.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/db_ddl.sql b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/db_ddl.sql deleted file mode 100644 index 80fab0a4..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/db_ddl.sql +++ /dev/null @@ -1,29 +0,0 @@ -set IGNORECASE TRUE; -DROP TABLE msg_metadata IF EXISTS; -CREATE TABLE msg_metadata ( - ID INTEGER default 0 NOT NULL AUTO_INCREMENT, - MSG_ID LONGVARCHAR NOT NULL, - MDN_ID LONGVARCHAR, - DIRECTION VARCHAR(25) , - IS_RESEND VARCHAR(1) DEFAULT 'N', - RESEND_COUNT INTEGER DEFAULT 0, - SENDER_ID VARCHAR(255) NOT NULL, - RECEIVER_ID VARCHAR(255) NOT NULL, - STATUS VARCHAR(255), - STATE VARCHAR(255), - SIGNATURE_ALGORITHM VARCHAR(255), - ENCRYPTION_ALGORITHM VARCHAR(255), - COMPRESSION VARCHAR(255), - FILE_NAME VARCHAR(255), - CONTENT_TYPE VARCHAR(255), - CONTENT_TRANSFER_ENCODING VARCHAR(255), - MDN_MODE VARCHAR(255), - MDN_RESPONSE LONGVARCHAR, - STATE_MSG LONGVARCHAR, - CREATE_DT TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - UPDATE_DT TIMESTAMP, - - PRIMARY KEY (ID) ); - -ALTER TABLE msg_metadata ADD CONSTRAINT MSG_ID_UNIQUE UNIQUE (MSG_ID); - diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/partnerships.xml b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/partnerships.xml deleted file mode 100644 index a9e4cb72..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/partnerships.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/ssl_certs.jks b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/ssl_certs.jks deleted file mode 100644 index 52b4e7bd..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/ssl_certs.jks and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/DB/openas2.mv.db b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/DB/openas2.mv.db deleted file mode 100644 index 67a2f92e..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/DB/openas2.mv.db and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/as2_certs.p12 b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/as2_certs.p12 deleted file mode 100644 index 13346b6a..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/as2_certs.p12 and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/commands.xml b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/commands.xml deleted file mode 100644 index 6f095991..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/commands.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/config.xml b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/config.xml deleted file mode 100644 index 05314093..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/config.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/db_ddl.sql b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/db_ddl.sql deleted file mode 100644 index 80fab0a4..00000000 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/db_ddl.sql +++ /dev/null @@ -1,29 +0,0 @@ -set IGNORECASE TRUE; -DROP TABLE msg_metadata IF EXISTS; -CREATE TABLE msg_metadata ( - ID INTEGER default 0 NOT NULL AUTO_INCREMENT, - MSG_ID LONGVARCHAR NOT NULL, - MDN_ID LONGVARCHAR, - DIRECTION VARCHAR(25) , - IS_RESEND VARCHAR(1) DEFAULT 'N', - RESEND_COUNT INTEGER DEFAULT 0, - SENDER_ID VARCHAR(255) NOT NULL, - RECEIVER_ID VARCHAR(255) NOT NULL, - STATUS VARCHAR(255), - STATE VARCHAR(255), - SIGNATURE_ALGORITHM VARCHAR(255), - ENCRYPTION_ALGORITHM VARCHAR(255), - COMPRESSION VARCHAR(255), - FILE_NAME VARCHAR(255), - CONTENT_TYPE VARCHAR(255), - CONTENT_TRANSFER_ENCODING VARCHAR(255), - MDN_MODE VARCHAR(255), - MDN_RESPONSE LONGVARCHAR, - STATE_MSG LONGVARCHAR, - CREATE_DT TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - UPDATE_DT TIMESTAMP, - - PRIMARY KEY (ID) ); - -ALTER TABLE msg_metadata ADD CONSTRAINT MSG_ID_UNIQUE UNIQUE (MSG_ID); - diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/ssl_certs.jks b/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/ssl_certs.jks deleted file mode 100644 index 52b4e7bd..00000000 Binary files a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/ssl_certs.jks and /dev/null differ diff --git a/Server/src/test/resources/SingleServerTest/MyCompany/config/as2_certs.p12 b/Server/src/test/resources/SingleServerTest/MyCompany/config/as2_certs.p12 deleted file mode 100644 index 06b579b0..00000000 Binary files a/Server/src/test/resources/SingleServerTest/MyCompany/config/as2_certs.p12 and /dev/null differ diff --git a/Server/src/test/resources/SingleServerTest/MyCompany/config/commands.xml b/Server/src/test/resources/SingleServerTest/MyCompany/config/commands.xml deleted file mode 100644 index 0ae9bbb0..00000000 --- a/Server/src/test/resources/SingleServerTest/MyCompany/config/commands.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/src/test/resources/SingleServerTest/MyCompany/config/config.xml b/Server/src/test/resources/SingleServerTest/MyCompany/config/config.xml deleted file mode 100644 index 902d870d..00000000 --- a/Server/src/test/resources/SingleServerTest/MyCompany/config/config.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Server/src/test/resources/SingleServerTest/MyCompany/config/partnerships.xml b/Server/src/test/resources/SingleServerTest/MyCompany/config/partnerships.xml deleted file mode 100644 index 80960e79..00000000 --- a/Server/src/test/resources/SingleServerTest/MyCompany/config/partnerships.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Server/src/test/resources/SingleServerTest/MyCompany/config/ssl_certs.jks b/Server/src/test/resources/SingleServerTest/MyCompany/config/ssl_certs.jks deleted file mode 100644 index 52b4e7bd..00000000 Binary files a/Server/src/test/resources/SingleServerTest/MyCompany/config/ssl_certs.jks and /dev/null differ diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/content_type_mappings.properties b/Server/src/test/resources/config/content_type_mappings.properties similarity index 100% rename from Server/src/test/resources/OpenAS2ServerTest/OpenAS2A/config/content_type_mappings.properties rename to Server/src/test/resources/config/content_type_mappings.properties diff --git a/Server/src/test/resources/config/db_ddl.sql b/Server/src/test/resources/config/db_ddl.sql new file mode 100644 index 00000000..027dee73 --- /dev/null +++ b/Server/src/test/resources/config/db_ddl.sql @@ -0,0 +1,39 @@ +-- ----------------------------------------------------------------------- +-- msg_metadata +-- ----------------------------------------------------------------------- + +DROP TABLE msg_metadata IF EXISTS; + +-- ----------------------------------------------------------------------- +-- msg_metadata +-- ----------------------------------------------------------------------- + +CREATE TABLE msg_metadata +( + ID INTEGER NOT NULL AUTO_INCREMENT, + MSG_ID VARCHAR NOT NULL, + PRIOR_MSG_ID VARCHAR, + MDN_ID VARCHAR, + DIRECTION VARCHAR(25), + IS_RESEND VARCHAR(1), + RESEND_COUNT INTEGER, + SENDER_ID VARCHAR(255) NOT NULL, + RECEIVER_ID VARCHAR(255) NOT NULL, + STATUS VARCHAR(255), + STATE VARCHAR(255), + SIGNATURE_ALGORITHM VARCHAR(255), + ENCRYPTION_ALGORITHM VARCHAR(255), + COMPRESSION VARCHAR(255), + FILE_NAME VARCHAR(255), + CONTENT_TYPE VARCHAR(255), + CONTENT_TRANSFER_ENCODING VARCHAR(255), + MDN_MODE VARCHAR(255), + MDN_RESPONSE VARCHAR, + STATE_MSG VARCHAR, + CREATE_DT TIMESTAMP, + UPDATE_DT TIMESTAMP, + PRIMARY KEY (ID) +); + +CREATE UNIQUE INDEX MSG_ID_UNIQUE ON msg_metadata (MSG_ID); + diff --git a/Server/src/test/resources/custom/server1.properties b/Server/src/test/resources/custom/server1.properties new file mode 100644 index 00000000..88a08f21 --- /dev/null +++ b/Server/src/test/resources/custom/server1.properties @@ -0,0 +1,11 @@ +storageBaseDir=src/test/resources/data1 +partnership_file=src/test/resources/custom/server1_partnerships.xml +config.dir=%home% +pollerConfigBase.interval=1 +module.AS2ReceiverModule.http.port=10080 +module.AS2MDNReceiverModule.http.port=10081 +module.AS2MDNReceiverModule.http.enabled=true +module.AS2ReceiverModule.https.port=1443 +module.AS2MDNReceiverModule.https.port=11443 +module.HealthCheckModule.port=10099 +msg_tracking.tcp_server_port=10092 diff --git a/Server/src/test/resources/custom/server1_partnerships.xml b/Server/src/test/resources/custom/server1_partnerships.xml new file mode 100644 index 00000000..7002a855 --- /dev/null +++ b/Server/src/test/resources/custom/server1_partnerships.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Server/src/test/resources/custom/server2.properties b/Server/src/test/resources/custom/server2.properties new file mode 100644 index 00000000..91ce0d63 --- /dev/null +++ b/Server/src/test/resources/custom/server2.properties @@ -0,0 +1,11 @@ +storageBaseDir=src/test/resources/data2 +partnership_file=src/test/resources/custom/server2_partnerships.xml +pollerConfigBase.interval=1 +module.AS2ReceiverModule.http.port=20080 +async_mdn_receiver_port=20081 +module.AS2MDNReceiverModule.http.port=$properties.async_mdn_receiver_port$ +as2_async_mdn_url=http://localhost:$properties.async_mdn_receiver_port$ +module.AS2ReceiverModule.https.port=2443 +module.AS2MDNReceiverModule.https.port=22443 +module.HealthCheckModule.port=20099 +msg_tracking.tcp_server_port=20092 diff --git a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/partnerships.xml b/Server/src/test/resources/custom/server2_partnerships.xml similarity index 59% rename from Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/partnerships.xml rename to Server/src/test/resources/custom/server2_partnerships.xml index bda57a57..ee60fcb9 100644 --- a/Server/src/test/resources/OpenAS2ServerTest/OpenAS2B/config/partnerships.xml +++ b/Server/src/test/resources/custom/server2_partnerships.xml @@ -1,41 +1,28 @@ - - + + - - - - - - - - - - - - - - - - - + + + + - - - + + + + - + diff --git a/changes.txt b/changes.txt index 57aab4b3..118b6e5c 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,17 @@ **IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading +Version 4.6.0 - 2025-08-04 + +This is a testing enhancement release. + +1. Reworked the resource access class +2. changed tests to use the same config that is provided in the installer package +3. Optimised method to wait for files to appear on file system as part of end-to-end tests +4. Created script to generate test certificates keystore with updated certificates +5. Added maven phase to regenerate test certificates keystore prior to running tests +6. Updated Maven wrapper for project +7. Added Java 24 to test matrix + Version 4.5.2 - 2025-06-12 This is a bugfix release. diff --git a/mvnw b/mvnw index 006d61d4..8d937f4c 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Apache Maven Wrapper startup batch script, version 3.2.0 # # Required ENV vars: # ------------------ @@ -27,7 +27,6 @@ # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -36,6 +35,10 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -50,109 +53,56 @@ fi cygwin=false; darwin=false; mingw=false -case "`uname`" in +case "$(uname)" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + JAVA_HOME=$(java-config --jre-home) fi fi -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" else - javaExecutable="`readlink -f \"$javaExecutable\"`" + javaExecutable="$(readlink -f "\"$javaExecutable\"")" fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') JAVA_HOME="$javaHome" export JAVA_HOME fi @@ -168,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`which java`" + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" fi fi @@ -182,57 +132,177 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround done - echo "${basedir}" + printf '%s' "$(cd "$basedir" || exit 1; pwd)" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" -# Provide a "standardized" way to retrieve the CLI args that will +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -# "-Dcom.sun.security.enableAIAcaIssuers=true" \ -# "-Djavax.net.debug=ssl:handshake:verbose:keymanager:trustmanager" \ - -"$JAVACMD" \ +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Djavax.net.debug=ssl:trustmanager" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CMD_LINE_ARGS -exit 0 + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 00104808..c4586b56 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,15 +18,14 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Apache Maven Wrapper startup batch script, version 3.2.0 @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @REM @REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +34,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -44,8 +45,8 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* :skipRcPre @setlocal @@ -80,8 +81,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +116,72 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end @@ -131,15 +191,15 @@ set ERROR_CODE=1 :end @endlocal & set ERROR_CODE=%ERROR_CODE% -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost @REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" :skipRcPost @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause +if "%MAVEN_BATCH_PAUSE%"=="on" pause -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% -exit /B %ERROR_CODE% +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index ba35ab7b..85cc5298 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.sf.openas2 OpenAS2 - 4.5.2 + 4.6.0 OpenAS2 pom @@ -46,7 +46,7 @@ org.dom4j dom4j - 2.1.4 + 2.2.0 org.bouncycastle @@ -81,12 +81,12 @@ commons-cli commons-cli - 1.9.0 + 1.10.0 com.sun.mail jakarta.mail - 2.0.1 + 2.0.2 com.h2database @@ -108,7 +108,7 @@ org.junit.jupiter junit-jupiter - 5.13.1 + 5.13.4 test @@ -136,7 +136,7 @@ commons-io commons-io - 2.19.0 + 2.20.0 org.slf4j @@ -167,13 +167,13 @@ com.fasterxml.jackson.core jackson-databind - 2.19.0 + 2.19.2 jar com.fasterxml.jackson.module jackson-module-jaxb-annotations - 2.19.0 + 2.19.2 org.glassfish.jersey.media @@ -204,7 +204,7 @@ com.zaxxer HikariCP - 6.3.0 + 7.0.0