From cbde588059ae5996a4c57bfd5c2039f0c1b2d6ec Mon Sep 17 00:00:00 2001 From: Martin Visser Date: Tue, 13 Jun 2023 08:45:20 +0200 Subject: [PATCH] Add codeowners --- CODEOWNERS | 8 ++++++++ .../github/rabobank/shadow_tool/ShadowFlow.java | 16 +++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..eb54340 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,8 @@ +# This is a comment. +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @rabobank/skunkworks will be requested for +# review when someone opens a pull request. +* @rabobank/skunkworks diff --git a/src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java b/src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java index 32d0849..488162d 100644 --- a/src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java +++ b/src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java @@ -33,6 +33,10 @@ public class ShadowFlow { private static final String INSTANCE_PREFIX_FORMAT = "[instance=%s]"; private static final String DEFAULT_INSTANCE_NAME = "default"; private static final String MESSAGE_FORMAT = "{} Calling new flow: {}"; + private static final String DEFAULT_ALGORITHM = "RSA"; + private static final String DEFAULT_ALGORITHM_MODE_PADDING = + DEFAULT_ALGORITHM + "/ECB/OAEPWITHSHA-256ANDMGF1PADDING"; + private final int percentage; private final ExecutorService executorService; private final EncryptionService encryptionService; @@ -45,7 +49,7 @@ public class ShadowFlow { final String instanceName) { this.percentage = percentage; this.encryptionService = encryptionService; - final String nonNullInstanceName = instanceName == null ? DEFAULT_INSTANCE_NAME : instanceName; + final var nonNullInstanceName = instanceName == null ? DEFAULT_INSTANCE_NAME : instanceName; instanceNameLogPrefix = String.format(INSTANCE_PREFIX_FORMAT, nonNullInstanceName); if (executorService != null) { @@ -132,8 +136,7 @@ public Mono compare(final Mono currentFlow, final Mono newFlow) { newFlow.doOnNext(newResponse -> logDifferences(javers.compare(currentResponse, newResponse))) .contextWrite(contextView) .subscribeOn(scheduler) - .subscribe() - ; + .subscribe(); } })); } @@ -257,9 +260,7 @@ public ShadowFlowBuilder withExecutorService(final ExecutorService executorSe */ public ShadowFlowBuilder withEncryption(final PublicKey publicKey) { try { - final String ALGORITHM = "RSA"; - final String ALGORITHM_MODE_PADDING = ALGORITHM + "/ECB/OAEPWITHSHA-256ANDMGF1PADDING"; - final var cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING); + final var cipher = Cipher.getInstance(DEFAULT_ALGORITHM_MODE_PADDING); cipher.init(Cipher.ENCRYPT_MODE, publicKey); withCipher(cipher); } catch (Exception e) { @@ -299,6 +300,7 @@ public ShadowFlowBuilder withInstanceName(final String instanceName) { /** * Build a new ShadowFlow instance. + * * @return New instance of ShadowFlow */ public ShadowFlow build() { @@ -308,7 +310,7 @@ public ShadowFlow build() { private int validatePercentage(final int percentage) { if (percentage < ZERO || percentage > HUNDRED) { logger.error("Invalid percentage! Must be within the range of 0 and 100. Got {}. " + - "The shadow flow will be effectively disabled by setting it to 0%.", percentage); + "The shadow flow will be effectively disabled by setting it to 0%.", percentage); return ZERO; }