diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 247ee89e..699b83e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,11 @@ jobs: uses: actions/setup-java@v1 with: java-version: '11' + # Spellcheck + - uses: actions/checkout@v2 + - uses: igsekor/pyspelling-any@v0.0.2 - name: Build project with Maven run: | cd java/jtqj mvn install + diff --git a/.spellcheck.yml b/.spellcheck.yml new file mode 100644 index 00000000..53d86aff --- /dev/null +++ b/.spellcheck.yml @@ -0,0 +1,8 @@ +matrix: +- name: Python Source + aspell: + lang: en + d: en_US + sources: + - documentation/* + \ No newline at end of file diff --git a/java/jtqj/api/bin/pom.xml b/java/jtqj/api/bin/pom.xml deleted file mode 100644 index fe04a793..00000000 --- a/java/jtqj/api/bin/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - com.devonfw.java.jtqj - jtqj - v4 - - jtqj-api - jar - ${project.artifactId} - API of the server for the jtqj application (containing datatypes, transfer-objects, and service interfaces). - - - - org.springframework.data - spring-data-commons - - - com.devonfw.java.modules - devon4j-rest - - - com.devonfw.java.modules - devon4j-logging - - - com.devonfw.java.modules - devon4j-security - - - - javax.servlet - javax.servlet-api - provided - - - diff --git a/java/jtqj/api/src/main/java/com/devonfw/application/jtqj/general/service/api/rest/SecurityRestService.java b/java/jtqj/api/src/main/java/com/devonfw/application/jtqj/general/service/api/rest/SecurityRestService.java deleted file mode 100644 index e59a2e96..00000000 --- a/java/jtqj/api/src/main/java/com/devonfw/application/jtqj/general/service/api/rest/SecurityRestService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.devonfw.application.jtqj.general.service.api.rest; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.Context; - -import org.springframework.security.web.csrf.CsrfToken; - -import com.devonfw.module.rest.common.api.RestService; - -import com.devonfw.application.jtqj.general.common.api.to.UserProfileTo; - -/** - * The security REST service provides access to the csrf token, the authenticated user's meta-data. Furthermore, it - * provides functionality to check permissions and roles of the authenticated user. - */ -@Path("/security/v1") -public interface SecurityRestService extends RestService { - - /** - * @param request {@link HttpServletRequest} to retrieve the current session from. - * @param response {@link HttpServletResponse} to send additional information. - * @return the Spring Security {@link CsrfToken} from the server session. - */ - @GET - @Path("/csrftoken/") - CsrfToken getCsrfToken(@Context HttpServletRequest request, @Context HttpServletResponse response); - - /** - * @return the {@link UserProfileTo} of the currently logged-in user. - */ - @GET - @Path("/currentuser/") - UserProfileTo getCurrentUser(); - -} diff --git a/java/jtqj/core/.jtqj1.mv.db b/java/jtqj/core/.jtqj1.mv.db new file mode 100644 index 00000000..edc011cb Binary files /dev/null and b/java/jtqj/core/.jtqj1.mv.db differ diff --git a/java/jtqj/core/bin/pom.xml b/java/jtqj/core/bin/pom.xml deleted file mode 100644 index 78e389ec..00000000 --- a/java/jtqj/core/bin/pom.xml +++ /dev/null @@ -1,233 +0,0 @@ - - 4.0.0 - - com.devonfw.java.jtqj - jtqj - v4 - - jtqj-core - jar - ${project.artifactId} - Core of the server for the jtqj application - a simple example using the Open Application Standard Platform for Java (devon4j). - - - - ${project.groupId} - jtqj-api - ${project.version} - - - - - com.devonfw.java.modules - devon4j-beanmapping - - - - - com.devonfw.java.modules - devon4j-security - - - - com.devonfw.java.modules - devon4j-web - - - - - com.devonfw.java.starters - devon4j-starter-cxf-client-rest - - - - com.devonfw.java.starters - devon4j-starter-cxf-client-ws - - - - - com.devonfw.java.starters - devon4j-starter-cxf-server-rest - - - - com.devonfw.java.starters - devon4j-starter-cxf-server-ws - - - - - com.devonfw.java.starters - devon4j-starter-spring-data-jpa - - - - - org.springframework.boot - spring-boot-starter-jdbc - - - - - javax.persistence - javax.persistence-api - - - - - org.hibernate - hibernate-entitymanager - - - - - com.querydsl - querydsl-jpa - - - com.querydsl - querydsl-apt - provided - - - - - org.hibernate.validator - hibernate-validator - - - - - javax.servlet - javax.servlet-api - provided - - - - - javax.el - javax.el-api - - - - - org.springframework - spring-webmvc - - - - - com.h2database - h2 - - - - - org.flywaydb - flyway-core - - - - - org.apache.cxf - cxf-rt-rs-service-description - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - - org.springframework - spring-aop - - - - - cglib - cglib - - - - - net.logstash.logback - logstash-logback-encoder - - - - - com.devonfw.java.modules - devon4j-test - test - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework.boot - spring-boot-starter-validation - - - - - - org.skyscreamer - jsonassert - test - - - - - - embedded - - true - - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - - - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-jar-plugin - - - config/application.properties - - - - - - - \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/META-INF/cxf/org.apache.cxf.Logger b/java/jtqj/core/bin/src/main/resources/META-INF/cxf/org.apache.cxf.Logger deleted file mode 100644 index 27dd788b..00000000 --- a/java/jtqj/core/bin/src/main/resources/META-INF/cxf/org.apache.cxf.Logger +++ /dev/null @@ -1 +0,0 @@ -org.apache.cxf.common.logging.Slf4jLogger \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/META-INF/orm.xml b/java/jtqj/core/bin/src/main/resources/META-INF/orm.xml deleted file mode 100644 index 55d30ec8..00000000 --- a/java/jtqj/core/bin/src/main/resources/META-INF/orm.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/application.properties b/java/jtqj/core/bin/src/main/resources/application.properties deleted file mode 100644 index 8f4f34a3..00000000 --- a/java/jtqj/core/bin/src/main/resources/application.properties +++ /dev/null @@ -1,32 +0,0 @@ -# This is the configuration file shipped with the application that contains reasonable defaults. -# Environment specific configurations are configured in config/application.properties. -# If you are running in a servlet container you may add this to lib/config/application.properties in case you do not -# want to touch the WAR file. - -# server.port=8080 - -spring.application.name=jtqj -server.servlet.context-path=/ - -security.expose.error.details=false -security.cors.enabled=false -spring.jpa.hibernate.ddl-auto=validate - -# Datasource for accessing the database -# https://github.com/spring-projects/spring-boot/blob/d3c34ee3d1bfd3db4a98678c524e145ef9bca51c/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java -spring.jpa.database=h2 -# spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -# spring.datasource.driver-class-name=org.h2.Driver -spring.datasource.username=sa - -# Hibernate NamingStrategy has been deprecated and then removed in favor of two step naming strategy ImplicitNamingStrategy and PhysicalNamingStrategy -spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - -# to prevent that Spring Boot launches batch jobs on startup -# might otherwise lead to errors if job parameters are needed (or lead to unwanted modifications and longer startup times) -# see http://stackoverflow.com/questions/22318907/how-to-stop-spring-batch-scheduled-jobs-from-running-at-first-time-when-executin -spring.batch.job.enabled=false - -# Flyway for Database Setup and Migrations -spring.flyway.locations=classpath:db/migration,classpath:db/type/h2 diff --git a/java/jtqj/core/bin/src/main/resources/config/app/common/dozer-mapping.xml b/java/jtqj/core/bin/src/main/resources/config/app/common/dozer-mapping.xml deleted file mode 100644 index 15912ec1..00000000 --- a/java/jtqj/core/bin/src/main/resources/config/app/common/dozer-mapping.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - true - - - - java.lang.Long - java.lang.Integer - java.lang.Number - - - - - - - - - com.devonfw.application.jtqj.general.dataaccess.api.ApplicationPersistenceEntity - com.devonfw.module.basic.common.api.to.AbstractEto - - this - persistentEntity - - - diff --git a/java/jtqj/core/bin/src/main/resources/config/app/dataaccess/NamedQueries.xml b/java/jtqj/core/bin/src/main/resources/config/app/dataaccess/NamedQueries.xml deleted file mode 100644 index ee83c8c6..00000000 --- a/java/jtqj/core/bin/src/main/resources/config/app/dataaccess/NamedQueries.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/java/jtqj/core/bin/src/main/resources/config/app/security/access-control-schema.xml b/java/jtqj/core/bin/src/main/resources/config/app/security/access-control-schema.xml deleted file mode 100644 index 418f6ebe..00000000 --- a/java/jtqj/core/bin/src/main/resources/config/app/security/access-control-schema.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/java/jtqj/core/bin/src/main/resources/config/application.properties b/java/jtqj/core/bin/src/main/resources/config/application.properties deleted file mode 100644 index 8fcee568..00000000 --- a/java/jtqj/core/bin/src/main/resources/config/application.properties +++ /dev/null @@ -1,23 +0,0 @@ -# This is the spring boot configuration file for development. It will not be included into the application. -# In order to set specific configurations in a regular installed environment create an according file -# config/application.properties in the server. If you are deploying the application to a servlet container as untouched -# WAR file you can locate this config folder in ${symbol_dollar}{CATALINA_BASE}/lib. If you want to deploy multiple applications to -# the same container (not recommended by default) you need to ensure the WARs are extracted in webapps folder and locate -# the config folder inside the WEB-INF/classes folder of the webapplication. - -server.port=8081 -server.servlet.context-path=/ - -# Datasource for accessing the database -# See https://github.com/devonfw-wiki/devon4j/wiki/guide-configuration#security-configuration -#jasypt.encryptor.password=none -#spring.datasource.password=ENC(7CnHiadYc0Wh2FnWADNjJg==) -spring.datasource.password= -spring.datasource.url=jdbc:h2:./.jtqj; - -# Enable JSON pretty printing -spring.jackson.serialization.INDENT_OUTPUT=true - -# Flyway for Database Setup and Migrations -spring.flyway.enabled=true -spring.flyway.clean-on-validation-error=true diff --git a/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0004__Add_blob_data.sql b/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0004__Add_blob_data.sql deleted file mode 100644 index 574db16c..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0004__Add_blob_data.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO BinaryObject(id, ModificationCounter, filesize, content, mimeType) VALUES (10, 0, 1150 ,'00000100010010100000010020006804000016000000280000001000000020000000010020000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000ECBD48EFECBD48FFECBD48FFECBD48FFECBD48FFECBD48F90000000000000000000000000000000000000000000000000000000000000000ECBD48FAECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FF0000000000000000000000000000000000000000ECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FF000000000000000000000000ECBD48FAECBD48FFFFFFFFFFECBD48FFFFFFFFFFFFFFFFFFEEC35EFFFFFEFDFFFFFFFFFFFFFFFFFFFFFFFFFFEFC86BFFECBD48FFECBD48FF0000000000000000ECBD48FFECBD48FFF4D696FFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FF00000000ECBD48EFECBD48FFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1CB7FFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFFFFFFFFFECBD48FFECBD48FFECBD48F9ECBD48FFECBD48FFECBD48FFFFFFFFFFFFFFFFFFFDF8EFFFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFFFFFFFFFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFECBD48FFECBD48FFECBD4AFFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFFFFFFFFFFEF9F3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFECBD48FFECBD48FFECBD48F9ECBD48FFECBD48FFFFFFFFFFEEC45FFFECBD48FFF1CD7EFFFFFFFFFFFFFFFFFFFFFFFFFFEDC156FFFFFFFFFFFFFFFFFFECBD48FFECBD48FFECBD48EF00000000ECBD48FFECBD48FFFFFFFFFFFEF9F2FFECBD48FFFCF5E8FFFFFFFFFFFFFFFFFFFFFFFFFFECBD48FFFFFFFFFFFFFFFFFFECBD48FFECBD48FF0000000000000000ECBD48FFECBD48FFEFC769FFFFFFFFFFFFFFFFFFFFFFFFFFEEC35EFFEEC25CFFFFFFFFFFFFFFFFFFFFFFFFFFEFC86BFFECBD48FFECBD48FA000000000000000000000000ECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FF0000000000000000000000000000000000000000ECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FFECBD48FA0000000000000000000000000000000000000000000000000000000000000000ECBD48F9ECBD48FFECBD48FFECBD48FFECBD48FFECBD48EF0000000000000000000000000000000000000000F81F0000E0070000C003000080010000800100000000000000000000000000000000000000000000000000008001000080010000C0030000E0070000F81F0000', 'image/vnd.microsoft.icon'); diff --git a/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0008__Master_Data.sql b/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0008__Master_Data.sql deleted file mode 100644 index a6f9eea8..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/migration/1.0/V0008__Master_Data.sql +++ /dev/null @@ -1,24 +0,0 @@ -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (0, 1, 'mike@mail.com', 'test', '1', '123456789', '0', '1', '1'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (1, 1, 'peter@mail.com', 'test', '1', '123456789', '1', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (2, 1, 'pablo@mail.com', 'test', '1', '123456789', '0', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (3, 1, 'test1@mail.com', 'test', '1', '123456789', '0', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (4, 1, 'test2@mail.com', 'test', '1', '123456789', '1', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (5, 1, 'test3@mail.com', 'test', '1', '123456789', '0', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (6, 1, 'test4@mail.com', 'test', '1', '123456789', '0', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (7, 1, 'test5@mail.com', 'test', '1', '123456789', '1', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (8, 1, 'test6@mail.com', 'test', '1', '123456789', '0', '1', '0'); -INSERT INTO Visitor (id, modificationCounter, username, name, password, phoneNumber, acceptedComercial, acceptedTerms, userType) VALUES (9, 1, 'test7@mail.com', 'test', '1', '123456789', '0', '1', '0'); - -INSERT INTO DailyQueue (id, modificationCounter, name, logo, currentNumber, attentionTime, minAttentionTime, active, customers) VALUES (1, 1, 'Day2', 'C:/logos/Day1Logo.png', 'Q001', NULL, '1970-01-01 00:01:00', TRUE, 9); - -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (1, 1, 'Q001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 1, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (2, 1, 'Q002', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 2, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (3, 1, 'Q003', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 3, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (4, 1, 'Q004', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 4, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (5, 1, 'Q005', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 5, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (6, 1, 'Q006', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 6, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (7, 1, 'Q007', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 7, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (8, 1, 'Q008', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 8, 1); -INSERT INTO AccessCode (id, modificationCounter, ticketNumber, creationTime, startTime, endTime, idVisitor, idQueue) VALUES (9, 1, 'Q009', CURRENT_TIMESTAMP, '2008-01-01 00:00:01', NULL, 9, 1); - - diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0001__Create_Sequence.sql deleted file mode 100644 index e54f1e7c..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0001__Create_Sequence.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Leave a large ID space reserved for master-data and test-data -CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000; \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0002__Create_RevInfo.sql deleted file mode 100644 index 8a41c6f9..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,6 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE TABLE RevInfo( - id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1), - "timestamp" BIGINT NOT NULL, - userLogin VARCHAR(255) -); \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0003__Create_BinaryObject.sql deleted file mode 100644 index d91838ce..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,9 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE TABLE BinaryObject ( - id BIGINT NOT NULL AUTO_INCREMENT, - modificationCounter INTEGER NOT NULL, - content BLOB(2147483647), - filesize BIGINT NOT NULL, - mimeType VARCHAR(255), - PRIMARY KEY (ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0005__Create_Visitor.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0005__Create_Visitor.sql deleted file mode 100644 index 5aad959b..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0005__Create_Visitor.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table Visitor( - id BIGINT NOT NULL AUTO_INCREMENT, - modificationCounter INTEGER NOT NULL, - username VARCHAR(255), - name VARCHAR(255) NOT NULL, - lastname VARCHAR(255) NOT NULL, - password VARCHAR(255), - phoneNumber VARCHAR(255), - email VARCHAR(255), - acceptedComercial BOOL DEFAULT '0', - acceptedTerms BOOL NOT NULL DEFAULT '0', - userType BOOL DEFAULT '0', - CONSTRAINT PK_Visitor PRIMARY KEY(id), -); \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0006__Create_Queue.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0006__Create_Queue.sql deleted file mode 100644 index 69e13555..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0006__Create_Queue.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table DailyQueue( - id BIGINT NOT NULL AUTO_INCREMENT, - modificationCounter INTEGER NOT NULL, - name VARCHAR(255), - logo VARCHAR(255), - currentNumber VARCHAR(255), - attentionTime TIMESTAMP, - minAttentionTime TIMESTAMP NOT NULL DEFAULT '60000', - active BOOL NOT NULL DEFAULT '1', - customers INTEGER NOT NULL DEFAULT '0', - CONSTRAINT PK_DailyQueue PRIMARY KEY(id), -); \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql b/java/jtqj/core/bin/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql deleted file mode 100644 index bf74f610..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE AccessCode( - id BIGINT NOT NULL AUTO_INCREMENT, - modificationCounter INTEGER NOT NULL, - ticketNumber VARCHAR(5), - creationTime TIMESTAMP, - startTime TIMESTAMP, - endTime TIMESTAMP, - idVisitor BIGINT NOT NULL, - idQueue BIGINT NOT NULL, - CONSTRAINT PK_AccessCode PRIMARY KEY(id), - CONSTRAINT FK_AccessCode_idVisitor FOREIGN KEY(idVisitor) REFERENCES Visitor(id), - CONSTRAINT FK_AccessCode_idQueue FOREIGN KEY(idQueue) REFERENCES DailyQueue(id), -); \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/hana/V0001__Create_Sequence.sql deleted file mode 100644 index 49953d2c..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0001__Create_Sequence.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Leave a large ID space reserved for master-data and test-data -CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000; - --- hana does not support Dateadd function out of the box so we add it here to be able to use it for master-data SQLs -CREATE FUNCTION DATEADD(IN DATETYPE NVARCHAR(256), IN NUMBER INTEGER, IN TS TIMESTAMP) -RETURNS TSADD TIMESTAMP -AS -BEGIN - IF :DATETYPE = 'DAY' - THEN - TSADD = ADD_DAYS(:TS, :NUMBER); - ELSEIF :DATETYPE = 'HOUR' - THEN - TSADD = ADD_SECONDS(:TS, :NUMBER * 3600); - ELSE - SIGNAL SQL_ERROR_CODE 10000 SET MESSAGE_TEXT = 'Unsupported date type: ' || :DATETYPE; - END IF; -END; \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/hana/V0002__Create_RevInfo.sql deleted file mode 100644 index 38b650b3..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,7 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE COLUMN TABLE RevInfo( - id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1), - "timestamp" BIGINT NOT NULL, - userLogin VARCHAR(255), - PRIMARY KEY (ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/hana/V0003__Create_BinaryObject.sql deleted file mode 100644 index 6463189d..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/hana/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,9 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE COLUMN TABLE BinaryObject ( - id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY, - modificationCounter INTEGER NOT NULL, - content BLOB, - filesize BIGINT NOT NULL, - mimeType VARCHAR(255), - CONSTRAINT PK_BinaryObject_id PRIMARY KEY(ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0001__Create_Sequence.sql deleted file mode 100644 index 80704fad..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0001__Create_Sequence.sql +++ /dev/null @@ -1 +0,0 @@ --- no sequences are used in MS-SQL Server instead use IDENTITY(«seed»,1) for every ID diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0002__Create_RevInfo.sql deleted file mode 100644 index ceae13d0..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,6 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE TABLE REVINFO( - id BIGINT NOT NULL IDENTITY(1,1), - timestamp BIGINT NOT NULL, - userLogin VARCHAR(255) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0003__Create_BinaryObject.sql deleted file mode 100644 index 4a454bee..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mssql/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,9 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE TABLE BINARYOBJECT ( - id BIGINT NOT NULL IDENTITY(10,1), - modificationCounter INTEGER NOT NULL, - content varbinary(max), - filesize BIGINT NOT NULL, - mimeType VARCHAR(255), - PRIMARY KEY (ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0001__Create_Sequence.sql deleted file mode 100644 index c5da8cf7..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0001__Create_Sequence.sql +++ /dev/null @@ -1 +0,0 @@ --- no sequences are used in MySQL/MariaDB instead use AUTO_INCREMENT for every ID diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0002__Create_RevInfo.sql deleted file mode 100644 index a9590a2b..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,6 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE TABLE REVINFO( - id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, - timestamp BIGINT NOT NULL, - userLogin VARCHAR(255) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0003__Create_BinaryObject.sql deleted file mode 100644 index ff7ca5f7..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/mysql/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,8 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE TABLE BINARYOBJECT ( - id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, - modificationCounter INT NOT NULL, - content LONGBLOB, - filesize BIGINT NOT NULL, - mimeType VARCHAR(255) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0001__Create_Sequence.sql deleted file mode 100644 index 22104389..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0001__Create_Sequence.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Leave a large ID space reserved for master-data and test-data -CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000; diff --git a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0002__Create_RevInfo.sql deleted file mode 100644 index a459bf24..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,7 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE TABLE RevInfo ( - id NUMBER(19), - "timestamp" NUMBER(19,0), - userLogin VARCHAR2(255 CHAR), - CONSTRAINT PK_RevInfo_id PRIMARY KEY (id) -); \ No newline at end of file diff --git a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0003__Create_BinaryObject.sql deleted file mode 100644 index e5635f1b..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/oracle/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,9 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE TABLE BinaryObject ( - id NUMBER(19), - modificationCounter NUMBER(10, 0) NOT NULL, - content BLOB, - filesize NUMBER(10, 0) NOT NULL, - mimeType VARCHAR(255), - CONSTRAINT PK_BinaryObject_id PRIMARY KEY (ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0001__Create_Sequence.sql b/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0001__Create_Sequence.sql deleted file mode 100644 index 22104389..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0001__Create_Sequence.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Leave a large ID space reserved for master-data and test-data -CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000; diff --git a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0002__Create_RevInfo.sql b/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0002__Create_RevInfo.sql deleted file mode 100644 index b6c8663c..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0002__Create_RevInfo.sql +++ /dev/null @@ -1,6 +0,0 @@ --- *** RevInfo (Commit log for envers audit trail) *** -CREATE TABLE REVINFO( - id BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - userLogin VARCHAR(255) -); diff --git a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0003__Create_BinaryObject.sql b/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0003__Create_BinaryObject.sql deleted file mode 100644 index 54bb1614..00000000 --- a/java/jtqj/core/bin/src/main/resources/db/type/postgresql/V0003__Create_BinaryObject.sql +++ /dev/null @@ -1,9 +0,0 @@ --- *** BinaryObject (BLOBs) *** -CREATE TABLE BINARYOBJECT ( - id BIGSERIAL NOT NULL, - modificationCounter INTEGER NOT NULL, - content BYTEA, - filesize BIGINT NOT NULL, - mimeType VARCHAR(255), - PRIMARY KEY (ID) -); diff --git a/java/jtqj/core/bin/src/main/resources/static/index.html b/java/jtqj/core/bin/src/main/resources/static/index.html deleted file mode 100644 index 88b7063e..00000000 --- a/java/jtqj/core/bin/src/main/resources/static/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -Welcome - - -

Welcome

- This is a test! -
- Services Overview (CXF) -
-
- -
- -
- - \ No newline at end of file diff --git a/java/jtqj/core/bin/src/test/resources/config/application.properties b/java/jtqj/core/bin/src/test/resources/config/application.properties deleted file mode 100644 index 47b72ef4..00000000 --- a/java/jtqj/core/bin/src/test/resources/config/application.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This is the spring boot configuration file for JUnit tests. It will only affect JUnits and is not included into the application. -spring.profiles.active=junit - -# Database and JPA -spring.jpa.database=h2 -spring.datasource.url=jdbc:h2:mem:app; -spring.datasource.password= -spring.datasource.username=sa -spring.jpa.hibernate.ddl-auto=none - -# Flyway for Database Setup and Migrations -spring.flyway.enabled=true -spring.flyway.locations=classpath:db/migration,classpath:db/type/h2 diff --git a/java/jtqj/core/pom.xml b/java/jtqj/core/pom.xml index 78e389ec..36f7b11c 100644 --- a/java/jtqj/core/pom.xml +++ b/java/jtqj/core/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 com.devonfw.java.jtqj @@ -20,7 +20,7 @@ com.devonfw.java.modules - devon4j-beanmapping + devon4j-beanmapping-dozer @@ -29,6 +29,17 @@ devon4j-security + + com.devonfw.java.starters + devon4j-starter-security-cors + + + + com.devonfw.java.starters + devon4j-starter-security-csrf + + + com.devonfw.java.modules devon4j-web @@ -153,7 +164,7 @@ cglib cglib - + net.logstash.logback @@ -163,7 +174,7 @@ com.devonfw.java.modules - devon4j-test + devon4j-test-junit4 test diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/SpringBootApp.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/SpringBootApp.java index 184a2d8c..4d2a1349 100644 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/SpringBootApp.java +++ b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/SpringBootApp.java @@ -2,18 +2,15 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import com.devonfw.module.jpa.dataaccess.api.AdvancedRevisionEntity; import com.devonfw.module.jpa.dataaccess.impl.data.GenericRepositoryFactoryBean; /** * Main entry point of this {@link SpringBootApplication}. Simply run this class to start this app. */ @SpringBootApplication -@EntityScan(basePackages = { "com.devonfw.application.jtqj" }, basePackageClasses = { AdvancedRevisionEntity.class }) @EnableJpaRepositories(repositoryFactoryBeanClass = GenericRepositoryFactoryBean.class) @EnableGlobalMethodSecurity(jsr250Enabled = true) public class SpringBootApp { diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/ApplicationObjectMapperFactory.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/ApplicationObjectMapperFactory.java index 83f2c1db..ec29db47 100644 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/ApplicationObjectMapperFactory.java +++ b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/ApplicationObjectMapperFactory.java @@ -3,13 +3,11 @@ import javax.inject.Named; import org.springframework.data.domain.Pageable; -import org.springframework.security.web.csrf.CsrfToken; - -import com.fasterxml.jackson.databind.module.SimpleModule; import com.devonfw.module.json.common.base.ObjectMapperFactory; -import com.devonfw.module.json.common.base.type.PageableJsonSerializer; import com.devonfw.module.json.common.base.type.PageableJsonDeserializer; +import com.devonfw.module.json.common.base.type.PageableJsonSerializer; +import com.fasterxml.jackson.databind.module.SimpleModule; /** * The MappingFactory class to resolve polymorphic conflicts within the jtqj application. @@ -25,8 +23,7 @@ public ApplicationObjectMapperFactory() { super(); // see https://github.com/devonfw-wiki/devon4j/wiki/guide-json#json-and-inheritance SimpleModule module = getExtensionModule(); - module.addAbstractTypeMapping(CsrfToken.class, CsrfTokenImpl.class); - // register spring-data Pageable + // register spring-data Pageable module.addSerializer(Pageable.class, new PageableJsonSerializer()); module.addDeserializer(Pageable.class, new PageableJsonDeserializer()); } diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/CsrfTokenImpl.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/CsrfTokenImpl.java deleted file mode 100644 index 920a3b02..00000000 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/config/CsrfTokenImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.devonfw.application.jtqj.general.common.impl.config; - -import org.springframework.security.web.csrf.CsrfToken; - -/** - * Implementation of {@link CsrfToken} as Java bean for JSON deserialization. - */ -public class CsrfTokenImpl implements CsrfToken { - - private static final long serialVersionUID = 1L; - - private String headerName; - - private String parameterName; - - private String token; - - @Override - public String getHeaderName() { - - return this.headerName; - } - - @Override - public String getParameterName() { - - return this.parameterName; - } - - @Override - public String getToken() { - - return this.token; - } - - /** - * @param headerName new value of {@link #getHeaderName()}. - */ - public void setHeaderName(String headerName) { - - this.headerName = headerName; - } - - /** - * @param parameterName new value of {@link #getParameterName()}. - */ - public void setParameterName(String parameterName) { - - this.parameterName = parameterName; - } - - /** - * @param token new value of {@link #getToken()}. - */ - public void setToken(String token) { - - this.token = token; - } - -} diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/security/CsrfRequestMatcher.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/security/CsrfRequestMatcher.java deleted file mode 100644 index 44c4a15c..00000000 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/common/impl/security/CsrfRequestMatcher.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.devonfw.application.jtqj.general.common.impl.security; - -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.security.web.util.matcher.RequestMatcher; - -/** - * This is the implementation of {@link RequestMatcher}, which decides which {@link HttpServletRequest Requests} require - * a correct CSRF token. - * - * @see Cross-site request forgery - */ -public class CsrfRequestMatcher implements RequestMatcher { - - private static final Pattern HTTP_METHOD_PATTERN = Pattern.compile("^GET$"); - - private static final String[] PATH_PREFIXES_WITHOUT_CSRF_PROTECTION = - { "/login", "/logout", "/services/rest/login", "/websocket" }; - - @Override - public boolean matches(HttpServletRequest request) { - - // GET requests are read-only and therefore do not need CSRF protection - if (HTTP_METHOD_PATTERN.matcher(request.getMethod()).matches()) { - - return false; - } - - // There are specific URLs which can not be protected from CSRF. For example, in case of the the login page, - // the CSRF token can only be accessed after a successful authentication ("login"). - String requestPath = getRequestPath(request); - for (String path : PATH_PREFIXES_WITHOUT_CSRF_PROTECTION) { - if (requestPath.startsWith(path)) { - return false; - } - } - - return true; - } - - private String getRequestPath(HttpServletRequest request) { - - String url = request.getServletPath(); - String pathInfo = request.getPathInfo(); - - if (pathInfo != null) { - url += pathInfo; - } - - return url; - } -} diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/LoginController.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/LoginController.java deleted file mode 100644 index b74ce4df..00000000 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/LoginController.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.devonfw.application.jtqj.general.service.impl; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for Login-Page. - */ -@Controller -public class LoginController { - - /** - * Default URL to redirect to after successfully login. - */ - public final static String defaultTargetUrl = "/"; - - /** - * Builds the model for the login page---mainly focusing on the error message handling. - * - * @param authentication_failed flag for authentication failed - * @param invalid_session flag for invalid session - * @param access_denied flag for access denied - * @param logout flag for successful logout - * @return the view model - */ - @RequestMapping(value = "/login**", method = {RequestMethod.GET,RequestMethod.POST}) - public ModelAndView login( - @RequestParam(value = "authentication_failed", required = false) boolean authentication_failed, - @RequestParam(value = "invalid_session", required = false) boolean invalid_session, - @RequestParam(value = "access_denied", required = false) boolean access_denied, - @RequestParam(value = "logout", required = false) boolean logout) { - - final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (!authentication.getPrincipal().equals("anonymousUser")) { - return new ModelAndView("redirect:" + defaultTargetUrl); - } - - ModelAndView model = new ModelAndView(); - if (authentication_failed) { - model.addObject("error", "Authentication failed!"); - } else if (invalid_session) { - model.addObject("error", "You are currently not logged in!"); - } else if (access_denied) { - model.addObject("error", "You have insufficient permissions to access this page!"); - } else if (logout) { - model.addObject("msg", "Logout successful!"); - } - - return model; - } - -} diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/BaseWebSecurityConfig.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/BaseWebSecurityConfig.java index c210b1f6..7f18b64b 100644 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/BaseWebSecurityConfig.java +++ b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/BaseWebSecurityConfig.java @@ -3,7 +3,6 @@ import javax.inject.Inject; import javax.servlet.Filter; -import org.springframework.beans.factory.annotation.Value; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @@ -14,13 +13,9 @@ import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; -import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; -import com.devonfw.application.jtqj.general.common.impl.security.CsrfRequestMatcher; +import com.devonfw.module.security.common.api.config.WebSecurityConfigurer; import com.devonfw.module.security.common.impl.rest.AuthenticationSuccessHandlerSendingOkHttpStatusCode; import com.devonfw.module.security.common.impl.rest.JsonUsernamePasswordAuthenticationFilter; import com.devonfw.module.security.common.impl.rest.LogoutSuccessHandlerReturningOkHttpStatusCode; @@ -33,32 +28,14 @@ */ public abstract class BaseWebSecurityConfig extends WebSecurityConfigurerAdapter { - @Value("${security.cors.enabled}") - boolean corsEnabled = false; - @Inject private UserDetailsService userDetailsService; @Inject private PasswordEncoder passwordEncoder; - private CorsFilter getCorsFilter() { - - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - CorsConfiguration config = new CorsConfiguration(); - config.setAllowCredentials(true); - config.addAllowedOrigin("*"); - config.addAllowedHeader("*"); - config.addAllowedMethod("OPTIONS"); - config.addAllowedMethod("HEAD"); - config.addAllowedMethod("GET"); - config.addAllowedMethod("PUT"); - config.addAllowedMethod("POST"); - config.addAllowedMethod("DELETE"); - config.addAllowedMethod("PATCH"); - source.registerCorsConfiguration("/**", config); - return new CorsFilter(source); - } + @Inject + private WebSecurityConfigurer webSecurityConfigurer; /** * Configure spring security to enable a simple webform-login + a simple rest login. @@ -69,31 +46,25 @@ public void configure(HttpSecurity http) throws Exception { String[] unsecuredResources = new String[] { "/login", "/security/**", "/services/rest/login", "/services/rest/logout" }; - /**http + // disable CSRF protection by default, use csrf starter to override. + http = http.csrf().disable(); + // load starters as pluggins. + http = this.webSecurityConfigurer.configure(http); + + http // .userDetailsService(this.userDetailsService) // define all urls that are not to be secured .authorizeRequests().antMatchers(unsecuredResources).permitAll().anyRequest().authenticated().and() - - // activate crsf check for a selection of urls (but not for login & logout) - .csrf().requireCsrfProtectionMatcher(new CsrfRequestMatcher()).and() - // configure parameters for simple form login (and logout) .formLogin().successHandler(new SimpleUrlAuthenticationSuccessHandler()).defaultSuccessUrl("/") .failureUrl("/login.html?error").loginProcessingUrl("/j_spring_security_login").usernameParameter("username") .passwordParameter("password").and() // logout via POST is possible .logout().logoutSuccessUrl("/login.html").and() - // register login and logout filter that handles rest logins .addFilterAfter(getSimpleRestAuthenticationFilter(), BasicAuthenticationFilter.class) - .addFilterAfter(getSimpleRestLogoutFilter(), LogoutFilter.class);*/ - - http.authorizeRequests().anyRequest().permitAll().and().csrf().disable(); - - if (this.corsEnabled) { - http.addFilterBefore(getCorsFilter(), CsrfFilter.class); - } + .addFilterAfter(getSimpleRestLogoutFilter(), LogoutFilter.class); } /** @@ -124,8 +95,8 @@ protected JsonUsernamePasswordAuthenticationFilter getSimpleRestAuthenticationFi JsonUsernamePasswordAuthenticationFilter jsonFilter = new JsonUsernamePasswordAuthenticationFilter( new AntPathRequestMatcher("/services/rest/login")); - jsonFilter.setPasswordParameter("j_password"); - jsonFilter.setUsernameParameter("j_username"); + jsonFilter.setPasswordParameter("password"); + jsonFilter.setUsernameParameter("username"); jsonFilter.setAuthenticationManager(authenticationManager()); // set failurehandler that uses no redirect in case of login failure; just HTTP-status: 401 jsonFilter.setAuthenticationManager(authenticationManagerBean()); @@ -139,10 +110,7 @@ protected JsonUsernamePasswordAuthenticationFilter getSimpleRestAuthenticationFi @Inject public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication().withUser("waiter").password(this.passwordEncoder.encode("waiter")).roles("Waiter") - .and().withUser("cook").password(this.passwordEncoder.encode("cook")).roles("Cook").and().withUser("barkeeper") - .password(this.passwordEncoder.encode("barkeeper")).roles("Barkeeper").and().withUser("chief") - .password(this.passwordEncoder.encode("chief")).roles("Chief"); + auth.inMemoryAuthentication().withUser("admin").password(this.passwordEncoder.encode("admin")).roles("Admin"); } } diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebConfig.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebConfig.java index 711f0ba0..f4a25b46 100644 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebConfig.java +++ b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebConfig.java @@ -1,7 +1,5 @@ package com.devonfw.application.jtqj.general.service.impl.config; -import javax.servlet.Filter; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.boot.web.servlet.FilterRegistrationBean; @@ -28,10 +26,10 @@ public class WebConfig { * with their duration and status code. */ @Bean - public FilterRegistrationBean performanceLogFilter() { + public FilterRegistrationBean performanceLogFilter() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - Filter performanceLogFilter = new PerformanceLogFilter(); + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + PerformanceLogFilter performanceLogFilter = new PerformanceLogFilter(); this.beanFactory.autowireBean(performanceLogFilter); registration.setFilter(performanceLogFilter); registration.addUrlPatterns("/*"); @@ -52,10 +50,10 @@ public DiagnosticContextFacade diagnosticContextFacade() { * correlation id as MDC so it will be included in all associated logs. */ @Bean - public FilterRegistrationBean diagnosticContextFilter() { + public FilterRegistrationBean diagnosticContextFilter() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - Filter diagnosticContextFilter = new DiagnosticContextFilter(); + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + DiagnosticContextFilter diagnosticContextFilter = new DiagnosticContextFilter(); this.beanFactory.autowireBean(diagnosticContextFilter); registration.setFilter(diagnosticContextFilter); registration.addUrlPatterns(ServiceConstants.URL_PATH_SERVICES + "/*"); @@ -66,9 +64,9 @@ public FilterRegistrationBean diagnosticContextFilter() { * @return the {@link FilterRegistrationBean} to register the {@link CharacterEncodingFilter} to set the encoding. */ @Bean - public FilterRegistrationBean setCharacterEncodingFilter() { + public FilterRegistrationBean setCharacterEncodingFilter() { - FilterRegistrationBean registration = new FilterRegistrationBean(); + FilterRegistrationBean registration = new FilterRegistrationBean<>(); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(false); diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebSecurityBeansConfig.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebSecurityBeansConfig.java index 17cfcdde..0b00b52a 100644 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebSecurityBeansConfig.java +++ b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/config/WebSecurityBeansConfig.java @@ -20,6 +20,18 @@ @Configuration public class WebSecurityBeansConfig { + + /** + * This method provides a new instance of {@code CsrfTokenRepository} + * + * @return the newly created {@code CsrfTokenRepository} + */ + @Bean + public CsrfTokenRepository csrfTokenRepository() { + + return new HttpSessionCsrfTokenRepository(); + } + /** * This method provides a new instance of {@code AccessControlProvider} * @@ -42,16 +54,6 @@ public AccessControlSchemaProvider accessControlSchemaProvider() { return new AccessControlSchemaProviderImpl(); } - /** - * This method provides a new instance of {@code CsrfTokenRepository} - * - * @return the newly created {@code CsrfTokenRepository} - */ - @Bean - public CsrfTokenRepository csrfTokenRepository() { - - return new HttpSessionCsrfTokenRepository(); - } /** * This method provides a new instance of {@code DefaultRolesPrefixPostProcessor} diff --git a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImpl.java b/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImpl.java deleted file mode 100644 index e8a12487..00000000 --- a/java/jtqj/core/src/main/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.devonfw.application.jtqj.general.service.impl.rest; - -import javax.annotation.security.PermitAll; -import javax.inject.Inject; -import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.transaction.Transactional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.web.csrf.CsrfToken; -import org.springframework.security.web.csrf.CsrfTokenRepository; - -import com.devonfw.application.jtqj.general.common.api.exception.NoActiveUserException; -import com.devonfw.application.jtqj.general.common.api.to.UserProfileTo; -import com.devonfw.application.jtqj.general.service.api.rest.SecurityRestService; - -/** - * Implementation of {@link SecurityRestService}. - */ -@Named -@Transactional -public class SecurityRestServiceImpl implements SecurityRestService { - - /** Logger instance. */ - private static final Logger LOG = LoggerFactory.getLogger(SecurityRestServiceImpl.class); - - /** - * Use {@link CsrfTokenRepository} for CSRF protection. - */ - private CsrfTokenRepository csrfTokenRepository; - - @Override - @PermitAll - public CsrfToken getCsrfToken(HttpServletRequest request, HttpServletResponse response) { - - CsrfToken token = this.csrfTokenRepository.loadToken(request); - if (token == null) { - LOG.error("No CsrfToken could be found - instantiating a new Token"); - token = this.csrfTokenRepository.generateToken(request); - this.csrfTokenRepository.saveToken(token, request, response); - } - return token; - } - - @Override - @PermitAll - public UserProfileTo getCurrentUser() { - - SecurityContext context = SecurityContextHolder.getContext(); - Authentication authentication = null; - if (context != null) { - authentication = context.getAuthentication(); - } - if (authentication == null) { - throw new NoActiveUserException(); - } - UserDetails user = (UserDetails) authentication.getPrincipal(); - UserProfileTo profile = new UserProfileTo(); - profile.setLogin(user.getUsername()); - return profile; - } - - /** - * @param csrfTokenRepository the csrfTokenRepository to set - */ - @Inject - public void setCsrfTokenRepository(CsrfTokenRepository csrfTokenRepository) { - - this.csrfTokenRepository = csrfTokenRepository; - } -} diff --git a/java/jtqj/core/src/main/resources/application.properties b/java/jtqj/core/src/main/resources/application.properties index 7c876cb3..46c02fda 100644 --- a/java/jtqj/core/src/main/resources/application.properties +++ b/java/jtqj/core/src/main/resources/application.properties @@ -30,3 +30,10 @@ spring.batch.job.enabled=false # Flyway for Database Setup and Migrations spring.flyway.locations=classpath:db/migration,classpath:db/type/h2 + +#CORS support +security.cors.spring.allowCredentials=true +security.cors.spring.allowedOriginPatterns=* +security.cors.spring.allowedHeaders=* +security.cors.spring.allowedMethods=OPTIONS,HEAD,GET,PUT,POST,DELETE,PATCH +security.cors.pathPattern=/** \ No newline at end of file diff --git a/java/jtqj/core/src/main/resources/config/application.properties b/java/jtqj/core/src/main/resources/config/application.properties index 20a24d93..9a172822 100644 --- a/java/jtqj/core/src/main/resources/config/application.properties +++ b/java/jtqj/core/src/main/resources/config/application.properties @@ -13,7 +13,7 @@ server.servlet.context-path=/jumpthequeue #jasypt.encryptor.password=none #spring.datasource.password=ENC(7CnHiadYc0Wh2FnWADNjJg==) spring.datasource.password= -spring.datasource.url=jdbc:h2:./.jtqj; +spring.datasource.url=jdbc:h2:./.jtqj1; # Enable JSON pretty printing spring.jackson.serialization.INDENT_OUTPUT=true @@ -21,3 +21,10 @@ spring.jackson.serialization.INDENT_OUTPUT=true # Flyway for Database Setup and Migrations spring.flyway.enabled=true spring.flyway.clean-on-validation-error=true + +#CORS support +security.cors.spring.allowCredentials=true +security.cors.spring.allowedOriginPatterns=* +security.cors.spring.allowedHeaders=* +security.cors.spring.allowedMethods=OPTIONS,HEAD,GET,PUT,POST,DELETE,PATCH +security.cors.pathPattern=/** \ No newline at end of file diff --git a/java/jtqj/core/src/main/resources/db/type/h2/V0005__Create_Visitor.sql b/java/jtqj/core/src/main/resources/db/type/h2/V0005__Create_Visitor.sql index 71b47d10..eaf25a5d 100644 --- a/java/jtqj/core/src/main/resources/db/type/h2/V0005__Create_Visitor.sql +++ b/java/jtqj/core/src/main/resources/db/type/h2/V0005__Create_Visitor.sql @@ -8,5 +8,5 @@ create table Visitor( acceptedCommercial BOOL DEFAULT '0', acceptedTerms BOOL NOT NULL DEFAULT '0', userType BOOL DEFAULT '0', - CONSTRAINT PK_Visitor PRIMARY KEY(id), + CONSTRAINT PK_Visitor PRIMARY KEY(id) ); \ No newline at end of file diff --git a/java/jtqj/core/src/main/resources/db/type/h2/V0006__Create_Queue.sql b/java/jtqj/core/src/main/resources/db/type/h2/V0006__Create_Queue.sql index 69e13555..0c8725a7 100644 --- a/java/jtqj/core/src/main/resources/db/type/h2/V0006__Create_Queue.sql +++ b/java/jtqj/core/src/main/resources/db/type/h2/V0006__Create_Queue.sql @@ -8,5 +8,5 @@ create table DailyQueue( minAttentionTime TIMESTAMP NOT NULL DEFAULT '60000', active BOOL NOT NULL DEFAULT '1', customers INTEGER NOT NULL DEFAULT '0', - CONSTRAINT PK_DailyQueue PRIMARY KEY(id), + CONSTRAINT PK_DailyQueue PRIMARY KEY(id) ); \ No newline at end of file diff --git a/java/jtqj/core/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql b/java/jtqj/core/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql index bf74f610..df3f5f71 100644 --- a/java/jtqj/core/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql +++ b/java/jtqj/core/src/main/resources/db/type/h2/V0007__Create_Access_Code.sql @@ -9,5 +9,5 @@ CREATE TABLE AccessCode( idQueue BIGINT NOT NULL, CONSTRAINT PK_AccessCode PRIMARY KEY(id), CONSTRAINT FK_AccessCode_idVisitor FOREIGN KEY(idVisitor) REFERENCES Visitor(id), - CONSTRAINT FK_AccessCode_idQueue FOREIGN KEY(idQueue) REFERENCES DailyQueue(id), + CONSTRAINT FK_AccessCode_idQueue FOREIGN KEY(idQueue) REFERENCES DailyQueue(id) ); \ No newline at end of file diff --git a/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/common/base/test/DbTestHelper.java b/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/common/base/test/DbTestHelper.java index 2c0badb0..a9369895 100644 --- a/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/common/base/test/DbTestHelper.java +++ b/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/common/base/test/DbTestHelper.java @@ -3,7 +3,6 @@ import javax.inject.Named; import org.flywaydb.core.Flyway; -import org.flywaydb.core.api.MigrationVersion; /** * This class provides methods for handling the database during testing where resets (and other operations) may be @@ -14,14 +13,13 @@ public class DbTestHelper { private Flyway flyway; - private MigrationVersion migrationVersion; - /** * The constructor. * * @param flyway an instance of type {@link Flyway}. */ public DbTestHelper(Flyway flyway) { + super(); this.flyway = flyway; } @@ -41,20 +39,6 @@ public void dropDatabase() { public void resetDatabase() { dropDatabase(); - if (this.migrationVersion != null) { - this.flyway.setTarget(this.migrationVersion); - } this.flyway.migrate(); } - - /** - * This method sets the internal value of the {@code migrationVersion}. - * - * @param migrationVersion new {@code String} value of {@code migrationVersion}. Must not be null - */ - public void setMigrationVersion(String migrationVersion) { - - this.migrationVersion = MigrationVersion.fromVersion(migrationVersion); - } - } diff --git a/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImplTest.java b/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImplTest.java deleted file mode 100644 index 64508e08..00000000 --- a/java/jtqj/core/src/test/java/com/devonfw/application/jtqj/general/service/impl/rest/SecurityRestServiceImplTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.devonfw.application.jtqj.general.service.impl.rest; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.web.csrf.CsrfToken; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.client.RestTemplate; - -import com.devonfw.application.jtqj.general.common.api.to.UserProfileTo; -import com.devonfw.application.jtqj.general.service.api.rest.SecurityRestService; -import com.devonfw.application.jtqj.general.service.base.test.RestServiceTest; -import com.devonfw.module.service.common.api.client.config.ServiceClientConfigBuilder; - -/** - * This class tests the login functionality of {@link SecurityRestServiceImpl}. - */ -@RunWith(SpringRunner.class) -public class SecurityRestServiceImplTest extends RestServiceTest { - - /** Logger instance. */ - private static final Logger LOG = LoggerFactory.getLogger(SecurityRestServiceImplTest.class); - - /** - * Test the login functionality as it will be used from a JavaScript client. - */ - @Test - @Ignore // Temporarily this test is failing so ignored - public void testLogin() { - - String login = "waiter"; - String password = "waiter"; - - ResponseEntity postResponse = login(login, password); - LOG.debug("Body: " + postResponse.getBody()); - assertThat(postResponse.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(postResponse.getHeaders().containsKey(HttpHeaders.SET_COOKIE)).isTrue(); - } - - /** - * Test of {@code SecurityRestService.getCsrfToken()}. - */ - @Test - public void testGetCsrfToken() { - - String login = "waiter"; - String password = "waiter"; - SecurityRestService securityService = getServiceClientFactory().create(SecurityRestService.class, - new ServiceClientConfigBuilder().host("localhost").authBasic().userLogin(login).userPassword(password) - .buildMap()); - CsrfToken csrfToken = securityService.getCsrfToken(null, null); - assertThat(csrfToken.getHeaderName()).isEqualTo("X-CSRF-TOKEN"); - assertThat(csrfToken.getParameterName()).isEqualTo("_csrf"); - assertThat(csrfToken.getToken()).isNotNull(); - LOG.debug("Csrf Token: {}", csrfToken.getToken()); - } - - /** - * Test of {@link SecurityRestService#getCurrentUser()}. - */ - @Test - public void testGetCurrentUser() { - - String login = "waiter"; - String password = "waiter"; - SecurityRestService securityService = getServiceClientFactory().create(SecurityRestService.class, - new ServiceClientConfigBuilder().host("localhost").authBasic().userLogin(login).userPassword(password) - .buildMap()); - UserProfileTo userProfile = securityService.getCurrentUser(); - assertThat(userProfile.getLogin()).isEqualTo(login); - } - - /** - * Performs the login as required by a JavaScript client. - * - * @param userName the username of the user - * @param tmpPassword the password of the user - * @return @ {@link ResponseEntity} containing containing a cookie in its header. - */ - private ResponseEntity login(String userName, String tmpPassword) { - - String tmpUrl = "http://localhost:" + String.valueOf(this.port) + "/services/rest/login"; - - HttpEntity postRequest = new HttpEntity<>( - "{\"j_username\": \"" + userName + "\", \"j_password\": \"" + tmpPassword + "\"}", new HttpHeaders()); - - ResponseEntity postResponse = new RestTemplate().exchange(tmpUrl, HttpMethod.POST, postRequest, - String.class); - return postResponse; - } - -} diff --git a/java/jtqj/pom.xml b/java/jtqj/pom.xml index 9ab83e70..e21a4fbb 100644 --- a/java/jtqj/pom.xml +++ b/java/jtqj/pom.xml @@ -8,13 +8,13 @@ Application based on the Open Application Standard Platform for Java (devon4j). - 2.1.6.RELEASE - 3.1.1 + 2.4.4 + 2021.04.002 1.8 UTF-8 UTF-8 com.devonfw.module.test.common.api.category.CategorySystemTest - 2.9.9.20190727 + 2.12.2 @@ -316,7 +316,7 @@ systemtest - + @@ -482,4 +482,4 @@ - + \ No newline at end of file diff --git a/java/jtqj/server/bin/pom.xml b/java/jtqj/server/bin/pom.xml deleted file mode 100644 index 1dab7321..00000000 --- a/java/jtqj/server/bin/pom.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - 4.0.0 - - com.devonfw.java.jtqj - jtqj - v4 - - jtqj-server - war - ${project.artifactId} - Server for the jtqj application - a simple example using the Open Application Standard Platform for Java (devon4j). - - - 1.8 - - - - - ${project.groupId} - jtqj-core - ${project.version} - - - - - - jsclient - - - false - - - - - org.codehaus.mojo - exec-maven-plugin - - - npm-install - generate-sources - - exec - - - npm - - install - - ${js.client.dir} - - - - gulp-clean - generate-sources - - exec - - - gulp - - clean - - ${js.client.dir} - - - - gulp-build - generate-sources - - exec - - - gulp - - build:dist - - ${js.client.dir} - - - - gulp-test - test - - exec - - - gulp - - test - - ${js.client.dir} - - - - - - org.apache.maven.plugins - maven-war-plugin - - WEB-INF/classes/config/application.properties - ${project.artifactId} - false - - - - - - - - - - - ${project.basedir}/src/main/resources - - - ${js.client.dir}/dist - static - - - - - org.springframework.boot - spring-boot-maven-plugin - - com.devonfw.application.jtqj.SpringBootApp - bootified - ${project.artifactId} - - - - - repackage - - - - - - - - - diff --git a/java/jtqj/server/bin/src/main/resources/logback.xml b/java/jtqj/server/bin/src/main/resources/logback.xml deleted file mode 100644 index cb0e3a5b..00000000 --- a/java/jtqj/server/bin/src/main/resources/logback.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - false - correlationId - - timestamp - [ignore] - [ignore] - -      {"appname":"jtqj"} - UTC - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/java/jtqj/src/main/java/com/devonfw/application/jtqj/SpringBootBatchApp.java b/java/jtqj/src/main/java/com/devonfw/application/jtqj/SpringBootBatchApp.java deleted file mode 100644 index 20215de7..00000000 --- a/java/jtqj/src/main/java/com/devonfw/application/jtqj/SpringBootBatchApp.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.devonfw.application.jtqj; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; -import org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; - -import com.devonfw.module.jpa.dataaccess.api.AdvancedRevisionEntity; - -/** - * {@link SpringBootApplication} for running this batch. - */ -@SpringBootApplication(exclude = { EndpointAutoConfiguration.class, SecurityAutoConfiguration.class, -SecurityFilterAutoConfiguration.class, }) -@EntityScan(basePackages = { "com.devonfw.application.jtqj" }, basePackageClasses = { AdvancedRevisionEntity.class }) -@EnableGlobalMethodSecurity(jsr250Enabled = false) -public class SpringBootBatchApp { - - /** - * Entry point for spring-boot based app - * - * @param args - arguments - */ - public static void main(String[] args) { - - SpringApplication.run(SpringBootBatchApp.class, args); - } -} diff --git a/java/jtqj/src/main/java/com/devonfw/application/jtqj/general/batch/impl/config/BeansBatchConfig.java b/java/jtqj/src/main/java/com/devonfw/application/jtqj/general/batch/impl/config/BeansBatchConfig.java deleted file mode 100644 index 273e8f85..00000000 --- a/java/jtqj/src/main/java/com/devonfw/application/jtqj/general/batch/impl/config/BeansBatchConfig.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.devonfw.application.jtqj.general.batch.impl.config; - -import javax.inject.Inject; -import javax.sql.DataSource; - -import org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor; -import org.springframework.batch.core.configuration.support.MapJobRegistry; -import org.springframework.batch.core.explore.support.JobExplorerFactoryBean; -import org.springframework.batch.core.launch.support.RunIdIncrementer; -import org.springframework.batch.core.launch.support.SimpleJobOperator; -import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; -import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.transaction.PlatformTransactionManager; - -/** - * This class contains the configuration like jobLauncher,Jobrepository etc. - */ -import com.devonfw.module.batch.common.impl.JobLauncherWithAdditionalRestartCapabilities; - -/** - * This class contains configuration of batch beans. - */ -@Configuration -public class BeansBatchConfig { - - private JobRepositoryFactoryBean jobRepository; - - private MapJobRegistry jobRegistry; - - private JobLauncherWithAdditionalRestartCapabilities jobLauncher; - - private JobExplorerFactoryBean jobExplorer; - - private DataSource dataSource; - - private PlatformTransactionManager transactionManager; - - @Value("ISOLATION_DEFAULT") - private String isolationLevelForCreate; - - /** - * This method is creating joboperator bean - * - * @return SimpleJobOperator - */ - @Bean - @DependsOn({ "jobRepository", "jobExplorer", "jobRegistry", "jobLauncher" }) - public SimpleJobOperator jobOperator() { - - SimpleJobOperator jobOperator = new SimpleJobOperator(); - try { - jobOperator.setJobExplorer(this.jobExplorer.getObject()); - } catch (Exception e) { - throw new BeanCreationException("Could not create BatchJobOperator", e); - } - - jobOperator.setJobLauncher(this.jobLauncher); - jobOperator.setJobRegistry(this.jobRegistry); - - try { - jobOperator.setJobRepository(this.jobRepository.getObject()); - } catch (Exception e) { - throw new BeanCreationException("Could not create BatchJobOperator", e); - } - - return jobOperator; - } - - /** - * This method is creating jobrepository - * - * @return JobRepositoryFactoryBean - */ - @Bean(name = "jobRepository") - public JobRepositoryFactoryBean jobRepository() { - - this.jobRepository = new JobRepositoryFactoryBean(); - this.jobRepository.setDataSource(this.dataSource); - this.jobRepository.setTransactionManager(this.transactionManager); - this.jobRepository.setIsolationLevelForCreate(this.isolationLevelForCreate); - return this.jobRepository; - } - - /** - * This method is creating jobLauncher bean - * - * @return SimpleJobLauncher - */ - @Bean - @DependsOn("jobRepository") - public JobLauncherWithAdditionalRestartCapabilities jobLauncher() { - - this.jobLauncher = new JobLauncherWithAdditionalRestartCapabilities(); - - try { - this.jobLauncher.setJobRepository(this.jobRepository.getObject()); - } catch (Exception e) { - throw new BeanCreationException("Could not create BatchJobOperator", e); - } - - return this.jobLauncher; - } - - /** - * This method is creating jobExplorer bean - * - * @return JobExplorerFactoryBean - */ - @Bean - @DependsOn("dataSource") - public JobExplorerFactoryBean jobExplorer() { - - this.jobExplorer = new JobExplorerFactoryBean(); - this.jobExplorer.setDataSource(this.dataSource); - return this.jobExplorer; - } - - /** - * This method is creating jobRegistry bean - * - * @return MapJobRegistry - */ - @Bean - public MapJobRegistry jobRegistry() { - - this.jobRegistry = new MapJobRegistry(); - return this.jobRegistry; - } - - /** - * This method is creating JobRegistryBeanPostProcessor - * - * @return JobRegistryBeanPostProcessor - */ - @Bean - @DependsOn("jobRegistry") - public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor() { - - JobRegistryBeanPostProcessor postProcessor = new JobRegistryBeanPostProcessor(); - postProcessor.setJobRegistry(this.jobRegistry); - return postProcessor; - } - - /** - * This method is creating incrementer - * - * @return RunIdIncrementer - */ - @Bean - public RunIdIncrementer incrementer() { - - return new RunIdIncrementer(); - } - - /** - * @return datasource - */ - public DataSource getDataSource() { - - return this.dataSource; - } - - /** - * @param datasource the datasource to set - */ - @Inject - public void setDataSource(DataSource datasource) { - - this.dataSource = datasource; - } - - /** - * @return transactionManager - */ - public PlatformTransactionManager getTransactionManager() { - - return this.transactionManager; - } - - /** - * @param transactionManager the transactionManager to set - */ - @Inject - public void setTransactionManager(PlatformTransactionManager transactionManager) { - - this.transactionManager = transactionManager; - } - -} diff --git a/java/jtqj/src/main/resources/db/migration/h2/V0002__Add_batch_tables.sql b/java/jtqj/src/main/resources/db/migration/h2/V0002__Add_batch_tables.sql deleted file mode 100644 index 980d37d4..00000000 --- a/java/jtqj/src/main/resources/db/migration/h2/V0002__Add_batch_tables.sql +++ /dev/null @@ -1,81 +0,0 @@ --- Autogenerated: do not edit this file - -CREATE TABLE BATCH_JOB_INSTANCE ( - JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , - VERSION BIGINT , - JOB_NAME VARCHAR(100) NOT NULL, - JOB_KEY VARCHAR(32) NOT NULL, - constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY) -) ; - -CREATE TABLE BATCH_JOB_EXECUTION ( - JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , - VERSION BIGINT , - JOB_INSTANCE_ID BIGINT NOT NULL, - CREATE_TIME TIMESTAMP NOT NULL, - START_TIME TIMESTAMP DEFAULT NULL , - END_TIME TIMESTAMP DEFAULT NULL , - STATUS VARCHAR(10) , - EXIT_CODE VARCHAR(2500) , - EXIT_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP, - JOB_CONFIGURATION_LOCATION VARCHAR(2500) NULL, - constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID) - references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID) -) ; - -CREATE TABLE BATCH_JOB_EXECUTION_PARAMS ( - JOB_EXECUTION_ID BIGINT NOT NULL , - TYPE_CD VARCHAR(6) NOT NULL , - KEY_NAME VARCHAR(100) NOT NULL , - STRING_VAL VARCHAR(250) , - DATE_VAL TIMESTAMP DEFAULT NULL , - LONG_VAL BIGINT , - DOUBLE_VAL DOUBLE PRECISION , - IDENTIFYING CHAR(1) NOT NULL , - constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) - references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) -) ; - -CREATE TABLE BATCH_STEP_EXECUTION ( - STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , - VERSION BIGINT NOT NULL, - STEP_NAME VARCHAR(100) NOT NULL, - JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , - END_TIME TIMESTAMP DEFAULT NULL , - STATUS VARCHAR(10) , - COMMIT_COUNT BIGINT , - READ_COUNT BIGINT , - FILTER_COUNT BIGINT , - WRITE_COUNT BIGINT , - READ_SKIP_COUNT BIGINT , - WRITE_SKIP_COUNT BIGINT , - PROCESS_SKIP_COUNT BIGINT , - ROLLBACK_COUNT BIGINT , - EXIT_CODE VARCHAR(2500) , - EXIT_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP, - constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID) - references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) -) ; - -CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT ( - STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, - SHORT_CONTEXT VARCHAR(2500) NOT NULL, - SERIALIZED_CONTEXT LONGVARCHAR , - constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID) - references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID) -) ; - -CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT ( - JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, - SHORT_CONTEXT VARCHAR(2500) NOT NULL, - SERIALIZED_CONTEXT LONGVARCHAR , - constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID) - references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) -) ; - -CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ; -CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ; -CREATE SEQUENCE BATCH_JOB_SEQ; diff --git a/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/batch/base/test/SpringBatchIntegrationTest.java b/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/batch/base/test/SpringBatchIntegrationTest.java deleted file mode 100644 index 36ed053d..00000000 --- a/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/batch/base/test/SpringBatchIntegrationTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.devonfw.application.jtqj.general.batch.base.test; - -import javax.inject.Inject; - -import org.flywaydb.core.Flyway; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.batch.core.Job; -import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.test.JobLauncherTestUtils; - -import com.devonfw.application.jtqj.general.common.base.test.TestUtil; -import com.devonfw.module.test.common.base.ComponentTest; - -/** - * Base class for all spring batch integration tests. It helps to do End-to-End job tests. - */ -public abstract class SpringBatchIntegrationTest extends ComponentTest { - - @Inject - private JobLauncher jobLauncher; - - @Inject - private Flyway flyway; - - @Override - protected void doSetUp() { - - super.doSetUp(); - this.flyway.clean(); - this.flyway.migrate(); - } - - @Override - protected void doTearDown() { - - super.doTearDown(); - TestUtil.logout(); - } - - /** - * @param job job to configure - * @return jobLauncherTestUtils - */ - public JobLauncherTestUtils getJobLauncherTestUtils(Job job) { - - JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils(); - jobLauncherTestUtils.setJob(job); - jobLauncherTestUtils.setJobLauncher(this.jobLauncher); - - return jobLauncherTestUtils; - } -} diff --git a/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/common/base/test/TestUtil.java b/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/common/base/test/TestUtil.java deleted file mode 100644 index 3c91ea6f..00000000 --- a/java/jtqj/src/test/java/com/devonfw/application/jtqj/general/common/base/test/TestUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.devonfw.application.jtqj.general.common.base.test; - -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; - -/** - * This is a utility for testing. It allows to simulate authentication for component testing. - */ -public class TestUtil { - - /** - * @param login the id of the user to run the test as. - * @param permissions the permissions for the test. - */ - public static void login(String login, String... permissions) { - - Authentication authentication = new TestingAuthenticationToken(login, login, permissions); - SecurityContextHolder.getContext().setAuthentication(authentication); - } - - /** - * Logs off any previously logged on user. - */ - public static void logout() { - - SecurityContextHolder.getContext().setAuthentication(null); - } -}