Skip to content

Commit

Permalink
import ResourcesRegistrar to run on https
Browse files Browse the repository at this point in the history
  • Loading branch information
wisskirchenj committed Jul 23, 2023
1 parent 70ad56b commit 49d2897
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 49 deletions.
7 changes: 0 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ configurations {
}
}

graalvmNative {
binaries.all {
resources.autodetect()
}
toolchainDetection = false
}

repositories {
mavenCentral()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/de/cofinpro/account/ResourcesRegistrar.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
12 changes: 12 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/main/resources/initData.sql
Original file line number Diff line number Diff line change
@@ -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');
38 changes: 38 additions & 0 deletions src/main/resources/initTables.sql
Original file line number Diff line number Diff line change
@@ -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
);
42 changes: 0 additions & 42 deletions src/main/resources/schema.sql

This file was deleted.

9 changes: 9 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 49d2897

Please sign in to comment.