aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java29
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java31
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java38
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java51
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java59
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java47
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java28
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java36
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java77
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java76
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java77
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java85
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java99
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java24
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java111
17 files changed, 0 insertions, 940 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java
deleted file mode 100644
index f8a0e91a..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/ClientConfigurationEnvs.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-public enum ClientConfigurationEnvs {
- REQUEST_URL,
- REQUEST_TIMEOUT,
- OUTPUT_PATH,
- CA_NAME,
- OUTPUT_TYPE
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java
deleted file mode 100644
index d1cfcd5a..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/CsrConfigurationEnvs.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-public enum CsrConfigurationEnvs {
- COMMON_NAME,
- ORGANIZATION,
- ORGANIZATION_UNIT,
- LOCATION,
- STATE,
- COUNTRY,
- SANS
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java
deleted file mode 100644
index 15339bbd..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvProvider {
- public Optional<String> readEnvVariable(String envVariableName) {
- return Optional.ofNullable(getSystemEnv(envVariableName))
- .filter(EnvProvider::isEnvPresent);
- }
-
- String getSystemEnv(String envVariableName) {
- return System.getenv(envVariableName);
- }
-
- private static Boolean isEnvPresent(String envValue) {
- return !"".equals(envValue);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java
deleted file mode 100644
index 9321964c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForClient.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForClient {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getUrlToCertService() {
- return readEnv(ClientConfigurationEnvs.REQUEST_URL);
- }
-
- public Optional<String> getRequestTimeOut() {
- return readEnv(ClientConfigurationEnvs.REQUEST_TIMEOUT);
- }
-
- public Optional<String> getOutputPath() {
- return readEnv(ClientConfigurationEnvs.OUTPUT_PATH);
- }
-
- public Optional<String> getCaName() {
- return readEnv(ClientConfigurationEnvs.CA_NAME);
- }
-
- public Optional<String> getOutputType() {
- return readEnv(ClientConfigurationEnvs.OUTPUT_TYPE);
- }
-
- private Optional<String> readEnv(ClientConfigurationEnvs envName) {
- return envProvider.readEnvVariable(envName.toString());
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java
deleted file mode 100644
index 9a892b24..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForCsr.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForCsr {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getCommonName() {
- return readEnv(CsrConfigurationEnvs.COMMON_NAME);
- }
-
- public Optional<String> getOrganization() {
- return readEnv(CsrConfigurationEnvs.ORGANIZATION);
- }
-
- public Optional<String> getOrganizationUnit() {
- return readEnv(CsrConfigurationEnvs.ORGANIZATION_UNIT);
- }
-
- public Optional<String> getLocation() {
- return readEnv(CsrConfigurationEnvs.LOCATION);
- }
-
- public Optional<String> getState() {
- return readEnv(CsrConfigurationEnvs.STATE);
- }
-
- public Optional<String> getCountry() {
- return readEnv(CsrConfigurationEnvs.COUNTRY);
- }
-
- public Optional<String> getSubjectAlternativesName() {
- return readEnv(CsrConfigurationEnvs.SANS);
- }
-
- Optional<String> readEnv(CsrConfigurationEnvs envName) {
- return envProvider.readEnvVariable(envName.toString());
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java
deleted file mode 100644
index 55b536a7..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/EnvsForTls.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-import java.util.Optional;
-
-public class EnvsForTls {
- private final EnvProvider envProvider = new EnvProvider();
-
- public Optional<String> getKeystorePath() {
- return readEnv(TlsConfigurationEnvs.KEYSTORE_PATH);
- }
-
- public Optional<String> getKeystorePassword() {
- return readEnv(TlsConfigurationEnvs.KEYSTORE_PASSWORD);
- }
-
- public Optional<String> getTruststorePath() {
- return readEnv(TlsConfigurationEnvs.TRUSTSTORE_PATH);
- }
-
- public Optional<String> getTruststorePassword() {
- return readEnv(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD);
- }
-
- Optional<String> readEnv(TlsConfigurationEnvs envName) {
- return envProvider.readEnvVariable(envName.toString());
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java
deleted file mode 100644
index 4009a088..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/TlsConfigurationEnvs.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration;
-
-public enum TlsConfigurationEnvs {
- KEYSTORE_PATH,
- KEYSTORE_PASSWORD,
- TRUSTSTORE_PATH,
- TRUSTSTORE_PASSWORD
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java
deleted file mode 100644
index ea280736..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/ClientConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class ClientConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CLIENT_CONFIGURATION_EXCEPTION;
-
- public ClientConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java
deleted file mode 100644
index cf785a71..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/CsrConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CsrConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CSR_CONFIGURATION_EXCEPTION;
-
- public CsrConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java
deleted file mode 100644
index 91f164e3..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/exception/TlsConfigurationException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class TlsConfigurationException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.TLS_CONFIGURATION_EXCEPTION;
-
- public TlsConfigurationException(String message) {
- super(message);
- }
-
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
deleted file mode 100644
index 24ed8b0d..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.factory;
-
-
-import org.onap.aaf.certservice.client.certification.ArtifactsCreatorProvider;
-import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurationException;
-import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.ConfigurationModel;
-
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.regex.Pattern;
-
-public abstract class AbstractConfigurationFactory<T extends ConfigurationModel> {
-
- abstract T create() throws ClientConfigurationException, CsrConfigurationException;
-
- public boolean isPathValid(String path) {
- return path.matches("^/|(/[a-zA-Z0-9_-]+)+/?$");
- }
-
- public boolean isAlphaNumeric(String caName) {
- return caName.matches("^[a-zA-Z0-9]*$");
- }
-
- public boolean isCommonNameValid(String commonName) {
- return !isSpecialCharsPresent(commonName)
- && !isHttpProtocolsPresent(commonName)
- && !isIpAddressPresent(commonName)
- && !isPortNumberPresent(commonName);
- }
-
- public boolean isSpecialCharsPresent(String stringToCheck) {
- return Pattern.compile("[~#@*$+%!()?/{}<>\\|_^]").matcher(stringToCheck).find();
- }
-
- public boolean isCountryValid(String country) {
- return Arrays.asList(Locale.getISOCountries()).contains(country);
- }
-
- public boolean isOutputTypeValid(String outputType) {
- return Arrays.stream(ArtifactsCreatorProvider.values())
- .map(ArtifactsCreatorProvider::toString)
- .anyMatch(name -> name.equals(outputType));
- }
-
- private boolean isPortNumberPresent(String stringToCheck) {
- return Pattern.compile(":[0-9]{1,5}").matcher(stringToCheck).find();
- }
-
- private boolean isIpAddressPresent(String stringToCheck) {
- return Pattern.compile("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}").matcher(stringToCheck).find();
- }
-
- private boolean isHttpProtocolsPresent(String stringToCheck) {
- return Pattern.compile("[h][t][t][p][:][/][/]|[h][t][t][p][s][:][/][/]").matcher(stringToCheck).find();
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java
deleted file mode 100644
index d8498d84..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/ClientConfigurationFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.factory;
-
-import org.onap.aaf.certservice.client.configuration.ClientConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForClient;
-import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.ClientConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Optional;
-
-public class ClientConfigurationFactory extends AbstractConfigurationFactory<ClientConfiguration> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ClientConfigurationFactory.class);
- private final EnvsForClient envsForClient;
-
- public ClientConfigurationFactory(EnvsForClient envsForClient) {
- this.envsForClient = envsForClient;
- }
-
- @Override
- public ClientConfiguration create() throws ClientConfigurationException {
-
- ClientConfiguration configuration = new ClientConfiguration();
-
-
- envsForClient.getUrlToCertService()
- .map(configuration::setUrlToCertService);
-
- envsForClient.getRequestTimeOut()
- .map(timeout -> configuration.setRequestTimeout(Integer.valueOf(timeout)));
-
- envsForClient.getOutputPath()
- .filter(this::isPathValid)
- .map(configuration::setCertsOutputPath)
- .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.OUTPUT_PATH + " is invalid."));
-
- envsForClient.getCaName()
- .filter(this::isAlphaNumeric)
- .map(configuration::setCaName)
- .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.CA_NAME + " is invalid."));
-
- Optional<String> outputType = envsForClient.getOutputType();
-
- if (outputType.isPresent()) {
- outputType.filter(this::isOutputTypeValid)
- .map(configuration::setOutputType)
- .orElseThrow(() -> new ClientConfigurationException(ClientConfigurationEnvs.OUTPUT_TYPE + " is invalid."));
- }
-
- LOGGER.info("Successful validation of Client configuration. Configuration data: {}", configuration.toString());
-
- return configuration;
- }
-}
-
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java
deleted file mode 100644
index 1d4cf2b2..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/CsrConfigurationFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.factory;
-
-import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.EnvsForCsr;
-import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
-import org.onap.aaf.certservice.client.configuration.model.CsrConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class CsrConfigurationFactory extends AbstractConfigurationFactory<CsrConfiguration> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CsrConfigurationFactory.class);
- private final EnvsForCsr envsForCsr;
-
- public CsrConfigurationFactory(EnvsForCsr envsForCsr) {
- this.envsForCsr = envsForCsr;
- }
-
- @Override
- public CsrConfiguration create() throws CsrConfigurationException {
-
- CsrConfiguration configuration = new CsrConfiguration();
-
- envsForCsr.getCommonName()
- .filter(this::isCommonNameValid)
- .map(configuration::setCommonName)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.COMMON_NAME + " is invalid."));
-
- envsForCsr.getOrganization()
- .filter(org -> !isSpecialCharsPresent(org))
- .map(configuration::setOrganization)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.ORGANIZATION + " is invalid."));
-
- envsForCsr.getState()
- .map(configuration::setState)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.STATE + " is invalid."));
-
- envsForCsr.getCountry()
- .filter(this::isCountryValid)
- .map(configuration::setCountry)
- .orElseThrow(() -> new CsrConfigurationException(CsrConfigurationEnvs.COUNTRY + " is invalid."));
-
- envsForCsr.getOrganizationUnit()
- .map(configuration::setOrganizationUnit);
-
- envsForCsr.getLocation()
- .map(configuration::setLocation);
-
- envsForCsr.getSubjectAlternativesName()
- .map(configuration::setSubjectAlternativeNames);
-
- LOGGER.info("Successful validation of CSR configuration. Configuration data: {}", configuration.toString());
-
- return configuration;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java
deleted file mode 100644
index 7da8fa58..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/SslContextFactory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.factory;
-
-import org.apache.http.ssl.SSLContexts;
-import org.onap.aaf.certservice.client.configuration.EnvsForTls;
-import org.onap.aaf.certservice.client.configuration.TlsConfigurationEnvs;
-import org.onap.aaf.certservice.client.configuration.exception.TlsConfigurationException;
-
-import javax.net.ssl.SSLContext;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-
-public class SslContextFactory {
-
- private static final String JKS = "jks";
-
- private EnvsForTls envsForTls;
-
- public SslContextFactory(EnvsForTls envsForTls) {
- this.envsForTls = envsForTls;
- }
-
- public SSLContext create() throws TlsConfigurationException {
- String keystorePath = envsForTls.getKeystorePath()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.KEYSTORE_PATH)));
- String keystorePassword = envsForTls.getKeystorePassword()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.KEYSTORE_PASSWORD)));
- String truststorePath = envsForTls.getTruststorePath()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.TRUSTSTORE_PATH)));
- String truststorePassword = envsForTls.getTruststorePassword()
- .orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD)));
-
- return createSslContext(keystorePath, keystorePassword, truststorePath, truststorePassword);
- }
-
- private String createEnvMissingMessage(TlsConfigurationEnvs keystorePath) {
- return String.format("%s env is missing.", keystorePath);
- }
-
- private KeyStore setupKeystore(String keystorePath, String certPassword)
- throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
- KeyStore keyStore = KeyStore.getInstance(JKS);
- FileInputStream identityKeyStoreFile = new FileInputStream(new File(
- keystorePath));
- keyStore.load(identityKeyStoreFile, certPassword.toCharArray());
- return keyStore;
- }
-
- private SSLContext createSslContext(String keystorePath, String keystorePassword, String truststorePath, String truststorePassword) throws TlsConfigurationException {
- try {
- KeyStore identityKeystore = setupKeystore(keystorePath, keystorePassword);
- KeyStore trustKeystore = setupKeystore(truststorePath, truststorePassword);
-
- return SSLContexts.custom()
- .loadKeyMaterial(identityKeystore, keystorePassword.toCharArray())
- .loadTrustMaterial(trustKeystore, null)
- .build();
- } catch (Exception e) {
- throw new TlsConfigurationException("TLS configuration exception: " + e);
- }
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java
deleted file mode 100644
index 78fa1b4b..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ClientConfiguration.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.model;
-
-import org.onap.aaf.certservice.client.configuration.ClientConfigurationEnvs;
-
-public class ClientConfiguration implements ConfigurationModel {
-
- private static final Integer DEFAULT_TIMEOUT_MS = 30000;
- private static final String DEFAULT_REQUEST_URL = "https://aaf-cert-service:8443/v1/certificate/";
- private static final String DEFAULT_OUTPUT_TYPE = "P12";
-
- private String urlToCertService;
- private Integer requestTimeout;
- private String certsOutputPath;
- private String caName;
- private String outputType;
-
-
- public ClientConfiguration() {
- urlToCertService = DEFAULT_REQUEST_URL;
- requestTimeout = DEFAULT_TIMEOUT_MS;
- outputType = DEFAULT_OUTPUT_TYPE;
- }
-
-
- public String getUrlToCertService() {
- return urlToCertService;
- }
-
- public ClientConfiguration setUrlToCertService(String urlToCertService) {
- this.urlToCertService = urlToCertService;
- return this;
- }
-
- public Integer getRequestTimeout() {
- return requestTimeout;
- }
-
- public ClientConfiguration setRequestTimeout(Integer requestTimeout) {
- this.requestTimeout = requestTimeout;
- return this;
- }
-
- public String getCertsOutputPath() {
- return certsOutputPath;
- }
-
- public ClientConfiguration setCertsOutputPath(String certsOutputPath) {
- this.certsOutputPath = certsOutputPath;
- return this;
- }
-
- public String getCaName() {
- return caName;
- }
-
- public ClientConfiguration setCaName(String caName) {
- this.caName = caName;
- return this;
- }
-
- public String getOutputType() {
- return outputType;
- }
-
- public ClientConfiguration setOutputType(String outputType) {
- this.outputType = outputType;
- return this;
- }
-
- @Override
- public String toString() {
- return String.format("%s: %s, %s: %s, %s: %s, %s: %s, %s: %s",
- ClientConfigurationEnvs.REQUEST_URL, urlToCertService,
- ClientConfigurationEnvs.REQUEST_TIMEOUT, requestTimeout,
- ClientConfigurationEnvs.OUTPUT_PATH, certsOutputPath,
- ClientConfigurationEnvs.CA_NAME, caName,
- ClientConfigurationEnvs.OUTPUT_TYPE, outputType);
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java
deleted file mode 100644
index 15c22233..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/ConfigurationModel.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.model;
-
-public interface ConfigurationModel {
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java
deleted file mode 100644
index 55f33c9f..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/model/CsrConfiguration.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * aaf-certservice-client
- * ================================================================================
- * 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.aaf.certservice.client.configuration.model;
-
-
-import org.onap.aaf.certservice.client.configuration.CsrConfigurationEnvs;
-
-public class CsrConfiguration implements ConfigurationModel {
-
- private String commonName;
- private String organization;
- private String state;
- private String country;
- private String organizationUnit;
- private String location;
- private String sans;
-
-
- public String getCommonName() {
- return commonName;
- }
-
- public CsrConfiguration setCommonName(String commonName) {
- this.commonName = commonName;
- return this;
- }
-
- public String getOrganization() {
- return organization;
- }
-
- public CsrConfiguration setOrganization(String organization) {
- this.organization = organization;
- return this;
- }
-
- public String getState() {
- return state;
- }
-
- public CsrConfiguration setState(String state) {
- this.state = state;
- return this;
- }
-
- public String getCountry() {
- return country;
- }
-
- public CsrConfiguration setCountry(String country) {
- this.country = country;
- return this;
- }
-
- public String getOrganizationUnit() {
- return organizationUnit;
- }
-
- public CsrConfiguration setOrganizationUnit(String organizationUnit) {
- this.organizationUnit = organizationUnit;
- return this;
- }
-
- public String getLocation() {
- return location;
- }
-
- public CsrConfiguration setLocation(String location) {
- this.location = location;
- return this;
- }
-
- public String getSans() {
- return sans;
- }
-
- public CsrConfiguration setSubjectAlternativeNames(String subjectAlternativeNames) {
- this.sans = subjectAlternativeNames;
- return this;
- }
-
- @Override
- public String toString() {
- return String.format("%s: %s, %s: %s, %s: %s, %s: %s, %s: %s, %s: %s, %s: %s",
- CsrConfigurationEnvs.COMMON_NAME, commonName,
- CsrConfigurationEnvs.COUNTRY, country,
- CsrConfigurationEnvs.STATE, state,
- CsrConfigurationEnvs.ORGANIZATION, organization,
- CsrConfigurationEnvs.ORGANIZATION_UNIT, organizationUnit,
- CsrConfigurationEnvs.LOCATION, location,
- CsrConfigurationEnvs.SANS, sans);
- }
-}