From 2ce6d2f5df7bbb1160fdeed8347759f04a9b9d32 Mon Sep 17 00:00:00 2001 From: Martin Vogel <martin.vogel@sinc.de> Date: Thu, 25 Aug 2022 08:55:13 +0200 Subject: [PATCH] refactor(#566): move signing key to global config, since the sender and subscriber are pushing set events now --- .../de/fitko/fitconnect/api/config/ApplicationConfig.java | 1 + .../java/de/fitko/fitconnect/api/config/Subscriber.java | 1 - .../de/fitko/fitconnect/client/factory/ClientFactory.java | 4 ++-- .../de/fitko/fitconnect/client/ClientIntegrationTest.java | 2 +- .../fitko/fitconnect/client/factory/ClientFactoryTest.java | 4 +++- sdk.conf | 6 +++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/de/fitko/fitconnect/api/config/ApplicationConfig.java b/api/src/main/java/de/fitko/fitconnect/api/config/ApplicationConfig.java index df7fb5c7b..e5ba97d3c 100644 --- a/api/src/main/java/de/fitko/fitconnect/api/config/ApplicationConfig.java +++ b/api/src/main/java/de/fitko/fitconnect/api/config/ApplicationConfig.java @@ -9,6 +9,7 @@ public class ApplicationConfig { private Integer httpProxyPort = 0; private Integer requestTimeoutInSeconds; private String metadataSchemaPath; + private String privateSigningKeyPath; private Sender sender; private Subscriber subscriber; diff --git a/api/src/main/java/de/fitko/fitconnect/api/config/Subscriber.java b/api/src/main/java/de/fitko/fitconnect/api/config/Subscriber.java index dd3eef1b9..6d68a9718 100644 --- a/api/src/main/java/de/fitko/fitconnect/api/config/Subscriber.java +++ b/api/src/main/java/de/fitko/fitconnect/api/config/Subscriber.java @@ -8,6 +8,5 @@ public class Subscriber { private String clientId; private String clientSecret; private String privateDecryptionKeyPath; - private String privateSigningKeyPath; private String securityEventTokenSchemaPath; } diff --git a/client/src/main/java/de/fitko/fitconnect/client/factory/ClientFactory.java b/client/src/main/java/de/fitko/fitconnect/client/factory/ClientFactory.java index e7c9f895b..c157b3984 100644 --- a/client/src/main/java/de/fitko/fitconnect/client/factory/ClientFactory.java +++ b/client/src/main/java/de/fitko/fitconnect/client/factory/ClientFactory.java @@ -179,8 +179,8 @@ public class ClientFactory { } private static SecurityEventTokenService getSecurityEventTokenService(final ApplicationConfig config) { - logger.info("Reading private signing key from {} ", config.getSubscriber().getPrivateSigningKeyPath()); - final String signingKey = readPath(config.getSubscriber().getPrivateSigningKeyPath()); + logger.info("Reading private signing key from {} ", config.getPrivateSigningKeyPath()); + final String signingKey = readPath(config.getPrivateSigningKeyPath()); return new SecurityEventTokenService(signingKey); } diff --git a/client/src/test/java/de/fitko/fitconnect/client/ClientIntegrationTest.java b/client/src/test/java/de/fitko/fitconnect/client/ClientIntegrationTest.java index 51e205566..049909a1e 100644 --- a/client/src/test/java/de/fitko/fitconnect/client/ClientIntegrationTest.java +++ b/client/src/test/java/de/fitko/fitconnect/client/ClientIntegrationTest.java @@ -112,7 +112,6 @@ public class ClientIntegrationTest { subscriber.setClientId(System.getenv("SUBSCRIBER_CLIENT_ID")); subscriber.setClientSecret(System.getenv("SUBSCRIBER_CLIENT_SECRET")); subscriber.setPrivateDecryptionKeyPath("src/test/resources/private_decryption_test_key.json"); - subscriber.setPrivateSigningKeyPath("src/test/resources/private_test_signing_key.json"); final var resourcePaths = new ResourcePaths(); resourcePaths.setAuthTokenPath("/token"); @@ -130,6 +129,7 @@ public class ClientIntegrationTest { config.setUsedEnvironment(TEST); config.setResourcePaths(resourcePaths); config.setMetadataSchemaPath("src/test/resources/metadata_schema.json"); + config.setPrivateSigningKeyPath("src/test/resources/private_test_signing_key.json"); return config; } diff --git a/client/src/test/java/de/fitko/fitconnect/client/factory/ClientFactoryTest.java b/client/src/test/java/de/fitko/fitconnect/client/factory/ClientFactoryTest.java index cb34ab68f..af7d628c9 100644 --- a/client/src/test/java/de/fitko/fitconnect/client/factory/ClientFactoryTest.java +++ b/client/src/test/java/de/fitko/fitconnect/client/factory/ClientFactoryTest.java @@ -38,6 +38,8 @@ public class ClientFactoryTest { senderConfig.setSender(sender); senderConfig.setUsedEnvironment(DEV); senderConfig.setResourcePaths(resourcePaths); + senderConfig.setMetadataSchemaPath("src/test/resources/metadata_schema.json"); + senderConfig.setPrivateSigningKeyPath("src/test/resources/private_test_signing_key.json"); assertNotNull(ClientFactory.senderClient(senderConfig)); } @@ -57,7 +59,6 @@ public class ClientFactoryTest { subscriber.setClientSecret("123"); subscriber.setClientSecret("abc"); subscriber.setPrivateDecryptionKeyPath("src/test/resources/private_decryption_test_key.json"); - subscriber.setPrivateSigningKeyPath("src/test/resources/private_test_signing_key.json"); final var subscriberConfig = new ApplicationConfig(); subscriberConfig.setHttpProxyHost("https://proxy.fitco.de"); @@ -67,6 +68,7 @@ public class ClientFactoryTest { subscriberConfig.setUsedEnvironment(DEV); subscriberConfig.setResourcePaths(resourcePaths); subscriberConfig.setMetadataSchemaPath("src/test/resources/metadata_schema.json"); + subscriberConfig.setPrivateSigningKeyPath("src/test/resources/private_test_signing_key.json"); assertNotNull(ClientFactory.subscriberClient(subscriberConfig)); } diff --git a/sdk.conf b/sdk.conf index 3531ec7f2..a09969639 100644 --- a/sdk.conf +++ b/sdk.conf @@ -9,6 +9,9 @@ sdk { # Path that references the metadata schema metadataSchemaPath: "path/to/metadata_schema.json" + # Path that references the signing key file + privateSigningKeyPath: "path/to/singning_key.json" + # switch between the active environments DEV, PROD or TEST usedEnvironment: "DEV" @@ -25,9 +28,6 @@ sdk { # Path that references the private key file privateDecryptionKeyPath: "path/to/decrpytion_key.json" - # Path that references the signing key file - privateSigningKeyPath: "path/to/singning_key.json" - securityEventTokenSchemaPath: "" } -- GitLab