Spring Boot application for running DD4J for testing purposes.
For building and running this application, Java 17 is needed.
If enabled, the application allows to validate signed containers / signatures.
The functionality can be enabled via the following configuration parameter:
| Configuration parameter | Required | Description | Example |
|---|---|---|---|
validation.enabled |
NO | Whether to enable the validation functionality and endpoints. Defaults to false if not specified. |
true |
The application provides the following endpoints for validation:
POST /validate/bin
POST /validate/json
-
The first validation endpoint
/validate/binconsumes a container in raw binary format.- Requests to this endpoint must use
application/octet-streamcontent type header.
- Requests to this endpoint must use
-
The second validation endpoint
/validate/jsonconsumes JSON requests.-
Requests to this endpoint must use
application/jsoncontent type header. -
The request body has the following form:
Request parameter Required Description Example containerYES The container to validate in base64 encoded format. Q29udGFpbmVyIGJ5dGVzIGVuY29kZWQgaW4gYmFzZTY0IGZvcm1hdC4=
-
All validation endpoints produce JSON responses with the following parameters:
| Response parameter | Always present | Description | Example |
|---|---|---|---|
valid |
YES | Boolean flag indicating whether the validated container is valid. | true |
containerErrors |
NO | List of container errors. | - |
containerErrors[i].message |
YES | Container error message. | Container has a problem |
containerErrors[i].errorCode |
NO | Container error code number. | 13 |
containerWarnings |
NO | List of container warnings. | - |
containerWarnings[i].message |
YES | Container warning message. | Container has a problem |
containerWarnings[i].errorCode |
NO | Container warning code number. | 13 |
errors |
NO | List of signature errors. | - |
errors[i].message |
YES | Signature error message. | Signature has a problem |
errors[i].signatureId |
NO | Signature ID. | Signature has a problem |
errors[i].errorCode |
NO | Signature error code number. | 13 |
warnings |
NO | List of signature warnings. | - |
warnings[i].message |
YES | Signature warning message. | Signature has a problem |
warnings[i].signatureId |
NO | Signature ID. | Signature has a problem |
warnings[i].errorCode |
NO | Signature warning code number. | 13 |
validationReport |
NO | XML validation report in base64 encoded format. | PFNpbXBsZVJlcG9ydD4= |
If validation is enabled in the application, then the following configuration parameters can be configured:
| Configuration parameter | Required | Description | Example |
|---|---|---|---|
validation.configuration.mode |
YES | DD4J configuration mode for validation. Available options are PROD and TEST. |
TEST |
validation.configuration.implementations.{propertyName} |
NO | Implementing class of the specified DD4J configuration property.IMPL | ee.test_gov.dd4j.app.common.factory.InMemoryCachingAiaSourceFactory |
validation.configuration.thread-executor.core-pool-size |
NO | Validation executor service core pool size. Defaults to 0 if not specified. |
10 |
validation.configuration.thread-executor.maximum-pool-size |
NO | Validation executor service maximum pool size. Defaults to 1 if not specified. |
100 |
validation.configuration.thread-executor.keep-alive-time |
NO | Validation executor service thread keep-alive time in ISO-8601 duration format PnDTnHnMn.nS. Defaults to 1 minute if not specified. |
PT5M |
IMPL Enables to configure DD4J configuration to use a specific implementation for the specified property.
For example, aiaSourceFactory implementation can be configured as follows:
validation.configuration.implementations.aiaSourceFactory=ee.test_gov.dd4j.app.common.factory.InMemoryCachingAiaSourceFactory.
NB: the specified implementation must have a constructor that takes one org.digidoc4j.Configuration argument!
This example runs the application using the configuration specified in conf/application.yml.
- Build the application JAR
./mvn clean package -DskipTests
- Start the application
java -jar target/dd4j-test-application-0.1.0-SNAPSHOT.jar --spring.config.location=file:conf/application.yml
The application is accessible on http://localhost:8080 .
This example runs the application using the configuration specified in docker-compose.yml.
- Build the Docker image
./mvnw spring-boot:build-image -DskipTests
- Start the application
docker-compose up
The application is accessible on http://localhost:8080 . You can view the logs for all the running containers at http://localhost:9080 .