summaryrefslogtreecommitdiffstats
path: root/certService/src/main/java/org/onap/aaf/certservice/certification/configuration
diff options
context:
space:
mode:
authorbaniewsk <pawel.baniewski@nokia.com>2020-07-29 16:01:27 +0200
committerPawel <pawel.kasperkiewicz@nokia.com>2020-08-05 14:18:54 +0200
commitb8c4e6867d6b26652f4382e93665c220769cdc9f (patch)
treebb60a44b012731e3ee6fdffe2466f5ed7d6b5c7b /certService/src/main/java/org/onap/aaf/certservice/certification/configuration
parentfc31c9e47b3e08f8914dcd1f0c5b6d18aa625567 (diff)
Removing AAF references from Cert-Service in OOM repo.
Certificates regenerated External files (from legacy AAF) removed Still left: * Sonar link, * Link to documentation, * Names of K8s resources in RTD documentation, * Link to CSITs Issue-ID: OOM-2526 Signed-off-by: Pawel Baniewski <pawel.baniewski@nokia.com> Change-Id: I675f7485160b9b8e46e9ea573550e62ed28ca607
Diffstat (limited to 'certService/src/main/java/org/onap/aaf/certservice/certification/configuration')
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java50
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java87
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java64
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java32
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java43
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java60
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java35
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java37
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java98
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java68
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java41
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java55
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java43
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java49
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java25
15 files changed, 0 insertions, 787 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java
deleted file mode 100644
index 329098ac..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpClientConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Cert Service
- * ================================================================================
- * 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.certification.configuration;
-
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.onap.aaf.certservice.cmpv2client.api.CmpClient;
-import org.onap.aaf.certservice.cmpv2client.impl.CmpClientImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.context.annotation.RequestScope;
-
-@Configuration
-public class CmpClientConfig {
-
- @Bean
- CmpClient cmpClient(CloseableHttpClient closeableHttpClient) {
- return new CmpClientImpl(closeableHttpClient);
- }
-
- @Bean
- @RequestScope
- CloseableHttpClient closeableHttpClient(HttpClientBuilder httpClientBuilder) {
- return httpClientBuilder.build();
- }
-
- @Bean
- HttpClientBuilder httpClientBuilder() {
- return HttpClientBuilder.create();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java
deleted file mode 100644
index cea228c1..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class CmpServersConfig {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CmpServersConfig.class);
- private static final String INIT_CONFIGURATION = "Loading initial configuration";
- private static final String RELOADING_CONFIGURATION = "Reloading configuration";
- private static final String LOADING_SUCCESS_MESSAGE = "CMP Servers configuration successfully loaded from file {}";
- private static final String CMP_SERVERS_CONFIG_FILENAME = "cmpServers.json";
-
- private final String configPath;
- private final CmpServersConfigLoader cmpServersConfigLoader;
-
- private List<Cmpv2Server> cmpServers;
- private volatile boolean isReady;
-
- @Autowired
- public CmpServersConfig(@Value("${app.config.path}") String configPath,
- CmpServersConfigLoader cmpServersConfigLoader) {
- this.cmpServersConfigLoader = cmpServersConfigLoader;
- this.configPath = configPath;
- }
-
- @PostConstruct
- void init() {
- try {
- LOGGER.info(INIT_CONFIGURATION);
- loadConfiguration();
- } catch (CmpServersConfigLoadingException e) {
- LOGGER.error(e.getMessage(), e.getCause());
- }
- }
-
- public void reloadConfiguration() throws CmpServersConfigLoadingException {
- LOGGER.info(RELOADING_CONFIGURATION);
- loadConfiguration();
- }
-
-
- synchronized void loadConfiguration() throws CmpServersConfigLoadingException {
- isReady = false;
- String configFilePath = configPath + File.separator + CMP_SERVERS_CONFIG_FILENAME;
- this.cmpServers = Collections.unmodifiableList(cmpServersConfigLoader.load(configFilePath));
- LOGGER.info(LOADING_SUCCESS_MESSAGE, configFilePath);
- isReady = true;
- }
-
- public List<Cmpv2Server> getCmpServers() {
- return cmpServers;
- }
-
- public boolean isReady() {
- return isReady;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java
deleted file mode 100644
index 101712e2..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoader.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.File;
-import java.io.IOException;
-import java.security.InvalidParameterException;
-import java.util.List;
-
-import org.onap.aaf.certservice.certification.configuration.model.CmpServers;
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.configuration.validation.Cmpv2ServersConfigurationValidator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-class CmpServersConfigLoader {
-
- private static final String LOADING_EXCEPTION_MESSAGE = "Exception occurred during CMP Servers configuration loading";
- private static final String VALIDATION_EXCEPTION_MESSAGE = "Validation of CMPv2 servers configuration failed";
-
- private final Cmpv2ServersConfigurationValidator validator;
-
- @Autowired
- CmpServersConfigLoader(Cmpv2ServersConfigurationValidator validator) {
- this.validator = validator;
- }
-
- List<Cmpv2Server> load(String path) throws CmpServersConfigLoadingException {
- try {
- List<Cmpv2Server> servers = loadConfigFromFile(path).getCmpv2Servers();
- validator.validate(servers);
- return servers;
- } catch (IOException e) {
- throw new CmpServersConfigLoadingException(LOADING_EXCEPTION_MESSAGE, e);
- } catch (InvalidParameterException e) {
- throw new CmpServersConfigLoadingException(VALIDATION_EXCEPTION_MESSAGE, e);
- }
- }
-
- private CmpServers loadConfigFromFile(String path) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(new File(path), CmpServers.class);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java
deleted file mode 100644
index b7c3638d..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfigLoadingException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration;
-
-public class CmpServersConfigLoadingException extends Exception {
-
- public CmpServersConfigLoadingException(String message) {
- super(message);
- }
-
- public CmpServersConfigLoadingException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java
deleted file mode 100644
index 190bb28a..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/Cmpv2ServerProvider.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration;
-
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Cmpv2ServerProvider {
-
- private final CmpServersConfig cmpServersConfig;
-
- @Autowired
- Cmpv2ServerProvider(CmpServersConfig cmpServersConfig) {
- this.cmpServersConfig = cmpServersConfig;
- }
-
- public Cmpv2Server getCmpv2Server(String caName) {
- return cmpServersConfig.getCmpServers().stream().filter(server -> server.getCaName().equals(caName)).findFirst()
- .orElseThrow(() -> new Cmpv2ServerNotFoundException("No server found for given CA name"));
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java
deleted file mode 100644
index e4c15518..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Authentication.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.model;
-
-import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.Length;
-
-public class Authentication {
-
- private static final int MAX_IAK_RV_LENGTH = 256;
-
- @NotNull
- @Length(min = 1, max = MAX_IAK_RV_LENGTH)
- private String iak;
- @NotNull
- @Length(min = 1, max = MAX_IAK_RV_LENGTH)
- private String rv;
-
- public String getIak() {
- return iak;
- }
-
- public void setIak(String iak) {
- this.iak = iak;
- }
-
- public String getRv() {
- return rv;
- }
-
- public void setRv(String rv) {
- this.rv = rv;
- }
-
- @Override
- public String toString() {
- return "Authentication{"
- + " iak=*****"
- + ", rv=*****"
- + '}';
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java
deleted file mode 100644
index 374feb3b..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CaMode.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.model;
-
-public enum CaMode {
- RA("RA"), CLIENT("Client");
-
- private String profile;
-
- CaMode(String profile) {
- this.profile = profile;
- }
-
- public String getProfile() {
- return profile;
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java
deleted file mode 100644
index 7fac1887..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/CmpServers.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.model;
-
-import java.util.List;
-
-public class CmpServers {
-
- private List<Cmpv2Server> cmpv2Servers;
-
- public List<Cmpv2Server> getCmpv2Servers() {
- return cmpv2Servers;
- }
-
- public void setCmpv2Servers(List<Cmpv2Server> cmpv2Servers) {
- this.cmpv2Servers = cmpv2Servers;
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java
deleted file mode 100644
index 51d91966..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/model/Cmpv2Server.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.model;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import org.bouncycastle.asn1.x500.X500Name;
-import org.hibernate.validator.constraints.Length;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.Cmpv2Url;
-
-public class Cmpv2Server {
-
- private static final int MAX_CA_NAME_LENGTH = 128;
-
- @NotNull
- @Valid
- private Authentication authentication;
- @NotNull
- private CaMode caMode;
- @NotNull
- @Length(min = 1, max = MAX_CA_NAME_LENGTH)
- private String caName;
- @NotNull
- private X500Name issuerDN;
- @Cmpv2Url
- private String url;
-
- public Authentication getAuthentication() {
- return authentication;
- }
-
- public void setAuthentication(Authentication authentication) {
- this.authentication = authentication;
- }
-
- public CaMode getCaMode() {
- return caMode;
- }
-
- public void setCaMode(CaMode caMode) {
- this.caMode = caMode;
- }
-
- public String getCaName() {
- return caName;
- }
-
- public void setCaName(String caName) {
- this.caName = caName;
- }
-
- public X500Name getIssuerDN() {
- return issuerDN;
- }
-
- public void setIssuerDN(X500Name issuerDN) {
- this.issuerDN = issuerDN;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Override
- public String toString() {
- return "Cmpv2Server{"
- + "authentication=" + authentication
- + ", caMode=" + caMode
- + ", caName='" + caName + '\''
- + ", issuerDN='" + issuerDN + '\''
- + ", url='" + url + '\''
- + '}';
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java
deleted file mode 100644
index 3cf7fdf7..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServersConfigurationValidator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation;
-
-import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-import java.security.InvalidParameterException;
-import java.util.List;
-import java.util.Set;
-
-@Service
-public class Cmpv2ServersConfigurationValidator {
-
- private final Validator validator;
-
- @Autowired
- public Cmpv2ServersConfigurationValidator(Validator validator) {
- this.validator = validator;
- }
-
- public void validate(List<Cmpv2Server> servers) {
- servers.forEach(this::validateServer);
- validateUniqueCaNames(servers);
- }
-
- private void validateServer(Cmpv2Server serverDetails) {
- Set<ConstraintViolation<Cmpv2Server>> violations = validator.validate(serverDetails);
- if (!violations.isEmpty()) {
- throw new InvalidParameterException(violations.toString());
- }
- }
-
- private void validateUniqueCaNames(List<Cmpv2Server> servers) {
- long distinctCAs = getNumberOfUniqueCaNames(servers);
- if (servers.size() != distinctCAs) {
- throw new InvalidParameterException("CA names are not unique within given CMPv2 servers");
- }
- }
-
- private long getNumberOfUniqueCaNames(List<Cmpv2Server> servers) {
- return servers.stream().map(Cmpv2Server::getCaName)
- .distinct()
- .count();
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java
deleted file mode 100644
index a5450a25..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2Url.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation.constraints;
-
-import javax.validation.Constraint;
-import javax.validation.Payload;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Target({FIELD, ANNOTATION_TYPE})
-@Retention(RUNTIME)
-@Constraint(validatedBy = Cmpv2UrlValidator.class)
-public @interface Cmpv2Url {
- String message() default "Server URL is invalid.";
-
- Class<?>[] groups() default {};
-
- Class<? extends Payload>[] payload() default {};
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java
deleted file mode 100644
index 7ce3bb6c..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/Cmpv2UrlValidator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation.constraints;
-
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.PortNumberViolation;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.RequestTypeViolation;
-import org.onap.aaf.certservice.certification.configuration.validation.constraints.violations.UrlServerViolation;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-class Cmpv2UrlValidator implements ConstraintValidator<Cmpv2Url, String> {
-
- private final List<UrlServerViolation> violations;
-
- Cmpv2UrlValidator() {
- this.violations = Arrays.asList(
- new PortNumberViolation(),
- new RequestTypeViolation()
- );
- }
-
- @Override
- public boolean isValid(String url, ConstraintValidatorContext context) {
- AtomicBoolean isValid = new AtomicBoolean(true);
- violations.forEach(violation -> {
- if (!violation.validate(url)) {
- isValid.set(false);
- }
- });
- return isValid.get();
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java
deleted file mode 100644
index 96f30149..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/PortNumberViolation.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation.constraints.violations;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class PortNumberViolation implements UrlServerViolation {
-
- private static final int MIN_PORT = 1;
- private static final int MAX_PORT = 65535;
- private static final int PORT_UNDEFINED = -1;
-
- @Override
- public boolean validate(String serverUrl) {
- try {
- URL url = new URL(serverUrl);
- int port = url.getPort();
- return port >= MIN_PORT && port <= MAX_PORT || port == PORT_UNDEFINED;
- } catch (MalformedURLException e) {
- return false;
- }
- }
-
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java
deleted file mode 100644
index 67a5c3c4..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/RequestTypeViolation.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation.constraints.violations;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class RequestTypeViolation implements UrlServerViolation {
-
- private static final List<String> VALID_REQUESTS = Collections.singletonList("http");
-
- @Override
- public boolean validate(String serverUrl) {
- try {
- AtomicBoolean isValid = new AtomicBoolean(false);
- String protocol = new URL(serverUrl).getProtocol();
- VALID_REQUESTS.forEach(requestType -> {
- if (protocol.equals(requestType)) {
- isValid.set(true);
- }
- });
- return isValid.get();
- } catch (MalformedURLException e) {
- return false;
- }
- }
-}
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java
deleted file mode 100644
index 5452beb4..00000000
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/validation/constraints/violations/UrlServerViolation.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.certification.configuration.validation.constraints.violations;
-
-public interface UrlServerViolation {
- boolean validate(String url);
-}