OpenBank - Jakarta EE 8 (Spring 5 and Spring Boot 2 integration included)
A demonstration of an simple bank application made with Jakarta Enterprise Edition 8 platform (Java EE) for the backend part and with Angular 7 for the frontend part.
Table of contents
- Requirements
- UML Diagram generation
- Java EE 7+ Stack related to code
- Installation
- Start OpenBank
- Test RESTful/SOAP contracts
- Start the client
- Administrate Wildly application server
- Run just the integration tests
- Run unit and system tests with coverage
- Force check code coverage by number of lines for all Java classes
- Generate encrypted property password
- Run the OpenBank with plain text passwords or with encrypted passwords locally
- Deliver new OpenBank Jakarta EE image
- Generate encrypted TRAVIS CI environment variables
Requirements
To be able to compile and run the OpenBank application the following dependicies are required:
To run application without Docker:
- Maven version 3.6.0 or newer
- JDK 11 or newer
- NodeJS version 10.15.3 or newer
- Angular CLI version 7.3.6 or newer
- Wildfly version 16.0.0 or newer
To run application with Docker:
- Docker Engine version 18.09.2 or later is recommended
UML Diagram generation
By default, uml diagrams are generated by the build setup and stored at the root diagrams directory.
Generate the graphvis dot files to pdf by the command:
find . -type f -name "*.dot" -exec sh -c 'dot -Tpdf "${0}" -o "${0%.*}.pdf"' {} \;
Java EE 7+ Stack related to code
Context and Dependency Injection
Context
Dependency injection
Dependent Injected EntityManager
Interceptor and Produces
Scopes
Bean Validation
Contraints and Validation
Java Persistence API (JPA)
Entity
Quering entity
Perstistence Unit
Persistence Context
Object-Relational Mapping
Attributes and Access Type Annotations
Annotations that can be applied to both field and method.
Table Annotation
Primary Key Annotation
Column Annotation
Enumerated Annotation
Relational Mapping
Inheritance Mapping
Managing Persistence Objects
Obtaining an EntityManager
Save an Entity
JPQL and Named Queries
Enterprise JavaBeans
Stateless EJB
Transactions (Required, Supports)
Enterprise JavaBeans are required by default.
Required transaction
Supported transaction
Messaging
Java Messaging Service API
Message-Driven Bean as Asyncronous JMSContext Consumer
SOAP Web Service
RESTful Web Service
Dynamic Injection Point Interceptor
To be able to dynamically add Interceptor annotation to all Java CDI beans not included in the excluded list.
DynamicEjbInjectionPointInterceptor
Installation
Prepare the environment
Before installing the application in a Docker environment, you will need to source the openbank_setup.sh file so the encrypted property values are decrypted and properly set when building the image. (Windows users needs Cyqwin to be able to execute the bash script.)
source openbank_setup.sh
With Docker compose
mvn clean install
docker-compose build --no-cache
Clean up Docker images and containers
Sometimes it is nessesary to clean up images and containers to be able to run OpenBank because of little memory space left and even hard disk space left, only execute this commands below if the regular Docker command give errors.
docker rm -vf $(docker ps -a -q) # Clean up containers
docker rmi -f $(docker images -a -q) # Clean up all images
Start OpenBank
With Docker compose
docker-compose up
Test RESTful/SOAP contracts
RESTful testing
Load the generated openbankAPI.yaml file with the http://editor.swagger.io/ editor to easily test the RESTful contracts after successful installation. Be sure to use basic authorization with --user user:pass flag to use the RESTful operations successfully.
Example:
curl --user john:doe -X GET "http://localhost:8080/restful-webservice/api/client/info/191212121212" \
-H "accept: application/json"
For the Spring war package the following OpenApi v2 json file gets generated at OpenBankAPIv1.json
SOAP testing
SOAP contracts (Service) is tested through http://localhost:8080/soap-webservice endpoint with SoapUI utility
Start the client
Goto http://localhost:8080/client/openbank and basic authorization is simplest to test through the Chrome browser.
Administrate Wildly application server
Run just the integration tests
mvn clean install
docker build -t openbank .
mvn clean install -Pintegrationtests
Run unit and system tests with coverage
mvn clean install -Pgenerate-coverage
Force check code coverage by number of lines for all Java classes
Code coverage by lines must be at least 50 %
mvn clean install -Pcoverage-check
Generate encrypted property password
The demonstration how to generate encrypted password with help of master password, master password shall never be stored in the repository along with any unencrypted passwords to maintain good security.
java -cp ~/.m2/repository/org/jasypt/jasypt/1.9.3/jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI \
input="obpassword" password=my_secret_password algorithm=PBEWithMD5AndDES
Run the OpenBank with plain text passwords or with encrypted passwords locally
# Execute the OpenBank with plain text passwords
mvn clean install -T 1C -DskipTests && source openbank_setup_local.sh && docker-compose -f docker-compose_local.yaml up --build --force-recreate
# Execute the OpenBank with encrypted password, MASTER_KEY environment variable must be set
mvn clean install -T 1C -DskipTests && source openbank_setup_prod.sh && docker-compose -f docker-compose_prod.yaml up --build --force-recreate
Deliver new OpenBank Jakarta EE image
# Make sure you are logged in to the DockerHub before releasing a new latest image tag
docker build -f Dockerfile -t openbank-jee .
docker tag openbank-jee:latest jsquadab/openbank-jee:latest
docker push jsquadab/openbank-jee:latest
Generate encrypted TRAVIS CI environment variables
travis encrypt VARIABLE_A=VALUE_1 MASTER_SECRET=VALUE_2 --add