summaryrefslogtreecommitdiffstats
path: root/trustStoreMerger/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'trustStoreMerger/src/main')
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java1
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/api/ConfigurationEnvs.java26
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/file/TruststoresPathsProvider.java25
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java10
4 files changed, 48 insertions, 14 deletions
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java
index ee57b3aa..3a3b9b6e 100644
--- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java
+++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java
@@ -24,7 +24,6 @@ import org.onap.oom.truststoremerger.api.ExitableException;
import org.onap.oom.truststoremerger.certification.file.EnvProvider;
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider;
import org.onap.oom.truststoremerger.configuration.MergerConfiguration;
-import org.onap.oom.truststoremerger.configuration.MergerConfigurationException;
import org.onap.oom.truststoremerger.configuration.MergerConfigurationFactory;
import org.onap.oom.truststoremerger.certification.file.PathValidator;
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/api/ConfigurationEnvs.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/api/ConfigurationEnvs.java
new file mode 100644
index 00000000..13c8c726
--- /dev/null
+++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/api/ConfigurationEnvs.java
@@ -0,0 +1,26 @@
+/*============LICENSE_START=======================================================
+ * oom-truststore-merger
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.oom.truststoremerger.api;
+
+public class ConfigurationEnvs {
+
+ public static final String TRUSTSTORES_ENV = "TRUSTSTORES";
+ public static final String TRUSTSTORES_PASSWORDS_ENV = "TRUSTSTORES_PASSWORDS";
+}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/file/TruststoresPathsProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/file/TruststoresPathsProvider.java
index b7b73e6b..e23a1add 100644
--- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/file/TruststoresPathsProvider.java
+++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/file/TruststoresPathsProvider.java
@@ -19,14 +19,15 @@
package org.onap.oom.truststoremerger.certification.file;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_ENV;
+
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
public class TruststoresPathsProvider {
- static final String TRUSTSTORES_ENV = "TRUSTSTORES";
- static final String TRUSTSTORES_PASSWORDS_ENV = "TRUSTSTORES_PASSWORDS";
private static final String DELIMITER = ":";
private static final int NEGATIVE_SPLIT_LIMIT = -1;
@@ -40,27 +41,29 @@ public class TruststoresPathsProvider {
public List<String> getTruststores() throws TruststoresPathsProviderException {
return envProvider.getEnv(TRUSTSTORES_ENV)
- .filter(Predicate.not(String::isEmpty))
- .map(this::splitToList)
- .filter(this::validateTruststores)
- .orElseThrow(() -> new TruststoresPathsProviderException("TRUSTSTORES environment variable does not contain valid truststores paths"));
+ .filter(Predicate.not(String::isEmpty))
+ .map(this::splitToList)
+ .filter(this::validateTruststores)
+ .orElseThrow(() -> new TruststoresPathsProviderException(
+ TRUSTSTORES_ENV + " environment variable does not contain valid truststores paths"));
}
public List<String> getTruststoresPasswords() throws TruststoresPathsProviderException {
return envProvider.getEnv(TRUSTSTORES_PASSWORDS_ENV)
- .map(this::splitToList)
- .filter(this::validateTruststoresPasswords)
- .orElseThrow(() -> new TruststoresPathsProviderException("TRUSTSTORES_PASSWORDS environment variable does not contain valid passwords paths"));
+ .map(this::splitToList)
+ .filter(this::validateTruststoresPasswords)
+ .orElseThrow(() -> new TruststoresPathsProviderException(
+ TRUSTSTORES_PASSWORDS_ENV + " environment variable does not contain valid passwords paths"));
}
private boolean validateTruststores(List<String> truststores) {
return truststores.stream()
- .allMatch(pathValidator::isTruststorePathValid);
+ .allMatch(pathValidator::isTruststorePathValid);
}
private boolean validateTruststoresPasswords(List<String> truststoresPasswords) {
return truststoresPasswords.stream()
- .allMatch(pathValidator::isTruststorePasswordPathValid);
+ .allMatch(pathValidator::isTruststorePasswordPathValid);
}
private List<String> splitToList(String stringToSplit) {
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java
index eea0551d..fa0b8cde 100644
--- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java
+++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java
@@ -22,6 +22,9 @@ package org.onap.oom.truststoremerger.configuration;
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider;
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProviderException;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_ENV;
+
import java.util.List;
public class MergerConfigurationFactory {
@@ -32,12 +35,15 @@ public class MergerConfigurationFactory {
this.pathsProvider = pathsProvider;
}
- public MergerConfiguration createConfiguration() throws MergerConfigurationException, TruststoresPathsProviderException {
+ public MergerConfiguration createConfiguration()
+ throws MergerConfigurationException, TruststoresPathsProviderException {
List<String> truststores = pathsProvider.getTruststores();
List<String> truststoresPasswords = pathsProvider.getTruststoresPasswords();
if (truststores.size() != truststoresPasswords.size()) {
- throw new MergerConfigurationException("Size of TRUSTSTORES does not match size of TRUSTSTORES_PASSWORDS environment variables");
+ throw new MergerConfigurationException(
+ "Size of " + TRUSTSTORES_ENV
+ + " does not match size of " + TRUSTSTORES_PASSWORDS_ENV + " environment variables");
}
return new MergerConfiguration(truststores, truststoresPasswords);