Skip to content

jsquad-consulting/openbank-jee

Repository files navigation

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.

Build Status

Table of contents

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

Singleton Enterprise JavaBean

Dependency injection

Injected Logger

Dependent Injected EntityManager

Interceptor and Produces

Logger Producer

Interceptor Logger

Scopes

Dependent EntityManager

Bean Validation

Contraints and Validation

ClientValidator

Java Persistence API (JPA)

Entity

Client Entity

Quering entity

Client

Perstistence Unit

Persistence Unit Definition

Persistence Context

Persistence Context

Object-Relational Mapping

Attributes and Access Type Annotations

Annotations that can be applied to both field and method.

Table Annotation

Table

Primary Key Annotation

Primary Key

Column Annotation

Column

Enumerated Annotation

Enumerated

Relational Mapping

OneToOne

OneToMany

ManyToOne

ManyToMany

Inheritance Mapping

Single Table Inheritance

Managing Persistence Objects

Obtaining an EntityManager

EntityManager

Save an Entity

Persist

JPQL and Named Queries

Named Query

Enterprise JavaBeans

Stateless EJB

AccountTransactionEJB

Transactions (Required, Supports)

Enterprise JavaBeans are required by default.

Required transaction

Transaction.Required

Supported transaction

Transaction.Supports

Messaging

Java Messaging Service API

JMSContext as Producer

Message-Driven Bean as Asyncronous JMSContext Consumer

Message-Driven Bean

SOAP Web Service

GetClientWS

RESTful Web Service

ClientInformationRest

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:https://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:https://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:https://localhost:8080/soap-webservice endpoint with SoapUI utility GetClient

Start the client

Goto http:https://localhost:8080/client/openbank and basic authorization is simplest to test through the Chrome browser.

Administrate Wildly application server

http:https://localhost:8080/console

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

Annex