From 9881edc5a799bab39d1f8d738a10d4af977530d6 Mon Sep 17 00:00:00 2001 From: Martin Vogel <martin.vogel@sinc.de> Date: Thu, 29 Jun 2023 08:13:30 +0200 Subject: [PATCH] Revert "refactor(#664): improve readability" This reverts commit 1d92209fc2e31db06d29385c4dfdc545fb6e1736. --- .../fitconnect/cli/keygen/KeyWriter.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/cli/src/main/java/dev/fitko/fitconnect/cli/keygen/KeyWriter.java b/cli/src/main/java/dev/fitko/fitconnect/cli/keygen/KeyWriter.java index 2869b6b20..84fca0762 100644 --- a/cli/src/main/java/dev/fitko/fitconnect/cli/keygen/KeyWriter.java +++ b/cli/src/main/java/dev/fitko/fitconnect/cli/keygen/KeyWriter.java @@ -63,13 +63,25 @@ public final class KeyWriter { private void writeConfigYamlToFile(final String dir) { + final Map<String, Object> data = new LinkedHashMap<>(); + data.put("senderConfig", + Map.of("clientSecret", "", + "clientId", "")); + data.put("subscriberConfig", + Map.of("clientSecret", "", + "clientId", "", + "privateDecryptionKeyPaths", List.of(Path.of(dir, PRIVATE_DECRYPTION_KEY_NAME).toAbsolutePath().toString()), + "privateSigningKeyPath", Path.of(dir,PRIVATE_SIGNING_KEY_NAME).toAbsolutePath().toString())); + data.put("activeEnvironment", DefaultEnvironments.TEST.getEnvironmentName().getName()); + final DumperOptions options = new DumperOptions(); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setPrettyFlow(true); final StringWriter writer = new StringWriter(); - new Yaml(options).dump(getConfigMap(dir), writer); + final Yaml yaml = new Yaml(options); + yaml.dump(data, writer); writer.flush(); writeFile(Path.of(dir, "config.yml"), writer.toString()); @@ -77,20 +89,6 @@ public final class KeyWriter { LOGGER.info("Wrote config.yml"); } - private static Map<String, Object> getConfigMap(final String dir) { - final Map<String, Object> data = new LinkedHashMap<>(); - data.put("senderConfig", - Map.of("clientSecret", "", - "clientId", "")); - data.put("subscriberConfig", - Map.of("clientSecret", "", - "clientId", "", - "privateDecryptionKeyPaths", List.of(Path.of(dir, PRIVATE_DECRYPTION_KEY_NAME).toAbsolutePath().toString()), - "privateSigningKeyPath", Path.of(dir,PRIVATE_SIGNING_KEY_NAME).toAbsolutePath().toString())); - data.put("activeEnvironment", DefaultEnvironments.TEST.getEnvironmentName().getName()); - return data; - } - private void writeKeyToFile(final String dir, final String filename, final String desc, final JWK jwk) { writeFile(Path.of(dir, filename), jwk.toJSONString()); LOGGER.info("Wrote {} as {}", desc, filename); -- GitLab