aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient
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 /certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient
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 'certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java51
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java111
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java41
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java37
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java44
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java35
6 files changed, 0 insertions, 319 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.java
deleted file mode 100644
index 3b7a46ab..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/CloseableHttpsClientProvider.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.httpclient;
-
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-
-import javax.net.ssl.SSLContext;
-
-public class CloseableHttpsClientProvider {
-
- private final int timeout;
- private final SSLContext sslContext;
-
- public CloseableHttpsClientProvider(SSLContext sslContext, int timeout) {
- this.sslContext = sslContext;
- this.timeout = timeout;
- }
-
- public CloseableHttpClient getClient() {
- RequestConfig config =
- RequestConfig.custom()
- .setConnectionRequestTimeout(timeout)
- .setConnectTimeout(timeout)
- .setSocketTimeout(timeout)
- .build();
-
- return HttpClientBuilder.create()
- .setSSLContext(sslContext)
- .setDefaultRequestConfig(config).build();
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.java
deleted file mode 100644
index 0780afad..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/HttpClient.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.httpclient;
-
-import com.google.gson.Gson;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.onap.aaf.certservice.client.httpclient.exception.CertServiceApiResponseException;
-import org.onap.aaf.certservice.client.httpclient.exception.HttpClientException;
-import org.onap.aaf.certservice.client.httpclient.model.CertServiceResponse;
-import org.onap.aaf.certservice.client.httpclient.model.ErrorCertServiceResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class HttpClient {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HttpClient.class);
- private static final String CSR_HEADER_NAME = "CSR";
- private static final String PK_HEADER_NAME = "PK";
- private static final String CHARSET_UTF_8 = "UTF-8";
-
- private final Gson gson = new Gson();
- private final CloseableHttpsClientProvider httpClientProvider;
- private final String certServiceAddress;
-
- public HttpClient(CloseableHttpsClientProvider httpClientProvider, String certServiceAddress) {
- this.httpClientProvider = httpClientProvider;
- this.certServiceAddress = certServiceAddress;
- }
-
- public CertServiceResponse retrieveCertServiceData(String caName, String csr, String encodedPk)
- throws CertServiceApiResponseException, HttpClientException {
-
- try (CloseableHttpClient httpClient = httpClientProvider.getClient()) {
- LOGGER.info("Attempt to send request to API, on url: {}{} ", certServiceAddress, caName);
- HttpResponse httpResponse = httpClient.execute(createHttpRequest(caName, csr, encodedPk));
- LOGGER.info("Received response from API");
- return extractCertServiceResponse(httpResponse);
-
- } catch (IOException e) {
- LOGGER.error("Failed execute request to API for URL: {}{} , exception message: {}",
- certServiceAddress, caName, e.getMessage());
- throw new HttpClientException(e);
- }
- }
-
- private HttpGet createHttpRequest(String caName, String csr, String pk) {
- String url = certServiceAddress + caName;
- HttpGet httpGet = new HttpGet(url);
- httpGet.addHeader(CSR_HEADER_NAME, csr);
- httpGet.addHeader(PK_HEADER_NAME, pk);
- return httpGet;
- }
-
- private CertServiceResponse extractCertServiceResponse(HttpResponse httpResponse)
- throws CertServiceApiResponseException, HttpClientException {
- int httpResponseCode = getStatusCode(httpResponse);
- if (HttpStatus.SC_OK != httpResponseCode) {
- LOGGER.error("Error on API response. Response Code: {}", httpResponseCode);
- throw generateApiResponseException(httpResponse);
- }
- String jsonResponse = getStringResponse(httpResponse.getEntity());
- return gson.fromJson(jsonResponse, CertServiceResponse.class);
- }
-
- private CertServiceApiResponseException generateApiResponseException(HttpResponse httpResponse)
- throws HttpClientException {
- String stringResponse = getStringResponse(httpResponse.getEntity());
- ErrorCertServiceResponse errorCertServiceResponse =
- gson.fromJson(stringResponse, ErrorCertServiceResponse.class);
-
- return new CertServiceApiResponseException(getStatusCode(httpResponse), errorCertServiceResponse.getMessage());
- }
-
- private int getStatusCode(HttpResponse httpResponse) {
- return httpResponse.getStatusLine().getStatusCode();
- }
-
- private String getStringResponse(HttpEntity httpEntity) throws HttpClientException {
- try {
- return EntityUtils.toString(httpEntity, CHARSET_UTF_8);
- } catch (IOException e) {
- LOGGER.error("Cannot parse response to string, exception message: {}", e.getMessage());
- throw new HttpClientException(e);
- }
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java
deleted file mode 100644
index ad5a5f1c..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/CertServiceApiResponseException.java
+++ /dev/null
@@ -1,41 +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.httpclient.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class CertServiceApiResponseException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.CERT_SERVICE_API_CONNECTION_EXCEPTION;
-
- public CertServiceApiResponseException(int responseCode, String messageFromApi) {
-
- super(String.format("CertService HTTP unsuccessful response. Response code: %d . Message from Service: %s",
- responseCode,
- messageFromApi));
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java
deleted file mode 100644
index e9f0f0ad..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/exception/HttpClientException.java
+++ /dev/null
@@ -1,37 +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.httpclient.exception;
-
-import org.onap.aaf.certservice.client.api.ExitStatus;
-import org.onap.aaf.certservice.client.api.ExitableException;
-
-public class HttpClientException extends ExitableException {
- private static final ExitStatus EXIT_STATUS = ExitStatus.HTTP_CLIENT_EXCEPTION;
-
- public HttpClientException(Throwable cause) {
- super(cause);
- }
-
- @Override
- public ExitStatus applicationExitStatus() {
- return EXIT_STATUS;
- }
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java
deleted file mode 100644
index 4ca17999..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/CertServiceResponse.java
+++ /dev/null
@@ -1,44 +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.httpclient.model;
-
-import java.util.Collections;
-import java.util.List;
-
-public class CertServiceResponse {
-
- private final List<String> certificateChain;
- private final List<String> trustedCertificates;
-
- public CertServiceResponse(List<String> certificateChain, List<String> trustedCertificates) {
- this.certificateChain = certificateChain;
- this.trustedCertificates = trustedCertificates;
- }
-
- public List<String> getCertificateChain() {
- return Collections.unmodifiableList(certificateChain);
- }
-
- public List<String> getTrustedCertificates() {
- return Collections.unmodifiableList(trustedCertificates);
- }
-
-}
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java
deleted file mode 100644
index 4a9efcb4..00000000
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/httpclient/model/ErrorCertServiceResponse.java
+++ /dev/null
@@ -1,35 +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.httpclient.model;
-
-public class ErrorCertServiceResponse {
-
- private final String errorMessage;
-
- public ErrorCertServiceResponse(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public String getMessage() {
- return errorMessage;
- }
-
-}