Skip to content

Commit

Permalink
Directory poller config moved to partnership XML (#269)
Browse files Browse the repository at this point in the history
* Handle possible null mdn object to avoid exception being thrown

* Enhance error messages to be clearer.

* Support overriding the target directory for saving inbound files at
partnership level.

* Support replacing the %home% placeholder on load of XML doc.

* Fix spelling error

* Make getPartnership public

* Only close if not alreadyclosed

* Simple shell script to create DB table in H2 DB

* Static for poller config XML element in partnerships.xml

* Make looking up partnership possible from AS2 ID's

* Support loading directory pollers from partnership config.

Add duplicate poller checks based on AS2 ID's

* Fix testing so that it does work in parallel rather than being blocked
by file arrival checking

* Remove redundant method

* Fix comment indentation issue

* Expand the classpath instead of using file globbing expansion in the
java command as it seems to mess with Mailcap loading

* Updated to test partnership based poller and no signed MDN response.

* Set response MDN content type when not signed.

* Base poller config stored in config.xml

* Add cleanup of all partneship based pollers when a refresh is called

* Fix weird logging method name "terminate:.

* Remove obsolete jar

* Add example for "store_received_file_to" attrib

* Switch to using partnership pollers

* Fix command for adding and storing partnership config.

* Fix partnership relted commands to retain the original config of the
file so it does not overwrite dynamic variables.

* Update the packages to latest.

* Add helper method to create a new XML doc

* Windows version of the import script for certificates from another
keystore.

* Add information about maven testing and packaging commands.

* configuration migration script

* Release notes and version changes

* Enhanced documentation for poller configuration.

* Release note history

* Make statics public

* Remove redundant imports

* Rules to prevent alpha/beta release candidate libs being used.
  • Loading branch information
uhurusurfa authored Apr 10, 2022
1 parent ad5c350 commit 926e9da
Show file tree
Hide file tree
Showing 57 changed files with 2,100 additions and 1,239 deletions.
145 changes: 79 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,79 @@
![logo](https://raw.githubusercontent.com/igwtech/OpenAs2App/master/docs/as2_logo.png)

# As2Server
The OpenAS2 application enables you to transmit and receive AS2 messages with EDI-X12, EDIFACT, XML, or binary payloads between trading partners.


## Development
There is a pom.xml in the Server folder to compile and create the jar and build the distribution package using Maven.
The current version of the application is extracted from the POM and inserted into the MANIFEST.MF at build time.
More detailed information is available in the DeveloperGuide.odt in the docs folder in Github.

## Build

Maven is used as a build tool. Therefore in order to build a snapshot the following command should be used:

`./mvnw clean package`


`./mvnw versions:set -DnewVersion=2.12.0-SNAPSHOT`

## Deploy to Maven Central
To deploy the released artifacts requires user ID and password for Sonatype. See developer guide for details:
`./mvnw clean deploy -P release` - will require manual closing and release in Sonatype
`./mvnw release:perform`
`./mvnw nexus-staging:release -Ddescription="Some release comment here"`

## How to create docker image

To create docker image ,use the Dockerfile in the project.
In terminal, open the folder where Dockerfile is located.
Use below command to login to your dockerhub account through terminal.

```console
$ docker login
```

Run below command to create image with name and tag.

```console
$ docker build -t openas2:latest .
```

## How to use this image.

Run the default OpenAS2 server:

```console
$ docker run -it --rm openas2:latest
```

You can test it by visiting `http://container-ip:10080` in a browser or, if you need access outside the host, on port 4080:

```console
$ docker run -it --rm -p 10080:4080 -p 10081:4081 openas2:latest
```

You can then go to `http://localhost:4080` or `http://host-ip:4080` in a browser (noting that it will return a 401 since there are no proper AS2 headers sent by the browser by default).

The default OpenAS2 environment in the image is:

OPENAS2_BASE: /usr/local/tomcat
OPENAS2_HOME: /usr/local/tomcat
OPENAS2_TMPDIR: /usr/local/tomcat/temp
JAVA_HOME: /usr/local/openjdk-11

The configuration files are available in `/opt/openas2/config/`.
![logo](https://raw.githubusercontent.com/igwtech/OpenAs2App/master/docs/as2_logo.png)

# As2Server
The OpenAS2 application enables you to transmit and receive AS2 messages with EDI-X12, EDIFACT, XML, or binary payloads between trading partners.


## Development
There is a pom.xml in the Server folder to compile and create the jar and build the distribution package using Maven.
The current version of the application is extracted from the POM and inserted into the MANIFEST.MF at build time.
More detailed information is available in the DeveloperGuide.odt in the docs folder in Github.

## Test, Build and Package
The following commands can be used in the build process.

Checking dependency tree:
`./mvnw dependency:tree`

Checking dependencies against latest:
`./mvnw versions:display-dependency-updates`

Updating dependencies to latest:
`./mvnw versions:use-latest-releases`

Build a snapshot the following command should be used:
`./mvnw versions:set -DnewVersion=2.12.0-SNAPSHOT`

Run unit tests:
`./mvnw test`

Build a package
`./mvnw clean package`


## Deploy to Maven Central
To deploy the released artifacts requires user ID and password for Sonatype. See developer guide for details:
`./mvnw clean deploy -P release` - will require manual closing and release in Sonatype
`./mvnw release:perform`
`./mvnw nexus-staging:release -Ddescription="Some release comment here"`

## How to create docker image

To create docker image ,use the Dockerfile in the project.
In terminal, open the folder where Dockerfile is located.
Use below command to login to your dockerhub account through terminal.

```console
$ docker login
```

Run below command to create image with name and tag.

```console
$ docker build -t openas2:latest .
```

## How to use this image.

Run the default OpenAS2 server:

```console
$ docker run -it --rm openas2:latest
```

You can test it by visiting `http://container-ip:10080` in a browser or, if you need access outside the host, on port 4080:

```console
$ docker run -it --rm -p 10080:4080 -p 10081:4081 openas2:latest
```

You can then go to `http://localhost:4080` or `http://host-ip:4080` in a browser (noting that it will return a 401 since there are no proper AS2 headers sent by the browser by default).

The default OpenAS2 environment in the image is:

OPENAS2_BASE: /usr/local/tomcat
OPENAS2_HOME: /usr/local/tomcat
OPENAS2_TMPDIR: /usr/local/tomcat/temp
JAVA_HOME: /usr/local/openjdk-11

The configuration files are available in `/opt/openas2/config/`.
24 changes: 14 additions & 10 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# OpenAS2 Server
# Version 2.14.0
# Version 3.0.0
# RELEASE NOTES
-----
The OpenAS2 project is pleased to announce the release of OpenAS2 2.14.0
The OpenAS2 project is pleased to announce the release of OpenAS2 3.0.0

The release download file is: OpenAS2Server-2.14.0.zip

<span style="color:red">**IMPORTANT:** If you are currently running 2.13.1 then you should upgrade to this release ASAP</span>
The release download file is: OpenAS2Server-3.0.0.zip

The zip file contains a PDF document (OpenAS2HowTo.pdf) providing information on installing and using the application.
## NOTE: Testing covers Java 8 to 17. The application should work for older versions down to Java 7 but they are not tested as part of the CI/CD pipeline.

Version 2.14.0 - 2021-12-10
This is a minor enhancement release and OS file handle release bugfix:
Version 3.0.0 - 2022-04-10
This is a major release:
**IMPORTANT NOTE**: Please review upgrade notes below if you are upgrading


1. Add an additional way to filter files based on a regular expression. This allows filtering files based on text within the file name and not just the file extension. See the section **Restricting Directory Files By Extension Or Name** in the documentation for details of use.
2. Fix directory polling module not releasing file handles and eventually starving the OS of file handles.
1. The directory polling module is no longer configured in the config.xml file. By default, any partnership will get a polling module unless explicitly disabled using the appropriate attribute. See documentation for details.
2. Support for expired certificates. Some partners seem to continue to use expired certificates when sending messages. The expiration date can be ignored and still validate the signature by adding an attribute to the partnership to ignore the expiration. See documentation for details.


##Upgrade Notes
See the openAS2HowTo appendix for the general process on upgrading OpenAS2.

There are no specific notes for this upgrade.
### For this upgrade, the old config will work without change but it is strongly recommended that you follow these steps to convert your existing configuration to the new format:
1. Follow the instructions for specific versions between your current version and this version as defined below before executing the commands below to convert your existing config.xml and partnerships.xml files to use the enhanced poller configuration.
2. Open a terminal window (command window in Windows)
3. Change to the <install>/config directory of the new version.
4. Copy the config.xml and partnerships.xml from your existing version to the new version if not already done in other steps.
5. Run this command: java -cp ../lib/\* org.openas2.upgrades.MigratePollingModuleConfig config.xml partnerships.xml
6. A backup will be created of the original file (with .00 extension|) that can be removed if the conversion is successful.

Below are some specific things to focus on depending on which version you are upgrading from.

Expand Down
2 changes: 1 addition & 1 deletion Remote/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>net.sf.openas2</groupId>
<artifactId>OpenAS2</artifactId>
<version>2.14.0</version>
<version>3.0.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
15 changes: 4 additions & 11 deletions Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- DO NOT CHANGE THIS "groupId" WITHOUT CHANGING XMLSession.getManifestAttributes.MANIFEST_VENDOR_ID_ATTRIB -->
<groupId>net.sf.openas2</groupId>
<artifactId>OpenAS2</artifactId>
<version>2.14.0</version>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -170,7 +170,7 @@
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
Expand Down Expand Up @@ -222,52 +222,45 @@
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>4.4.0-alpha.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>3.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>3.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.1</version>
</dependency>
<!-- Removed JavaEE APIs removed from Java 9+ -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.0</version>
</dependency>
<!--
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<dependency>
<groupId>javax.ws.rs</groupId>
Expand Down
66 changes: 66 additions & 0 deletions Server/src/bin/import_alias_from_keystore.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@echo off

if "%~4"=="" goto :Usage
set srcStore=%1%
set srcAlias=%2%
set tgtStore=%3%
set tgtAlias=%4%
set action=%5%
if "%action%" == "" set action=insert
rem Setup the Java Virtual Machine
call "%OPENAS2_BASE_DIR%\bin\find_java.bat"
if %ERRORLEVEL% NEQ 0 exit /B 1

echo Generate a certificate to a PKCS12 key store.
echo Generating certificate: using alias %certAlias% to %tgtStore%"

echo Executing action "%action%" on certificate from key "%srcStore%" using alias "%tgtAlias%" to: %tgtStore%"
setlocal
SET /P AREYOUSURE=Do you wish to execute this request (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" EXIT /B 0
endlocal

set /p srcksPwd=Enter password for source keystore:%=%
set /p tgtksPwd=Enter password for destination keystore:%=%

if "%action%" == "replace" (
"%JAVA_HOME%\bin\keytool" -delete -alias %tgtAlias% -keystore %tgtStore% -storepass %tgtksPwd% -storetype pkcs12
if errorlevel 1 (
echo The REPLACE option was specified.
echo Failed to delete the certificate in the keystore for alias "%tgtAlias%". See errors above to correct the problem.
EXIT /B 1
)
)
echo "%JAVA_HOME%\bin\keytool" -importkeystore -srckeystore %srcStore% -srcstoretype pkcs12 -srcstorepass "%srcksPwd%" -srcalias %srcAlias% -destalias %tgtAlias% -destkeystore %tgtStore% -deststorepass "%tgtksPwd%" -deststoretype pkcs12
"%JAVA_HOME%\bin\keytool" -importkeystore -srckeystore %srcStore% -srcstoretype pkcs12 -srcstorepass "%srcksPwd%" -srcalias %srcAlias% -destalias %tgtAlias% -destkeystore %tgtStore% -deststorepass "%tgtksPwd%" -deststoretype pkcs12
if errorlevel 1 (
echo ***** Failed to import the certificate to the keystore. See errors above to correct the problem.
echo If the error shows the certificate already exists then add the "replace" option to the command line.
EXIT /B 1
)
echo Successfully Imported certificate from file "%srcStore%" using alias "%tgtAlias%" to: %tgtSttore%

goto :END

:Usage
echo Import an entry in a source PKCS12 keystore identified by an alias to a target PKCS12 key store.
echo You must specify the source keystore, source alias entry, target key store file name and an alias for imported certificate.
echo By default the script will attempt to import the designated entries in the specified alias.
echo If you wish to replace an existing entry in the target keystore then specify "replace" as a 4th argument to the script
echo usage: import_alias_from_keystore.bat ^<src keystore^> ^<src alias^> ^<target keystore^> ^<target alias^> [action]s
echo WHERE
echo src keystore = name of the keystore containing the entry to be imported
echo src alias = name of the alias in the source keystore to be imported
echo target keystore = name of the target keystore file including .p12 extension
echo target alias = alias name used to store the imported entry in the keystore
echo action = if not provided this defaults to "import". The only other option is "replace"
echo anything other than "replace" will be interpreted as "import"

echo
echo eg. import_alias_from_keystore.bat my_cert2.p12 my_cert as2_certs.p12 my_cert_2
echo OR
echo eg. import_alias_from_keystore.bat my_cert2.p12 my_cert as2_certs.p12 my_cert_2 replace

:warn

:END
11 changes: 10 additions & 1 deletion Server/src/bin/start-openas2.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ rem set EXTRA_PARMS=%EXTRA_PARMS% -DCmdProcessorSocketCipher=SSL_DH_anon_WITH_R
rem Setup the Java Virtual Machine
call "%OPENAS2_BASE_DIR%\bin\find_java.bat"
if %ERRORLEVEL% NEQ 0 exit /B 1
set LIB_JARS=%OPENAS2_BASE_DIR%/lib/*

rem Using file globbing via * in classpath causes Mailcap loading issues so build full path
rem set LIB_JARS=%OPENAS2_BASE_DIR%/lib/*
setLocal EnableDelayedExpansion
set LIB_JARS=
for /R %OPENAS2_BASE_DIR%/lib %%a in (*.jar) do (
set LIB_JARS=!LIB_JARS!;%%a
)
set LIB_JARS=".!LIB_JARS!"
setLocal disableDelayedExpansion
rem
rem echo Running: "%JAVA%" %EXTRA_PARMS% -cp .;%LIB_JARS% org.openas2.app.OpenAS2Server "%OPENAS2_BASE_DIR%/config/config.xml"
"%JAVA%" %EXTRA_PARMS% -cp .;%LIB_JARS% org.openas2.app.OpenAS2Server "%OPENAS2_BASE_DIR%/config/config.xml"
Expand Down
5 changes: 3 additions & 2 deletions Server/src/bin/start-openas2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ if [ -z $JAVA_HOME ]; then
echo "ERROR: Cannot find JAVA_HOME"
exit 1
fi

CMD=`echo "${JAVA_HOME}/bin/java ${PWD_OVERRIDE} ${EXTRA_PARMS} -cp .:${binDir}/../lib/* org.openas2.app.OpenAS2Server"`
# Expand the classpath instead of using file globbing expansion in the java command as it seems to mess with Mailcap loading
CLASSPATH=$(echo "${binDir}/../lib/"*".jar" | tr ' ' ':')
CMD=$(echo "${JAVA_HOME}/bin/java ${PWD_OVERRIDE} ${EXTRA_PARMS} -cp .:${CLASSPATH} org.openas2.app.OpenAS2Server")
echo
echo Running ${CMD}
echo
Expand Down
Loading

0 comments on commit 926e9da

Please sign in to comment.