diff options
author | kjaniak <kornel.janiak@nokia.com> | 2020-09-02 13:34:19 +0200 |
---|---|---|
committer | kjaniak <kornel.janiak@nokia.com> | 2020-09-03 11:02:14 +0200 |
commit | 9518352d2bdc2db7b33c5ad305faeca77eba9656 (patch) | |
tree | a01f1cc58b6f669a4c66c2a20d4fcfcc01f61579 /trustStoreMerger/src/main | |
parent | d0e9d1fb9422effe0fe2408c8de2553e2ac20702 (diff) |
Move path logic to configuration (merger)
Issue-ID: DCAEGEN2-2253
Change-Id: I8ef6603335a837fbd2bcda9975d669f73f94db57
Signed-off-by: kjaniak <kornel.janiak@nokia.com>
Diffstat (limited to 'trustStoreMerger/src/main')
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java | 14 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationProvider.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java) | 11 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/MergerConfigurationException.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationException.java) | 4 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/TruststoresPathsProviderException.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProviderException.java) | 4 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/MergerConfiguration.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfiguration.java) | 4 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/EnvProvider.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/EnvProvider.java) | 4 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/PathValidator.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/PathValidator.java) | 8 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProvider.java (renamed from trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProvider.java) | 5 | ||||
-rw-r--r-- | trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProviderFactory.java | 30 |
9 files changed, 57 insertions, 27 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 c8cc84df..e2e0c62a 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/TrustStoreMerger.java @@ -27,11 +27,10 @@ import org.onap.oom.truststoremerger.certification.file.provider.FileManager; import org.onap.oom.truststoremerger.certification.file.provider.PasswordReader; import org.onap.oom.truststoremerger.certification.file.TruststoreFileFactory; import org.onap.oom.truststoremerger.certification.file.TruststoreFilesListProvider; -import org.onap.oom.truststoremerger.certification.path.EnvProvider; -import org.onap.oom.truststoremerger.certification.path.TruststoresPathsProvider; -import org.onap.oom.truststoremerger.configuration.MergerConfiguration; -import org.onap.oom.truststoremerger.configuration.MergerConfigurationFactory; -import org.onap.oom.truststoremerger.certification.path.PathValidator; +import org.onap.oom.truststoremerger.configuration.path.TruststoresPathsProviderFactory; +import org.onap.oom.truststoremerger.configuration.path.TruststoresPathsProvider; +import org.onap.oom.truststoremerger.configuration.model.MergerConfiguration; +import org.onap.oom.truststoremerger.configuration.MergerConfigurationProvider; import java.util.List; import org.slf4j.Logger; @@ -75,9 +74,8 @@ class TrustStoreMerger { } private MergerConfiguration loadConfiguration() throws ExitableException { - TruststoresPathsProvider truststoresPathsProvider = new TruststoresPathsProvider(new EnvProvider(), - new PathValidator()); - MergerConfigurationFactory factory = new MergerConfigurationFactory(truststoresPathsProvider); + TruststoresPathsProvider truststoresPathsProvider = TruststoresPathsProviderFactory.create(); + MergerConfigurationProvider factory = new MergerConfigurationProvider(truststoresPathsProvider); return factory.createConfiguration(); } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationProvider.java index acd9a840..5a40a64a 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationFactory.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationProvider.java @@ -19,19 +19,20 @@ package org.onap.oom.truststoremerger.configuration; -import org.onap.oom.truststoremerger.certification.path.TruststoresPathsProvider; -import org.onap.oom.truststoremerger.certification.path.TruststoresPathsProviderException; - import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PATHS_ENV; import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_PATHS_ENV; import java.util.List; +import org.onap.oom.truststoremerger.configuration.exception.MergerConfigurationException; +import org.onap.oom.truststoremerger.configuration.exception.TruststoresPathsProviderException; +import org.onap.oom.truststoremerger.configuration.model.MergerConfiguration; +import org.onap.oom.truststoremerger.configuration.path.TruststoresPathsProvider; -public class MergerConfigurationFactory { +public class MergerConfigurationProvider { private final TruststoresPathsProvider pathsProvider; - public MergerConfigurationFactory(TruststoresPathsProvider pathsProvider) { + public MergerConfigurationProvider(TruststoresPathsProvider pathsProvider) { this.pathsProvider = pathsProvider; } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationException.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/MergerConfigurationException.java index 54982f5f..90a75d91 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfigurationException.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/MergerConfigurationException.java @@ -17,14 +17,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.configuration; +package org.onap.oom.truststoremerger.configuration.exception; import org.onap.oom.truststoremerger.api.ExitStatus; import org.onap.oom.truststoremerger.api.ExitableException; public class MergerConfigurationException extends ExitableException { - MergerConfigurationException(String message) { + public MergerConfigurationException(String message) { super(message, ExitStatus.MERGER_CONFIGURATION_EXCEPTION); } } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProviderException.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/TruststoresPathsProviderException.java index 1f69fe20..dda53e32 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProviderException.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/exception/TruststoresPathsProviderException.java @@ -17,14 +17,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.certification.path; +package org.onap.oom.truststoremerger.configuration.exception; import org.onap.oom.truststoremerger.api.ExitStatus; import org.onap.oom.truststoremerger.api.ExitableException; public class TruststoresPathsProviderException extends ExitableException { - TruststoresPathsProviderException(String message) { + public TruststoresPathsProviderException(String message) { super(message, ExitStatus.TRUSTSTORES_PATHS_PROVIDER_EXCEPTION); } } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfiguration.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/MergerConfiguration.java index f3b7d935..3b807c39 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/MergerConfiguration.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/model/MergerConfiguration.java @@ -17,12 +17,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.configuration; +package org.onap.oom.truststoremerger.configuration.model; import java.util.Collections; import java.util.List; -public class MergerConfiguration { +public final class MergerConfiguration { private final List<String> truststoreFilePaths; private final List<String> truststoreFilePasswordPaths; diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/EnvProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/EnvProvider.java index a1998b86..c6fbf515 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/EnvProvider.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/EnvProvider.java @@ -17,14 +17,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.certification.path; +package org.onap.oom.truststoremerger.configuration.path; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EnvProvider { +class EnvProvider { private static final Logger LOGGER = LoggerFactory.getLogger(EnvProvider.class); diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/PathValidator.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/PathValidator.java index 256da490..4240228d 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/PathValidator.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/PathValidator.java @@ -17,18 +17,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.certification.path; +package org.onap.oom.truststoremerger.configuration.path; -public class PathValidator { +class PathValidator { private static final String TRUSTSTORE_PATH_REGEX = "^(/[a-zA-Z0-9_-]+)+\\.(pem|jks|p12)"; private static final String TRUSTSTORE_PASSWORD_PATH_REGEX = "^(/[a-zA-Z0-9_-]+)+\\.pass"; - public boolean isTruststorePathValid(String truststorePath) { + boolean isTruststorePathValid(String truststorePath) { return isPathValid(truststorePath, TRUSTSTORE_PATH_REGEX); } - public boolean isTruststorePasswordPathValid(String truststorePasswordPath) { + boolean isTruststorePasswordPathValid(String truststorePasswordPath) { return truststorePasswordPath.isEmpty() || isPathValid(truststorePasswordPath, TRUSTSTORE_PASSWORD_PATH_REGEX); } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProvider.java index 9d86a8b9..9d7e30a4 100644 --- a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/certification/path/TruststoresPathsProvider.java +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProvider.java @@ -17,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.oom.truststoremerger.certification.path; +package org.onap.oom.truststoremerger.configuration.path; import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PATHS_ENV; import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_PATHS_ENV; @@ -25,6 +25,7 @@ import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PA import java.util.Arrays; import java.util.List; import java.util.function.Predicate; +import org.onap.oom.truststoremerger.configuration.exception.TruststoresPathsProviderException; public class TruststoresPathsProvider { @@ -34,7 +35,7 @@ public class TruststoresPathsProvider { private final EnvProvider envProvider; private final PathValidator pathValidator; - public TruststoresPathsProvider(EnvProvider envProvider, PathValidator pathValidator) { + TruststoresPathsProvider(EnvProvider envProvider, PathValidator pathValidator) { this.envProvider = envProvider; this.pathValidator = pathValidator; } diff --git a/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProviderFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProviderFactory.java new file mode 100644 index 00000000..7a999108 --- /dev/null +++ b/trustStoreMerger/src/main/java/org/onap/oom/truststoremerger/configuration/path/TruststoresPathsProviderFactory.java @@ -0,0 +1,30 @@ +/*============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.configuration.path; + +public class TruststoresPathsProviderFactory { + + private TruststoresPathsProviderFactory() { + } + + public static TruststoresPathsProvider create() { + return new TruststoresPathsProvider(new EnvProvider(), new PathValidator()); + } +} |