From 49d2897075f4fdf31d373c7274111e9a902d5ef9 Mon Sep 17 00:00:00 2001 From: wisskirchenj Date: Mon, 24 Jul 2023 01:04:24 +0200 Subject: [PATCH] import ResourcesRegistrar to run on https --- build.gradle.kts | 7 ---- .../account/AccountReactiveApplication.java | 2 + .../cofinpro/account/ResourcesRegistrar.java | 15 +++++++ src/main/resources/application.properties | 12 ++++++ src/main/resources/initData.sql | 4 ++ src/main/resources/initTables.sql | 38 +++++++++++++++++ src/main/resources/schema.sql | 42 ------------------- src/test/resources/application.properties | 9 ++++ 8 files changed, 80 insertions(+), 49 deletions(-) create mode 100644 src/main/java/de/cofinpro/account/ResourcesRegistrar.java create mode 100644 src/main/resources/initData.sql create mode 100644 src/main/resources/initTables.sql delete mode 100644 src/main/resources/schema.sql diff --git a/build.gradle.kts b/build.gradle.kts index 57a2f96..aba6369 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,13 +23,6 @@ configurations { } } -graalvmNative { - binaries.all { - resources.autodetect() - } - toolchainDetection = false -} - repositories { mavenCentral() } diff --git a/src/main/java/de/cofinpro/account/AccountReactiveApplication.java b/src/main/java/de/cofinpro/account/AccountReactiveApplication.java index b4b3993..a744e46 100644 --- a/src/main/java/de/cofinpro/account/AccountReactiveApplication.java +++ b/src/main/java/de/cofinpro/account/AccountReactiveApplication.java @@ -13,8 +13,10 @@ import org.springframework.aot.hint.annotation.RegisterReflectionForBinding; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ImportRuntimeHints; @SpringBootApplication +@ImportRuntimeHints({ResourcesRegistrar.class}) @RegisterReflectionForBinding({SignupRequest.class, SignupResponse.class, ChangepassRequest.class, diff --git a/src/main/java/de/cofinpro/account/ResourcesRegistrar.java b/src/main/java/de/cofinpro/account/ResourcesRegistrar.java new file mode 100644 index 0000000..d020e94 --- /dev/null +++ b/src/main/java/de/cofinpro/account/ResourcesRegistrar.java @@ -0,0 +1,15 @@ +package de.cofinpro.account; + +import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.lang.NonNull; + +public class ResourcesRegistrar implements RuntimeHintsRegistrar { + + @Override + public void registerHints(@NonNull RuntimeHints hints, ClassLoader classLoader) { + hints.resources() + .registerPattern("keystore/*.p12") + .registerPattern("*.sql"); + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b1c326a..2fefb4b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -11,5 +11,17 @@ spring.r2dbc.password=password spring.jpa.show-sql=true spring.sql.init.mode=always +spring.sql.init.schema-locations=classpath:initTables.sql +spring.sql.init.data-locations=classpath:initData.sql server.error.include-message=always + +server.ssl.enabled=true +# Keystore format +server.ssl.key-store-type=PKCS12 +# The path to the keystore +server.ssl.key-store=classpath:keystore/service.p12 +# Certificate password +server.ssl.key-store-password=service +# Certificate alias +server.ssl.key-alias=accountant_service \ No newline at end of file diff --git a/src/main/resources/initData.sql b/src/main/resources/initData.sql new file mode 100644 index 0000000..7dd44ba --- /dev/null +++ b/src/main/resources/initData.sql @@ -0,0 +1,4 @@ + INSERT INTO ROLES (USER_ROLE) VALUES ('ROLE_ADMINISTRATOR'); + INSERT INTO ROLES (USER_ROLE) VALUES ('ROLE_USER'); + INSERT INTO ROLES (USER_ROLE) VALUES ('ROLE_ACCOUNTANT'); + INSERT INTO ROLES (USER_ROLE) VALUES ('ROLE_AUDITOR'); \ No newline at end of file diff --git a/src/main/resources/initTables.sql b/src/main/resources/initTables.sql new file mode 100644 index 0000000..32a32b2 --- /dev/null +++ b/src/main/resources/initTables.sql @@ -0,0 +1,38 @@ +DROP TABLE IF EXISTS ROLES; +CREATE TABLE IF NOT EXISTS LOGIN +( + id BIGSERIAL PRIMARY KEY NOT NULL, + name VARCHAR(64), + lastname VARCHAR(64), + email VARCHAR(64) UNIQUE NOT NULL, + password VARCHAR(128) NOT NULL, + account_locked BOOL NOT NULL, + failed_logins SMALLINT +); +CREATE TABLE IF NOT EXISTS SALARY +( + id BIGSERIAL PRIMARY KEY NOT NULL, + email VARCHAR(64) NOT NULL, + period VARCHAR(7) NOT NULL, + salary BIGINT NOT NULL +); +CREATE TABLE IF NOT EXISTS ROLES +( + id BIGSERIAL PRIMARY KEY NOT NULL, + user_role VARCHAR(20) UNIQUE NOT NULL +); +CREATE TABLE IF NOT EXISTS LOGIN_ROLES +( + id BIGSERIAL PRIMARY KEY NOT NULL, + email VARCHAR(64) NOT NULL, + user_role VARCHAR(20) NOT NULL +); +CREATE TABLE IF NOT EXISTS AUDIT +( + id BIGSERIAL PRIMARY KEY NOT NULL, + date DATE NOT NULL, + action VARCHAR(20) NOT NULL, + subject VARCHAR(64), + object VARCHAR(128), + path VARCHAR(64) NOT NULL +); \ No newline at end of file diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql deleted file mode 100644 index 8802045..0000000 --- a/src/main/resources/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ -DROP TABLE IF EXISTS ROLES; -CREATE TABLE IF NOT EXISTS LOGIN ( - id BIGSERIAL PRIMARY KEY NOT NULL, - name VARCHAR (64), - lastname VARCHAR (64), - email VARCHAR (64) UNIQUE NOT NULL, - password VARCHAR (128) NOT NULL, - account_locked BOOL NOT NULL, - failed_logins SMALLINT -); -CREATE TABLE IF NOT EXISTS SALARY ( - id BIGSERIAL PRIMARY KEY NOT NULL, - email VARCHAR (64) NOT NULL, - period VARCHAR (7) NOT NULL, - salary BIGINT NOT NULL -); -CREATE TABLE IF NOT EXISTS ROLES ( - id BIGSERIAL PRIMARY KEY NOT NULL, - user_role VARCHAR (20) UNIQUE NOT NULL -); -CREATE TABLE IF NOT EXISTS LOGIN_ROLES ( - id BIGSERIAL PRIMARY KEY NOT NULL, - email VARCHAR (64) NOT NULL, - user_role VARCHAR(20) NOT NULL -); -CREATE TABLE IF NOT EXISTS AUDIT -( - id BIGSERIAL PRIMARY KEY NOT NULL, - date DATE NOT NULL, - action VARCHAR(20) NOT NULL, - subject VARCHAR(64), - object VARCHAR(128), - path VARCHAR(64) NOT NULL -); -INSERT INTO ROLES (USER_ROLE) -VALUES ('ROLE_ADMINISTRATOR'); -INSERT INTO ROLES (USER_ROLE) -VALUES ('ROLE_USER'); -INSERT INTO ROLES (USER_ROLE) -VALUES ('ROLE_ACCOUNTANT'); -INSERT INTO ROLES (USER_ROLE) -VALUES ('ROLE_AUDITOR'); \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 62cc379..af74c88 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -10,3 +10,12 @@ spring.sql.init.mode=always spring.sql.init.schema-locations=classpath:initTables.sql spring.sql.init.data-locations=classpath:initData.sql server.error.include-message=always +server.ssl.enabled=true +# Keystore format +server.ssl.key-store-type=PKCS12 +# The path to the keystore +server.ssl.key-store=classpath:keystore/service.p12 +# Certificate password +server.ssl.key-store-password=service +# Certificate alias +server.ssl.key-alias=accountant_service \ No newline at end of file