aboutsummaryrefslogtreecommitdiffstats
path: root/trustStoreMerger/src/main/java
diff options
context:
space:
mode:
authorJan Malkiewicz <jan.malkiewicz@nokia.com>2020-09-18 09:53:12 +0200
committerJan Malkiewicz <jan.malkiewicz@nokia.com>2020-09-18 10:01:49 +0200
commitf8ce5f7332bd79b584ddd45ed8062cfdb5a938f3 (patch)
tree378475eac7d70cbc4d478af39c82d809a1972b3f /trustStoreMerger/src/main/java
parent900b8224a0401e126e9033c61602aceed68c4080 (diff)
[OOM-CMPv2] Rename module folder truststoreMerger -> certServicePostProcessor
Issue-ID: DCAEGEN2-2253 Signed-off-by: Jan Malkiewicz <jan.malkiewicz@nokia.com> Change-Id: I975f37507f7f79c238f1eac15f375fe64761c80c
Diffstat (limited to 'trustStoreMerger/src/main/java')
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExecutor.java54
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExitHandler.java34
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/CertificatePostProcessor.java47
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/MainApp.java27
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/CertificateConstants.java31
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitStatus.java56
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitableException.java40
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/ExtensionResolver.java42
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/FileTools.java52
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/PasswordReader.java41
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationLoader.java33
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationProvider.java82
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/CertificatesPathsValidationException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/ConfigurationException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/AppConfiguration.java56
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/EnvVariable.java51
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitter.java49
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/env/EnvReader.java39
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/validation/ValidationFunctions.java57
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/KeystoreCopier.java74
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreFileCopyException.java31
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreNotExistException.java31
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreFilesProvider.java46
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreMerger.java54
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/AliasConflictException.java31
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/CreateBackupException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/KeystoreInstanceException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/LoadTruststoreException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/MissingTruststoreException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/PasswordReaderException.java29
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreDataOperationException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreFileFactoryException.java30
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/WriteTruststoreFileException.java31
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststore.java166
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststoreFactory.java48
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java156
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/Truststore.java47
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/TruststoreFactory.java64
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAlias.java41
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAliasFactory.java33
-rw-r--r--trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/PemAliasGenerator.java42
41 files changed, 0 insertions, 1955 deletions
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExecutor.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExecutor.java
deleted file mode 100644
index 2ef30b68..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExecutor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*============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.certservice.postprocessor;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AppExecutor {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(AppExecutor.class);
-
- private AppExitHandler exitHandler;
-
- AppExecutor() {
- this(new AppExitHandler());
- }
-
- AppExecutor(AppExitHandler exitHandler) {
- this.exitHandler = exitHandler;
- }
-
-
- public void execute(Runnable logic) {
- try {
- logic.run();
- exitHandler.exit(ExitStatus.SUCCESS);
- } catch (ExitableException e) {
- LOGGER.error("Application failed: ", e);
- exitHandler.exit(e.applicationExitStatus());
- } catch (Exception e) {
- LOGGER.error("Application failed (unexpected error): ", e);
- exitHandler.exit(ExitStatus.UNEXPECTED_EXCEPTION);
- }
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExitHandler.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExitHandler.java
deleted file mode 100644
index 15677dc4..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/AppExitHandler.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*============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.certservice.postprocessor;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AppExitHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(AppExitHandler.class);
-
- public void exit(ExitStatus exitStatus) {
- LOGGER.info("Application exits with code [{}] and message: {}",
- exitStatus.getExitCodeValue(), exitStatus.getMessage());
- System.exit(exitStatus.getExitCodeValue());
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/CertificatePostProcessor.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/CertificatePostProcessor.java
deleted file mode 100644
index b9038227..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/CertificatePostProcessor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*============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.certservice.postprocessor;
-
-import org.onap.oom.certservice.postprocessor.common.FileTools;
-import org.onap.oom.certservice.postprocessor.configuration.AppConfigurationLoader;
-import org.onap.oom.certservice.postprocessor.configuration.model.AppConfiguration;
-import org.onap.oom.certservice.postprocessor.copier.KeystoreCopier;
-import org.onap.oom.certservice.postprocessor.merger.TruststoreMerger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class CertificatePostProcessor implements Runnable {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CertificatePostProcessor.class);
-
- private AppConfigurationLoader config = new AppConfigurationLoader();
- private TruststoreMerger merger = new TruststoreMerger();
- private KeystoreCopier copier = new KeystoreCopier(new FileTools());
-
- public void run() {
- LOGGER.debug("Loading configuration...");
- AppConfiguration configuration = config.loadConfiguration();
- LOGGER.debug("Starting TruststoreMerger...");
- merger.mergeTruststores(configuration);
- LOGGER.debug("Starting KeystoreCopier...");
- copier.copyKeystores(configuration);
- LOGGER.debug("Certificate post processing finished successfully.");
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/MainApp.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/MainApp.java
deleted file mode 100644
index f815f489..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/MainApp.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*============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.certservice.postprocessor;
-
-public class MainApp {
-
- public static void main(String[] args) {
- new AppExecutor().execute(new CertificatePostProcessor());
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/CertificateConstants.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/CertificateConstants.java
deleted file mode 100644
index 3442621b..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/CertificateConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*============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.certservice.postprocessor.api;
-
-public class CertificateConstants {
-
- private CertificateConstants() { }
-
- public static final String JKS_TYPE = "JKS";
- public static final String PKCS12_TYPE = "PKCS12";
- public static final String X_509_CERTIFICATE = "X.509";
- public static final String BOUNCY_CASTLE_PROVIDER = "BC";
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitStatus.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitStatus.java
deleted file mode 100644
index b6cebeb1..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitStatus.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*============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.certservice.postprocessor.api;
-
-public enum ExitStatus {
-
- SUCCESS(0, "Success"),
- CERTIFICATES_PATHS_VALIDATION_EXCEPTION(1, "Invalid paths in environment variables"),
- CONFIGURATION_EXCEPTION(2, "Invalid merger configuration"),
- TRUSTSTORE_FILE_FACTORY_EXCEPTION(3, "Invalid truststore file-password pair"),
- PASSWORD_READER_EXCEPTION(4, "Cannot read password from file"),
- CREATE_BACKUP_EXCEPTION(5, "Cannot create backup file"),
- KEYSTORE_INSTANCE_EXCEPTION(6, "Cannot initialize keystore instance"),
- TRUSTSTORE_LOAD_FILE_EXCEPTION(7, "Cannot load truststore file"),
- TRUSTSTORE_DATA_OPERATION_EXCEPTION(8, "Cannot operate on truststore data"),
- MISSING_TRUSTSTORE_EXCEPTION(9, "Missing truststore certificates in provided file"),
- ALIAS_CONFLICT_EXCEPTION(10, "Alias conflict detected"),
- WRITE_TRUSTSTORE_FILE_EXCEPTION(11, "Cannot save truststore file"),
- KEYSTORE_FILE_COPY_EXCEPTION(12, "Cannot copy keystore file"),
- KEYSTORE_NOT_EXIST_EXCEPTION(13, "Keystore file does not exist"),
- UNEXPECTED_EXCEPTION(99, "Application exited abnormally");
-
-
- private final int value;
- private final String message;
-
- ExitStatus(int value, String message) {
- this.value = value;
- this.message = message;
- }
-
- public int getExitCodeValue() {
- return value;
- }
-
- public String getMessage() {
- return message;
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitableException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitableException.java
deleted file mode 100644
index 54a7c6a1..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/api/ExitableException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*============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.certservice.postprocessor.api;
-
-public class ExitableException extends RuntimeException {
-
- private final ExitStatus exitStatus;
-
- public ExitableException(Throwable cause, ExitStatus exitStatus) {
- super(cause);
- this.exitStatus = exitStatus;
- }
-
- public ExitableException(String message, ExitStatus exitStatus) {
- super(message);
- this.exitStatus = exitStatus;
- }
-
- public ExitStatus applicationExitStatus() {
- return exitStatus;
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/ExtensionResolver.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/ExtensionResolver.java
deleted file mode 100644
index 7a785ae1..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/ExtensionResolver.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*============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.certservice.postprocessor.common;
-
-import java.io.File;
-
-public final class ExtensionResolver {
-
- private static final int INDEX_NOT_FOUND = -1;
-
- private ExtensionResolver() {}
-
- public static String get(File file) {
- int extStartIndex = file.getName().lastIndexOf(".");
- if (extStartIndex == INDEX_NOT_FOUND) {
- return "";
- }
- return file.getName().substring(extStartIndex).toLowerCase();
- }
-
- public static boolean checkIfFileExists(File file) {
- return file.exists();
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/FileTools.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/FileTools.java
deleted file mode 100644
index 620d8088..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/FileTools.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*============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.certservice.postprocessor.common;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.commons.io.FileUtils;
-import org.onap.oom.certservice.postprocessor.merger.exception.CreateBackupException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class FileTools {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(FileTools.class);
- private static final String BACKUP_EXTENSION = ".bak";
-
- public void createBackup(File file) throws CreateBackupException {
- LOGGER.debug("Try to create a backup of the file: {}", file.getPath());
- File backupFile = new File(file.getAbsolutePath() + BACKUP_EXTENSION);
- try {
- copy(file, backupFile);
- } catch (IOException e) {
- LOGGER.error("Could not create backup of the file: '{}'", file.getPath());
- throw new CreateBackupException(e);
- }
- LOGGER.debug("Backup file created: '{}'", backupFile.getAbsolutePath());
- }
-
- public void copy(File source, File destination) throws IOException {
- LOGGER.debug("Try to copy from '{}' to '{}'.", source.getAbsolutePath(), destination.getAbsolutePath());
- FileUtils.copyFile(source, destination);
- LOGGER.debug("File copied from '{}' to '{}'.", source.getAbsolutePath(),
- destination.getAbsolutePath());
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/PasswordReader.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/PasswordReader.java
deleted file mode 100644
index 6e4a5f3a..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/common/PasswordReader.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*============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.certservice.postprocessor.common;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import org.onap.oom.certservice.postprocessor.merger.exception.PasswordReaderException;
-
-public final class PasswordReader {
-
- private static final String COULD_NOT_READ_PASSWORD_FROM_FILE_MSG_TEMPLATE = "Could not read password from file: %s";
-
- private PasswordReader() {
- }
-
- public static String readPassword(File file) {
- try {
- return Files.readString(file.toPath());
- } catch (IOException e) {
- throw new PasswordReaderException(String.format(COULD_NOT_READ_PASSWORD_FROM_FILE_MSG_TEMPLATE, file));
- }
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationLoader.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationLoader.java
deleted file mode 100644
index a3f49d86..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationLoader.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*============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.certservice.postprocessor.configuration;
-
-import org.onap.oom.certservice.postprocessor.configuration.model.AppConfiguration;
-import org.onap.oom.certservice.postprocessor.configuration.path.DelimitedPathsSplitter;
-import org.onap.oom.certservice.postprocessor.configuration.path.env.EnvReader;
-
-public class AppConfigurationLoader {
-
- public AppConfiguration loadConfiguration() {
- DelimitedPathsSplitter pathsSplitter = new DelimitedPathsSplitter();
- AppConfigurationProvider factory = new AppConfigurationProvider(pathsSplitter, new EnvReader());
- return factory.createConfiguration();
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationProvider.java
deleted file mode 100644
index 1e9ef8a9..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/AppConfigurationProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*============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.certservice.postprocessor.configuration;
-
-
-import static org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable.KEYSTORE_DESTINATION_PATHS;
-import static org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable.KEYSTORE_SOURCE_PATHS;
-import static org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable.TRUSTSTORES_PASSWORDS_PATHS;
-import static org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable.TRUSTSTORES_PATHS;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import org.onap.oom.certservice.postprocessor.configuration.path.env.EnvReader;
-import org.onap.oom.certservice.postprocessor.configuration.exception.ConfigurationException;
-import org.onap.oom.certservice.postprocessor.configuration.model.AppConfiguration;
-import org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable;
-import org.onap.oom.certservice.postprocessor.configuration.path.DelimitedPathsSplitter;
-
-public class AppConfigurationProvider {
-
- private final EnvReader envReader;
- private final DelimitedPathsSplitter pathsSplitter;
-
- public AppConfigurationProvider(DelimitedPathsSplitter pathsSplitter, EnvReader envReader) {
- this.envReader = envReader;
- this.pathsSplitter = pathsSplitter;
- }
-
- public AppConfiguration createConfiguration() {
- List<String> truststoresPaths = getPaths(TRUSTSTORES_PATHS);
- List<String> truststoresPasswordsPaths = getPaths(TRUSTSTORES_PASSWORDS_PATHS);
- List<String> sourceKeystorePaths = getPaths(KEYSTORE_SOURCE_PATHS);
- List<String> destinationKeystorePaths = getPaths(KEYSTORE_DESTINATION_PATHS);
-
- ensureSameSize(truststoresPaths, truststoresPasswordsPaths, TRUSTSTORES_PATHS.name(),
- TRUSTSTORES_PASSWORDS_PATHS.name());
- ensureSameSize(sourceKeystorePaths, destinationKeystorePaths, KEYSTORE_SOURCE_PATHS.name(),
- KEYSTORE_DESTINATION_PATHS.name());
-
- return new AppConfiguration(truststoresPaths, truststoresPasswordsPaths, sourceKeystorePaths,
- destinationKeystorePaths);
- }
-
- private List<String> getPaths(EnvVariable envVariable) {
- Optional<String> envValue = envReader.getEnv(envVariable.name());
- isMandatoryEnvPresent(envVariable, envValue);
- return envValue.isPresent() ? pathsSplitter.getValidatedPaths(envVariable, envValue) : Collections.emptyList();
- }
-
- private void isMandatoryEnvPresent(EnvVariable envVariable, Optional<String> envValue) {
- if (envVariable.isMandatory() && envValue.isEmpty()) {
- throw new ConfigurationException(envVariable + " mandatory environment variable is not defined");
- }
- }
-
- private void ensureSameSize(List<String> firstList, List<String> secondList, String firstListEnvName,
- String secondListEnvName) {
- if (firstList.size() != secondList.size()) {
- throw new ConfigurationException(
- "Size of " + firstListEnvName
- + " does not match size of " + secondListEnvName + " environment variables");
- }
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/CertificatesPathsValidationException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/CertificatesPathsValidationException.java
deleted file mode 100644
index fb621017..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/CertificatesPathsValidationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.configuration.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class CertificatesPathsValidationException extends ExitableException {
-
- public CertificatesPathsValidationException(String errorMessage) {
- super(errorMessage, ExitStatus.CERTIFICATES_PATHS_VALIDATION_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/ConfigurationException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/ConfigurationException.java
deleted file mode 100644
index c9f9a416..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/exception/ConfigurationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.configuration.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class ConfigurationException extends ExitableException {
-
- public ConfigurationException(String errorMessage) {
- super(errorMessage, ExitStatus.CONFIGURATION_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/AppConfiguration.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/AppConfiguration.java
deleted file mode 100644
index d28dcac5..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/AppConfiguration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*============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.certservice.postprocessor.configuration.model;
-
-import java.util.Collections;
-import java.util.List;
-
-public final class AppConfiguration {
- private final List<String> truststoreFilePaths;
- private final List<String> truststoreFilePasswordPaths;
- private final List<String> sourceKeystorePaths;
- private final List<String> destinationKeystorePaths;
-
- public AppConfiguration(List<String> truststoreFilePaths,
- List<String> truststoreFilePasswordPaths, List<String> sourceKeystorePaths,
- List<String> destinationKeystorePaths) {
- this.truststoreFilePaths = List.copyOf(truststoreFilePaths);
- this.truststoreFilePasswordPaths = List.copyOf(truststoreFilePasswordPaths);
- this.sourceKeystorePaths = List.copyOf(sourceKeystorePaths);
- this.destinationKeystorePaths = List.copyOf(destinationKeystorePaths);
- }
-
- public List<String> getTruststoreFilePaths() {
- return Collections.unmodifiableList(truststoreFilePaths);
- }
-
- public List<String> getTruststoreFilePasswordPaths() {
- return Collections.unmodifiableList(truststoreFilePasswordPaths);
- }
-
-
- public List<String> getDestinationKeystorePaths() {
- return Collections.unmodifiableList(destinationKeystorePaths);
- }
-
- public List<String> getSourceKeystorePaths() {
- return Collections.unmodifiableList(sourceKeystorePaths);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/EnvVariable.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/EnvVariable.java
deleted file mode 100644
index be49d39c..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/model/EnvVariable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*============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.certservice.postprocessor.configuration.model;
-
-import static org.onap.oom.certservice.postprocessor.configuration.path.validation.ValidationFunctions.doesItContainValidCertificatesPaths;
-import static org.onap.oom.certservice.postprocessor.configuration.path.validation.ValidationFunctions.doesItContainValidPasswordPaths;
-import static org.onap.oom.certservice.postprocessor.configuration.path.validation.ValidationFunctions.doesItContainValidPathsToCopy;
-
-import java.util.List;
-import java.util.function.Predicate;
-
-public enum EnvVariable {
- TRUSTSTORES_PATHS(true, doesItContainValidCertificatesPaths()),
- TRUSTSTORES_PASSWORDS_PATHS(true, doesItContainValidPasswordPaths()),
- KEYSTORE_SOURCE_PATHS(false, doesItContainValidPathsToCopy()),
- KEYSTORE_DESTINATION_PATHS(false, doesItContainValidPathsToCopy());
-
- boolean isMandatory;
-
- Predicate<List<String>> validationFunction;
-
- EnvVariable(boolean isMandatory, Predicate<List<String>> validationFunction) {
- this.isMandatory = isMandatory;
- this.validationFunction = validationFunction;
- }
-
- public boolean isMandatory() {
- return isMandatory;
- }
-
- public Predicate<List<String>> getValidationFunction() {
- return validationFunction;
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitter.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitter.java
deleted file mode 100644
index b2e71cb3..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*============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.certservice.postprocessor.configuration.path;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import org.onap.oom.certservice.postprocessor.configuration.exception.CertificatesPathsValidationException;
-import org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable;
-
-public class DelimitedPathsSplitter {
-
- private static final String DELIMITER = ":";
- private static final int NEGATIVE_SPLIT_LIMIT = -1;
-
- public List<String> getValidatedPaths(EnvVariable envVariable, Optional<String> envValue)
- throws CertificatesPathsValidationException {
- return envValue.filter(this::hasValue)
- .map(this::splitToList)
- .filter(envVariable.getValidationFunction())
- .orElseThrow(() -> new CertificatesPathsValidationException(
- envVariable + " environment variable does not contain valid paths"));
- }
-
- private boolean hasValue(String envValue) {
- return !envValue.isEmpty();
- }
-
- private List<String> splitToList(String stringToSplit) {
- return Arrays.asList(stringToSplit.split(DELIMITER, NEGATIVE_SPLIT_LIMIT));
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/env/EnvReader.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/env/EnvReader.java
deleted file mode 100644
index f30e43be..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/env/EnvReader.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*============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.certservice.postprocessor.configuration.path.env;
-
-import java.util.Optional;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EnvReader {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(EnvReader.class);
-
- public Optional<String> getEnv(String name) {
- return getSystemEnv(name);
- }
-
- Optional<String> getSystemEnv(String name) {
- String value = System.getenv(name);
- LOGGER.info("Read variable: {} , value: {}", name, value);
- return Optional.ofNullable(value);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/validation/ValidationFunctions.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/validation/ValidationFunctions.java
deleted file mode 100644
index f65a21a0..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/configuration/path/validation/ValidationFunctions.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*============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.certservice.postprocessor.configuration.path.validation;
-
-import java.util.List;
-import java.util.function.Predicate;
-
-public final class ValidationFunctions {
-
- private static final String CERTIFICATE_PATH_REGEX = "^(/[a-zA-Z0-9_-]+)+\\.(pem|jks|p12)";
- private static final String CERTIFICATE_PASSWORD_PATH_REGEX = "^(/[a-zA-Z0-9_-]+)+\\.pass";
-
- private ValidationFunctions() {
- }
-
- public static Predicate<List<String>> doesItContainValidPasswordPaths() {
- return paths -> paths.stream().allMatch(ValidationFunctions::isCertificatePasswordPathValid);
- }
-
- public static Predicate<List<String>> doesItContainValidCertificatesPaths() {
- return paths -> paths.stream().allMatch(ValidationFunctions::isCertificatePathValid);
- }
-
- public static Predicate<List<String>> doesItContainValidPathsToCopy() {
- return paths -> paths.stream().allMatch(path ->
- doesMatch(path, CERTIFICATE_PASSWORD_PATH_REGEX) || isCertificatePathValid(path));
- }
-
- private static boolean isCertificatePathValid(String path) {
- return doesMatch(path, CERTIFICATE_PATH_REGEX);
- }
-
- private static boolean isCertificatePasswordPathValid(String path) {
- return path.isEmpty() || doesMatch(path, CERTIFICATE_PASSWORD_PATH_REGEX);
- }
-
- private static boolean doesMatch(String path, String regex) {
- return path.matches(regex);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/KeystoreCopier.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/KeystoreCopier.java
deleted file mode 100644
index f5cea212..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/KeystoreCopier.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*============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.certservice.postprocessor.copier;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import org.onap.oom.certservice.postprocessor.common.FileTools;
-import org.onap.oom.certservice.postprocessor.configuration.model.AppConfiguration;
-import org.onap.oom.certservice.postprocessor.copier.exception.KeystoreFileCopyException;
-import org.onap.oom.certservice.postprocessor.copier.exception.KeystoreNotExistException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class KeystoreCopier {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(KeystoreCopier.class);
- private final FileTools fileTools;
-
- public KeystoreCopier(FileTools fileTools) {
- this.fileTools = fileTools;
- }
-
- public void copyKeystores(AppConfiguration configuration) {
- final List<String> sources = configuration.getSourceKeystorePaths();
- final List<String> destinations = configuration.getDestinationKeystorePaths();
- containsPaths(sources);
- try {
- for (int i = 0; i < sources.size(); i++) {
- copy(sources.get(i), destinations.get(i));
- }
- } catch (IOException e) {
- throw new KeystoreFileCopyException(e);
- }
- }
-
- private void containsPaths(List<String> sources) {
- if (sources.isEmpty()) {
- LOGGER.info("No Keystore files to copy");
- }
- }
-
- private void copy(String sourcePath, String destinationPath) throws IOException {
- final File source = new File(sourcePath);
- final File destination = new File(destinationPath);
-
- if (!source.exists()) {
- throw new KeystoreNotExistException("Keystore file does not exist '" + source.getAbsolutePath() + "'!");
- }
-
- if (destination.exists()) {
- fileTools.createBackup(destination);
- }
- fileTools.copy(source, destination);
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreFileCopyException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreFileCopyException.java
deleted file mode 100644
index 66190965..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreFileCopyException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*============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.certservice.postprocessor.copier.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class KeystoreFileCopyException extends ExitableException {
-
- public KeystoreFileCopyException(Exception e) {
- super(e, ExitStatus.KEYSTORE_FILE_COPY_EXCEPTION);
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreNotExistException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreNotExistException.java
deleted file mode 100644
index 37f2f537..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/copier/exception/KeystoreNotExistException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*============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.certservice.postprocessor.copier.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class KeystoreNotExistException extends ExitableException {
-
- public KeystoreNotExistException(String message) {
- super(message, ExitStatus.KEYSTORE_NOT_EXIST_EXCEPTION);
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreFilesProvider.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreFilesProvider.java
deleted file mode 100644
index 9e30bd44..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreFilesProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*============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.certservice.postprocessor.merger;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.onap.oom.certservice.postprocessor.merger.model.Truststore;
-import org.onap.oom.certservice.postprocessor.merger.model.TruststoreFactory;
-
-public class TruststoreFilesProvider {
-
-
- private TruststoreFilesProvider() {
- }
-
- public static List<Truststore> getTruststoreFiles(List<String> truststoreFilePaths,
- List<String> truststoreFilePasswordPaths) {
- List<Truststore> truststoreFiles = new ArrayList<>();
- for (int i = 0; i < truststoreFilePaths.size(); i++) {
- String truststorePath = truststoreFilePaths.get(i);
- String passwordPath = truststoreFilePasswordPaths.get(i);
-
- Truststore truststore = TruststoreFactory.create(truststorePath, passwordPath);
- truststoreFiles.add(truststore);
- }
-
- return truststoreFiles;
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreMerger.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreMerger.java
deleted file mode 100644
index 3cf60da1..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/TruststoreMerger.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*============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.certservice.postprocessor.merger;
-
-import java.util.List;
-import org.onap.oom.certservice.postprocessor.configuration.model.AppConfiguration;
-import org.onap.oom.certservice.postprocessor.merger.model.Truststore;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAlias;
-
-public class TruststoreMerger {
-
- private static final int FIRST_TRUSTSTORE_INDEX = 0;
- private static final int SECOND_TRUSTSTORE_INDEX = 1;
-
- public void mergeTruststores(AppConfiguration configuration) {
- List<Truststore> truststoreFilesList = getTruststoreFiles(configuration);
-
- Truststore baseFile = truststoreFilesList.get(FIRST_TRUSTSTORE_INDEX);
- baseFile.createBackup();
-
- for (int i = SECOND_TRUSTSTORE_INDEX; i < truststoreFilesList.size(); i++) {
- Truststore truststore = truststoreFilesList.get(i);
- List<CertificateWithAlias> certificateWrappers = truststore.getCertificates();
- baseFile.addCertificates(certificateWrappers);
- }
-
- baseFile.saveFile();
- }
-
- private List<Truststore> getTruststoreFiles(AppConfiguration configuration) {
- return TruststoreFilesProvider
- .getTruststoreFiles(
- configuration.getTruststoreFilePaths(),
- configuration.getTruststoreFilePasswordPaths()
- );
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/AliasConflictException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/AliasConflictException.java
deleted file mode 100644
index 2e7939b7..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/AliasConflictException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class AliasConflictException extends ExitableException {
-
- public AliasConflictException(String errorMessage) {
- super(errorMessage, ExitStatus.ALIAS_CONFLICT_EXCEPTION);
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/CreateBackupException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/CreateBackupException.java
deleted file mode 100644
index 8e99f993..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/CreateBackupException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class CreateBackupException extends ExitableException {
-
- public CreateBackupException(Exception cause) {
- super(cause, ExitStatus.CREATE_BACKUP_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/KeystoreInstanceException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/KeystoreInstanceException.java
deleted file mode 100644
index 1279dff7..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/KeystoreInstanceException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class KeystoreInstanceException extends ExitableException {
-
- public KeystoreInstanceException(Exception cause) {
- super(cause, ExitStatus.KEYSTORE_INSTANCE_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/LoadTruststoreException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/LoadTruststoreException.java
deleted file mode 100644
index b3493fd6..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/LoadTruststoreException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class LoadTruststoreException extends ExitableException {
-
- public LoadTruststoreException(Exception cause) {
- super(cause, ExitStatus.TRUSTSTORE_LOAD_FILE_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/MissingTruststoreException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/MissingTruststoreException.java
deleted file mode 100644
index 51660f60..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/MissingTruststoreException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class MissingTruststoreException extends ExitableException {
-
- public MissingTruststoreException(String errorMessage) {
- super(errorMessage, ExitStatus.MISSING_TRUSTSTORE_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/PasswordReaderException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/PasswordReaderException.java
deleted file mode 100644
index b1bdf1ea..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/PasswordReaderException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class PasswordReaderException extends ExitableException {
- public PasswordReaderException(String errorMessage) {
- super(errorMessage, ExitStatus.PASSWORD_READER_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreDataOperationException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreDataOperationException.java
deleted file mode 100644
index 77ae366e..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreDataOperationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class TruststoreDataOperationException extends ExitableException {
-
- public TruststoreDataOperationException(Exception cause) {
- super(cause, ExitStatus.TRUSTSTORE_DATA_OPERATION_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreFileFactoryException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreFileFactoryException.java
deleted file mode 100644
index a87a62a3..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/TruststoreFileFactoryException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class TruststoreFileFactoryException extends ExitableException {
- public TruststoreFileFactoryException(String errorMessage) {
- super(errorMessage, ExitStatus.TRUSTSTORE_FILE_FACTORY_EXCEPTION);
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/WriteTruststoreFileException.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/WriteTruststoreFileException.java
deleted file mode 100644
index f9b772ca..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/exception/WriteTruststoreFileException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*============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.certservice.postprocessor.merger.exception;
-
-import org.onap.oom.certservice.postprocessor.api.ExitStatus;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-
-public class WriteTruststoreFileException extends ExitableException {
-
- public WriteTruststoreFileException(Exception cause) {
- super(cause, ExitStatus.WRITE_TRUSTSTORE_FILE_EXCEPTION);
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststore.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststore.java
deleted file mode 100644
index d264d2f4..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststore.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*============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.certservice.postprocessor.merger.model;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.onap.oom.certservice.postprocessor.merger.exception.AliasConflictException;
-import org.onap.oom.certservice.postprocessor.merger.exception.LoadTruststoreException;
-import org.onap.oom.certservice.postprocessor.merger.exception.MissingTruststoreException;
-import org.onap.oom.certservice.postprocessor.merger.exception.TruststoreDataOperationException;
-import org.onap.oom.certservice.postprocessor.merger.exception.WriteTruststoreFileException;
-import org.onap.oom.certservice.postprocessor.api.ExitableException;
-import org.onap.oom.certservice.postprocessor.common.FileTools;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAlias;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAliasFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class JavaTruststore extends Truststore {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JavaTruststore.class);
-
- private final CertificateWithAliasFactory factory = new CertificateWithAliasFactory();
- private final KeyStore keyStore;
- private final String password;
-
-
- private JavaTruststore(KeyStore keyStore, File storeFile, String password) {
- super(storeFile, new FileTools());
- this.keyStore = keyStore;
- this.password = password;
- }
-
- public static JavaTruststore createWithLoadingFile(KeyStore keyStore, File storeFile, String password)
- throws LoadTruststoreException {
- JavaTruststore javaTruststore = new JavaTruststore(keyStore, storeFile, password);
- javaTruststore.loadFile();
- return javaTruststore;
- }
-
- public List<CertificateWithAlias> getCertificates() throws ExitableException {
- LOGGER.debug("Attempt to read certificates from file: {}", storeFile.getPath());
- List<String> aliases = getTruststoreAliases();
- if (aliases.isEmpty()) {
- throw new MissingTruststoreException("Missing certificate aliases in file: " + storeFile.getPath());
- }
- return getWrappedCertificates(aliases);
- }
-
- public void addCertificates(List<CertificateWithAlias> certificatesWithAliases)
- throws ExitableException {
- LOGGER.debug("Attempt to add certificates for saving to file");
- if (getTruststoreAliases().isEmpty()) {
- throw new MissingTruststoreException("Missing certificate aliases in file: " + storeFile.getPath());
- }
- for (CertificateWithAlias certificate : certificatesWithAliases) {
- addCertificate(certificate);
- }
- }
-
- public void saveFile() throws WriteTruststoreFileException {
- LOGGER.debug("Attempt to save file: {}", storeFile.getPath());
- try (FileOutputStream outputStream = new FileOutputStream(storeFile)) {
- keyStore.store(outputStream, this.password.toCharArray());
- } catch (Exception e) {
- LOGGER.error("Cannot write truststore file");
- throw new WriteTruststoreFileException(e);
- }
- }
-
- private void loadFile() throws LoadTruststoreException {
- try {
- keyStore.load(new FileInputStream(storeFile), this.password.toCharArray());
- } catch (Exception e) {
- LOGGER.error("Cannot load file: {}", storeFile.getPath());
- throw new LoadTruststoreException(e);
- }
- }
-
- private void addCertificate(CertificateWithAlias certificate)
- throws TruststoreDataOperationException, AliasConflictException {
- if (hasAliasConflict(certificate)) {
- LOGGER.error("Alias conflict detected");
- throw new AliasConflictException("Alias conflict detected. Alias conflicted: " + certificate.getAlias());
- }
- try {
- keyStore.setCertificateEntry(certificate.getAlias(), certificate.getCertificate());
- } catch (KeyStoreException e) {
- LOGGER.error("Cannot merge certificate with alias: {}", certificate.getAlias());
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private boolean hasAliasConflict(CertificateWithAlias certificate) throws TruststoreDataOperationException {
- try {
- return keyStore.containsAlias(certificate.getAlias());
- } catch (KeyStoreException e) {
- LOGGER.error("Cannot check alias conflict");
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private List<CertificateWithAlias> getWrappedCertificates(List<String> aliases)
- throws TruststoreDataOperationException {
-
- List<CertificateWithAlias> certificateWrapped = new ArrayList<>();
-
- for (String alias : aliases) {
- certificateWrapped.add(createWrappedCertificate(alias));
- }
- return certificateWrapped;
- }
-
- private CertificateWithAlias createWrappedCertificate(String alias) throws TruststoreDataOperationException {
- try {
- return factory.createCertificateWithAlias(keyStore.getCertificate(alias), alias);
- } catch (KeyStoreException e) {
- LOGGER.warn("Cannot get certificate with alias: {} ", alias);
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private List<String> getTruststoreAliases() throws TruststoreDataOperationException {
- try {
- List<String> aliases = Collections.list(keyStore.aliases());
- return getFilteredAlias(aliases);
- } catch (KeyStoreException e) {
- LOGGER.warn("Cannot read truststore aliases");
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private List<String> getFilteredAlias(List<String> aliases) throws KeyStoreException {
- List<String> filteredAlias = new ArrayList<>();
- for (String alias : aliases) {
- if (keyStore.isCertificateEntry(alias)) {
- filteredAlias.add(alias);
- }
- }
- return filteredAlias;
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststoreFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststoreFactory.java
deleted file mode 100644
index 4740d0f6..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/JavaTruststoreFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*============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.certservice.postprocessor.merger.model;
-
-import java.io.File;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import org.onap.oom.certservice.postprocessor.merger.exception.KeystoreInstanceException;
-import org.onap.oom.certservice.postprocessor.common.PasswordReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JavaTruststoreFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JavaTruststoreFactory.class);
-
- private JavaTruststoreFactory() {
- }
-
- public static Truststore create(File certFile, String truststorePasswordPath, String keystoreType) {
- String password = PasswordReader.readPassword(new File(truststorePasswordPath));
- try {
- return JavaTruststore
- .createWithLoadingFile(KeyStore.getInstance(keystoreType), certFile, password);
- } catch (KeyStoreException e) {
- LOGGER.error("Cannot initialize Java Keystore instance");
- throw new KeystoreInstanceException(e);
- }
- }
-}
-
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java
deleted file mode 100644
index d7f4bfd2..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*============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.certservice.postprocessor.merger.model;
-
-import static org.onap.oom.certservice.postprocessor.api.CertificateConstants.BOUNCY_CASTLE_PROVIDER;
-import static org.onap.oom.certservice.postprocessor.api.CertificateConstants.X_509_CERTIFICATE;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator;
-import org.bouncycastle.util.io.pem.PemObjectGenerator;
-import org.bouncycastle.util.io.pem.PemWriter;
-import org.onap.oom.certservice.postprocessor.merger.exception.MissingTruststoreException;
-import org.onap.oom.certservice.postprocessor.merger.exception.TruststoreDataOperationException;
-import org.onap.oom.certservice.postprocessor.merger.exception.WriteTruststoreFileException;
-import org.onap.oom.certservice.postprocessor.common.FileTools;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAlias;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAliasFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PemTruststore extends Truststore {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PemTruststore.class);
-
- private static final boolean APPEND_TO_FILE = true;
-
- private final CertificateWithAliasFactory factory = new CertificateWithAliasFactory();
- private final List<CertificateWithAlias> certificatesToBeSaved = new ArrayList<>();
-
- public PemTruststore(File storeFile) {
- super(storeFile, new FileTools());
- }
-
- public List<CertificateWithAlias> getCertificates()
- throws TruststoreDataOperationException, MissingTruststoreException {
- LOGGER.debug("Attempt to read certificates from file: {}", storeFile.getPath());
- if (isFileWithoutPemCertificate()) {
- throw new MissingTruststoreException("File does not contain any certificate");
- }
- List<Certificate> extractedCertificate = extractCertificatesFromFile();
- return wrapCertificates(extractedCertificate);
- }
-
- public void addCertificates(List<CertificateWithAlias> certificates)
- throws TruststoreDataOperationException, MissingTruststoreException {
- LOGGER.debug("Attempt to add certificates for saving to file");
- if (isFileWithoutPemCertificate()) {
- LOGGER.error("File does not contain any certificate. File path: {} ", storeFile.getPath());
- throw new MissingTruststoreException("File does not contain any certificate");
- }
- certificatesToBeSaved.addAll(certificates);
- }
-
- public void saveFile() throws WriteTruststoreFileException, TruststoreDataOperationException {
- LOGGER.debug("Attempt to save file: {}", storeFile.getPath());
- List<Certificate> certificates = certificatesToBeSaved.stream()
- .map(CertificateWithAlias::getCertificate)
- .collect(Collectors.toList());
- String certificatesAsString = transformToStringInPemFormat(certificates);
- appendToFile(certificatesAsString);
- }
-
- boolean isFileWithoutPemCertificate() throws TruststoreDataOperationException {
- List<Certificate> certificateList = extractCertificatesFromFile();
- return certificateList.isEmpty();
- }
-
- String transformToStringInPemFormat(List<Certificate> certificates) throws TruststoreDataOperationException {
- StringWriter sw = new StringWriter();
- List<PemObjectGenerator> generators = transformToPemGenerators(certificates);
- try (PemWriter pemWriter = new PemWriter(sw)) {
- for (PemObjectGenerator generator : generators) {
- pemWriter.writeObject(generator);
- }
- } catch (IOException e) {
- LOGGER.error("Cannot convert certificates to PEM format");
- throw new TruststoreDataOperationException(e);
- }
- return sw.toString();
- }
-
- private List<Certificate> extractCertificatesFromFile() throws TruststoreDataOperationException {
- try (FileInputStream inputStream = new FileInputStream(storeFile)) {
- Security.addProvider(new BouncyCastleProvider());
- CertificateFactory factory = CertificateFactory.getInstance(X_509_CERTIFICATE, BOUNCY_CASTLE_PROVIDER);
- return new ArrayList<>(factory.generateCertificates(inputStream));
- } catch (Exception e) {
- LOGGER.error("Cannot read certificates from file: {}", storeFile.getPath());
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private List<PemObjectGenerator> transformToPemGenerators(List<Certificate> certificates)
- throws TruststoreDataOperationException {
- List<PemObjectGenerator> generators = new ArrayList<>();
- for (Certificate certificate : certificates) {
- PemObjectGenerator generator = createPemGenerator(certificate);
- generators.add(generator);
- }
- return generators;
- }
-
- private JcaMiscPEMGenerator createPemGenerator(Certificate certificate)
- throws TruststoreDataOperationException {
- try {
- return new JcaMiscPEMGenerator(certificate);
- } catch (IOException e) {
- LOGGER.error("Cannot convert Certificate Object to PemGenerator Object");
- throw new TruststoreDataOperationException(e);
- }
- }
-
- private List<CertificateWithAlias> wrapCertificates(List<Certificate> rawCertificates) {
- return rawCertificates.stream()
- .map(factory::createPemCertificate)
- .collect(Collectors.toList());
- }
-
- private void appendToFile(String certificatesAsString) throws WriteTruststoreFileException {
- try {
- FileOutputStream fileOutputStream = new FileOutputStream(storeFile, APPEND_TO_FILE);
- fileOutputStream.write(certificatesAsString.getBytes());
- } catch (Exception e) {
- LOGGER.error("Cannot write certificates to file");
- throw new WriteTruststoreFileException(e);
- }
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/Truststore.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/Truststore.java
deleted file mode 100644
index 058613a9..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/Truststore.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*============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.certservice.postprocessor.merger.model;
-
-import java.io.File;
-import java.util.List;
-import org.onap.oom.certservice.postprocessor.common.FileTools;
-import org.onap.oom.certservice.postprocessor.merger.model.certificate.CertificateWithAlias;
-
-public abstract class Truststore {
-
- final File storeFile;
-
- private final FileTools fileTools;
-
- public Truststore(File storeFile, FileTools fileTools) {
- this.storeFile = storeFile;
- this.fileTools = fileTools;
- }
-
- public void createBackup() {
- fileTools.createBackup(storeFile);
- }
-
- public abstract List<CertificateWithAlias> getCertificates();
-
- public abstract void addCertificates(List<CertificateWithAlias> certificates);
-
- public abstract void saveFile();
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/TruststoreFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/TruststoreFactory.java
deleted file mode 100644
index 5167c301..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/TruststoreFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*============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.certservice.postprocessor.merger.model;
-
-import static org.onap.oom.certservice.postprocessor.api.CertificateConstants.JKS_TYPE;
-import static org.onap.oom.certservice.postprocessor.api.CertificateConstants.PKCS12_TYPE;
-
-import java.io.File;
-import org.onap.oom.certservice.postprocessor.common.ExtensionResolver;
-import org.onap.oom.certservice.postprocessor.merger.exception.TruststoreFileFactoryException;
-
-public class TruststoreFactory {
-
- private static final String JKS_EXTENSION = ".jks";
- private static final String P12_EXTENSION = ".p12";
- private static final String PEM_EXTENSION = ".pem";
- private static final String FILE_DOES_NOT_EXIST_MSG_TEMPLATE = "File: %s does not exist";
- private static final String UNKNOWN_TRUSTSTORE_TYPE_MSG_TEMPLATE = "Unknown truststore extension type: %s";
-
-
- private TruststoreFactory() {
- }
-
- public static Truststore create(String truststoreFilePath, String truststorePasswordPath) {
- File truststoreFile = new File(truststoreFilePath);
- if (!ExtensionResolver.checkIfFileExists(truststoreFile)) {
- throw new TruststoreFileFactoryException(String.format(FILE_DOES_NOT_EXIST_MSG_TEMPLATE, truststoreFile));
- }
- return createTypedTruststore(truststoreFile, truststorePasswordPath);
- }
-
- private static Truststore createTypedTruststore(File truststoreFile, String truststorePasswordPath) {
- String extension = ExtensionResolver.get(truststoreFile);
- switch (extension) {
- case JKS_EXTENSION:
- return JavaTruststoreFactory.create(truststoreFile, truststorePasswordPath, JKS_TYPE);
- case P12_EXTENSION:
- return JavaTruststoreFactory.create(truststoreFile, truststorePasswordPath, PKCS12_TYPE);
- case PEM_EXTENSION:
- return new PemTruststore(truststoreFile);
- default:
- throw new TruststoreFileFactoryException(
- String.format(UNKNOWN_TRUSTSTORE_TYPE_MSG_TEMPLATE, extension));
- }
- }
-
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAlias.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAlias.java
deleted file mode 100644
index 098ffcd0..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAlias.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*============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.certservice.postprocessor.merger.model.certificate;
-
-import java.security.cert.Certificate;
-
-public class CertificateWithAlias {
-
- private final Certificate certificate;
- private final String alias;
-
- public CertificateWithAlias(Certificate certificate, String alias) {
- this.certificate = certificate;
- this.alias = alias;
- }
-
- public String getAlias() {
- return this.alias;
- }
-
- public Certificate getCertificate() {
- return this.certificate;
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAliasFactory.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAliasFactory.java
deleted file mode 100644
index 4ad2b417..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/CertificateWithAliasFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*============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.certservice.postprocessor.merger.model.certificate;
-
-import java.security.cert.Certificate;
-
-public class CertificateWithAliasFactory {
-
- public CertificateWithAlias createCertificateWithAlias(Certificate certificate, String alias) {
- return new CertificateWithAlias(certificate, alias);
- }
-
- public CertificateWithAlias createPemCertificate(Certificate certificate) {
- return new CertificateWithAlias(certificate, PemAliasGenerator.getInstance().getAlias());
- }
-}
diff --git a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/PemAliasGenerator.java b/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/PemAliasGenerator.java
deleted file mode 100644
index a89b1031..00000000
--- a/trustStoreMerger/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/certificate/PemAliasGenerator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*============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.certservice.postprocessor.merger.model.certificate;
-
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class PemAliasGenerator {
-
- private static final String PREFIX_ALIAS_NAME = "pem-trusted-certificate-";
- private static final PemAliasGenerator INSTANCE = new PemAliasGenerator();
- private static AtomicInteger counter = new AtomicInteger(0);
-
- private PemAliasGenerator() {
- }
-
- public static PemAliasGenerator getInstance() {
- return INSTANCE;
- }
-
- public String getAlias() {
-
- return PREFIX_ALIAS_NAME + counter.getAndIncrement();
- }
-}