aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services/dmaap-client/src/main/java
diff options
context:
space:
mode:
authorMarcin Migdal <marcin.migdal@nokia.com>2019-03-07 15:02:24 +0100
committerMarcin Migdal <marcin.migdal@nokia.com>2019-03-08 12:47:13 +0100
commit522a1c9dde168f0baa32a52a80a1b85b0b4812f9 (patch)
tree55f72ca7984183f2ae9072bd69935805a7eec492 /rest-services/dmaap-client/src/main/java
parent3666e89b3411e84b138279cccc8130df60c81f4c (diff)
DMaaP client remove Spring
Change-Id: I9e0206d4b3c737df8a80944f0050871c1ad307c6 Issue-ID: DCAEGEN2-1310 Signed-off-by: Marcin Migdal <marcin.migdal@nokia.com>
Diffstat (limited to 'rest-services/dmaap-client/src/main/java')
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java2
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java37
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java49
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java37
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java71
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java102
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java10
7 files changed, 156 insertions, 152 deletions
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java
index f7107f7c..75816ea4 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/config/DmaapConsumerConfiguration.java
@@ -22,12 +22,10 @@ package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
-import org.springframework.stereotype.Component;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
-@Component
@Value.Immutable(prehash = true)
@Value.Style(builder = "new")
@Gson.TypeAdapters
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java
new file mode 100644
index 00000000..55fa7fb7
--- /dev/null
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPAbstractReactiveHttpClient.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. 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.dcaegen2.services.sdk.rest.services.dmaap.client.service;
+
+import java.util.UUID;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.ImmutableRequestDiagnosticContext;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
+
+public abstract class DMaaPAbstractReactiveHttpClient {
+
+ protected final static String SLASH = "/";
+
+ protected RequestDiagnosticContext getRequestDiagnosticContext() {
+ return ImmutableRequestDiagnosticContext.builder()
+ .invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build();
+ }
+
+
+}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java
new file mode 100644
index 00000000..3876b527
--- /dev/null
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/DMaaPClientServiceUtils.java
@@ -0,0 +1,49 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. 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.dcaegen2.services.sdk.rest.services.dmaap.client.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:marcin.wmigdal@nokia.com">Marcin Migdal</a> on 3/8/2019
+ */
+public final class DMaaPClientServiceUtils {
+
+ public final static String CONTENT_TYPE = "Content-Type";
+
+ private DMaaPClientServiceUtils() {
+
+ }
+
+ /**
+ * Method generates headers for HTTP requests
+ * @param contentType contentType to be used in HTTP header*
+ * @return Map of Headers
+ * */
+ public static Map<String, String> getHeaders(String contentType) {
+ Map<String, String> header = new HashMap<>();
+ header.put(CONTENT_TYPE, contentType);
+ return header;
+ }
+
+
+}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java
index 99f70209..d0f95f6e 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPConsumerReactiveHttpClient.java
@@ -21,12 +21,13 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer;
import java.net.URI;
-import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPAbstractReactiveHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.ImmutableRequestDiagnosticContext;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder;
@@ -36,17 +37,9 @@ import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/26/18
*/
-public class DMaaPConsumerReactiveHttpClient {
+public class DMaaPConsumerReactiveHttpClient extends DMaaPAbstractReactiveHttpClient {
- private final static String SLASH = "/";
- private final static String CONTENT_TYPE = "Content-Type";
- private final String dmaapHostName;
- private final String dmaapProtocol;
- private final Integer dmaapPortNumber;
- private final String dmaapTopicName;
- private final String consumerGroup;
- private final String consumerId;
- private final String contentType;
+ private final DmaapConsumerConfiguration consumerConfiguration;
private final CloudHttpClient cloudHttpClient;
/**
@@ -57,13 +50,7 @@ public class DMaaPConsumerReactiveHttpClient {
public DMaaPConsumerReactiveHttpClient(DmaapConsumerConfiguration consumerConfiguration,
CloudHttpClient cloudHttpClient) {
- this.dmaapHostName = consumerConfiguration.dmaapHostName();
- this.dmaapProtocol = consumerConfiguration.dmaapProtocol();
- this.dmaapPortNumber = consumerConfiguration.dmaapPortNumber();
- this.dmaapTopicName = consumerConfiguration.dmaapTopicName();
- this.consumerGroup = consumerConfiguration.consumerGroup();
- this.consumerId = consumerConfiguration.consumerId();
- this.contentType = consumerConfiguration.dmaapContentType();
+ this.consumerConfiguration = consumerConfiguration;
this.cloudHttpClient = cloudHttpClient;
}
@@ -73,10 +60,10 @@ public class DMaaPConsumerReactiveHttpClient {
* @return reactive response from DMaaP in string format
*/
public Mono<String> getDMaaPConsumerResponse(Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) {
- Map<String,String> headers = new HashMap<>();
- headers.put(CONTENT_TYPE,contentType);
+ Map<String,String> headers = DMaaPClientServiceUtils.getHeaders(consumerConfiguration.dmaapContentType());
if (requestDiagnosticContextOptional.isPresent()) {
- return cloudHttpClient.get(getUri().toString(), requestDiagnosticContextOptional.get(),headers, String.class);
+ return cloudHttpClient
+ .get(getUri().toString(), requestDiagnosticContextOptional.get(), headers, String.class);
}
RequestDiagnosticContext requestDiagnosticContext = ImmutableRequestDiagnosticContext.builder()
.invocationId(UUID.randomUUID()).requestId(UUID.randomUUID()).build();
@@ -85,12 +72,14 @@ public class DMaaPConsumerReactiveHttpClient {
URI getUri() {
return URI.create(
- new URIBuilder().scheme(dmaapProtocol).host(dmaapHostName).port(dmaapPortNumber).path(createRequestPath())
+ new URIBuilder().scheme(consumerConfiguration.dmaapProtocol()).host(consumerConfiguration.dmaapHostName())
+ .port(consumerConfiguration.dmaapPortNumber()).path(createRequestPath())
.build().toString());
}
private String createRequestPath() {
- return new StringBuilder().append(SLASH).append(dmaapTopicName).append(SLASH).append(consumerGroup)
- .append(SLASH).append(consumerId).toString();
+ return new StringBuilder().append(SLASH).append(consumerConfiguration.dmaapTopicName()).append(SLASH)
+ .append(consumerConfiguration.consumerGroup())
+ .append(SLASH).append(consumerConfiguration.consumerId()).toString();
}
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
index 39fdb32c..6314bcba 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DMaaPPublisherReactiveHttpClient.java
@@ -21,55 +21,39 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer;
-import static org.onap.dcaegen2.services.sdk.rest.services.model.logging.MdcVariables.REQUEST_ID;
-import static org.onap.dcaegen2.services.sdk.rest.services.model.logging.MdcVariables.X_INVOCATION_ID;
-import static org.onap.dcaegen2.services.sdk.rest.services.model.logging.MdcVariables.X_ONAP_REQUEST_ID;
-
import java.net.URI;
-import java.util.UUID;
+import java.util.Map;
+import java.util.Optional;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPAbstractReactiveHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.DMaaPClientServiceUtils;
import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel;
import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
*/
-public class DMaaPPublisherReactiveHttpClient {
+public class DMaaPPublisherReactiveHttpClient extends DMaaPAbstractReactiveHttpClient {
- private final static String SLASH = "/";
- private final Logger logger = LoggerFactory.getLogger(DMaaPPublisherReactiveHttpClient.class);
- private final String dmaapHostName;
- private final Integer dmaapPortNumber;
- private final String dmaapProtocol;
- private final String dmaapTopicName;
- private final String dmaapContentType;
- private final Mono<RestTemplate> restTemplateMono;
+ private final DmaapPublisherConfiguration dmaapPublisherConfiguration;
private final JsonBodyBuilder jsonBodyBuilder;
+ private final CloudHttpClient cloudHttpClient;
/**
* Constructor DMaaPPublisherReactiveHttpClient.
*
* @param dmaapPublisherConfiguration - DMaaP producer configuration object
+ * @param cloudHttpClient - cloudHttpClient sending http requests
*/
DMaaPPublisherReactiveHttpClient(DmaapPublisherConfiguration dmaapPublisherConfiguration,
- Mono<RestTemplate> restTemplateMono, JsonBodyBuilder jsonBodyBuilder) {
- this.dmaapHostName = dmaapPublisherConfiguration.dmaapHostName();
- this.dmaapProtocol = dmaapPublisherConfiguration.dmaapProtocol();
- this.dmaapPortNumber = dmaapPublisherConfiguration.dmaapPortNumber();
- this.dmaapTopicName = dmaapPublisherConfiguration.dmaapTopicName();
- this.dmaapContentType = dmaapPublisherConfiguration.dmaapContentType();
- this.restTemplateMono = restTemplateMono;
+ CloudHttpClient cloudHttpClient, JsonBodyBuilder jsonBodyBuilder) {
+ this.dmaapPublisherConfiguration = dmaapPublisherConfiguration;
+ this.cloudHttpClient = cloudHttpClient;
this.jsonBodyBuilder = jsonBodyBuilder;
}
@@ -80,32 +64,31 @@ public class DMaaPPublisherReactiveHttpClient {
* @return status code of operation
*/
- public Mono<ResponseEntity<String>> getDMaaPProducerResponse(DmaapModel dmaapModel) {
+ public Mono<Integer> getDMaaPProducerResponse(DmaapModel dmaapModel,
+ Optional<RequestDiagnosticContext> requestDiagnosticContextOptional) {
return Mono.defer(() -> {
- HttpEntity<String> request = new HttpEntity<>(jsonBodyBuilder.createJsonBody(dmaapModel), getAllHeaders());
- logger.info("Request: {} {}", getUri(), request);
- return restTemplateMono.map(
- restTemplate -> restTemplate.exchange(getUri(), HttpMethod.POST, request, String.class));
+ Map<String, String> headers = DMaaPClientServiceUtils.getHeaders(dmaapPublisherConfiguration.dmaapContentType());
+ if (requestDiagnosticContextOptional.isPresent()) {
+ cloudHttpClient
+ .post(getUri().toString(), requestDiagnosticContextOptional.get(), headers, jsonBodyBuilder,
+ dmaapModel);
+ }
+ return cloudHttpClient
+ .post(getUri().toString(), getRequestDiagnosticContext(), headers, jsonBodyBuilder, dmaapModel);
});
}
- private HttpHeaders getAllHeaders() {
- HttpHeaders headers = new HttpHeaders();
- headers.set(X_ONAP_REQUEST_ID, MDC.get(REQUEST_ID));
- headers.set(X_INVOCATION_ID, UUID.randomUUID().toString());
- headers.set(HttpHeaders.CONTENT_TYPE, dmaapContentType);
- return headers;
-
- }
URI getUri() {
return URI.create(
- new URIBuilder().scheme(dmaapProtocol).host(dmaapHostName).port(dmaapPortNumber).path(createRequestPath())
+ new URIBuilder().scheme(dmaapPublisherConfiguration.dmaapProtocol())
+ .host(dmaapPublisherConfiguration.dmaapHostName()).port(dmaapPublisherConfiguration.dmaapPortNumber())
+ .path(createRequestPath())
.build().toString());
}
private String createRequestPath() {
- return new StringBuilder().append(SLASH).append(dmaapTopicName).toString();
+ return new StringBuilder().append(SLASH).append(dmaapPublisherConfiguration.dmaapTopicName()).toString();
}
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java
index fe2b2c10..765c64b7 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java
@@ -20,96 +20,42 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
-import javax.net.ssl.SSLContext;
-import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContextBuilder;
+import io.netty.handler.ssl.SslContext;
+import javax.net.ssl.SSLException;
+import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.CloudHttpClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.web.client.RestTemplate;
-import reactor.core.publisher.Mono;
+import org.onap.dcaegen2.services.sdk.rest.services.ssl.SslFactory;
public class DmaaPRestTemplateFactory {
+ private SslFactory sslFactory;
+
+ public DmaaPRestTemplateFactory() {
+ this(new SslFactory());
+ }
+
+ DmaaPRestTemplateFactory(SslFactory sslFactory) {
+ this.sslFactory = sslFactory;
+ }
+
/**
* Function for creating RestTemplate object.
*
* @param publisherConfiguration - DMaaP publisher configuration object
* @return RestTemplate with correct ssl configuration
*/
- public Mono<RestTemplate> build(DmaapPublisherConfiguration publisherConfiguration) {
- if (publisherConfiguration.enableDmaapCertAuth()) {
- return createRestTemplateWithSslSetup(publisherConfiguration);
- }
-
- return Mono.just(new RestTemplate());
+ public CloudHttpClient build(DmaapPublisherConfiguration publisherConfiguration) throws SSLException {
+ SslContext sslContext = createSslContext(publisherConfiguration);
+ return new CloudHttpClient(sslContext);
}
- private Mono<RestTemplate> createRestTemplateWithSslSetup(DmaapPublisherConfiguration publisherConfiguration) {
- try {
- RestTemplateBuilder builder = new RestTemplateBuilder();
-
- SSLContext sslContext = createSslContext(publisherConfiguration,
- loadPasswordFromFile(publisherConfiguration.keyStorePasswordPath()),
- loadPasswordFromFile(publisherConfiguration.trustStorePasswordPath()));
-
- return Mono.just(builder
- .requestFactory(() -> createRequestFactory(sslContext)).build());
-
- } catch (GeneralSecurityException | IOException e) {
- return Mono.error(e);
+ private SslContext createSslContext(DmaapPublisherConfiguration consumerConfiguration) throws SSLException {
+ if (consumerConfiguration.enableDmaapCertAuth()) {
+ return sslFactory.createSecureContext(
+ consumerConfiguration.keyStorePath(), consumerConfiguration.keyStorePasswordPath(),
+ consumerConfiguration.trustStorePath(), consumerConfiguration.trustStorePasswordPath()
+ );
}
+ return sslFactory.createInsecureContext();
}
-
- private SSLContext createSslContext(DmaapPublisherConfiguration publisherConfiguration,
- String keyStorePassword, String trustStorePassword)
- throws IOException, GeneralSecurityException {
- return new SSLContextBuilder()
- .loadKeyMaterial(
- keyStore(publisherConfiguration.keyStorePath(), keyStorePassword),
- keyStorePassword.toCharArray())
- .loadTrustMaterial(
- getFile(publisherConfiguration.trustStorePath()), trustStorePassword.toCharArray())
- .build();
- }
-
- private HttpComponentsClientHttpRequestFactory createRequestFactory(SSLContext sslContext) {
- SSLConnectionSocketFactory socketFactory =
- new SSLConnectionSocketFactory(sslContext);
- HttpClient httpClient = HttpClients.custom()
- .setSSLSocketFactory(socketFactory).build();
-
- return new HttpComponentsClientHttpRequestFactory(httpClient);
- }
-
- private KeyStore keyStore(String keyStoreFile, String keyStorePassword)
- throws GeneralSecurityException, IOException {
- KeyStore ks = KeyStore.getInstance("jks");
- ks.load(getResource(keyStoreFile), keyStorePassword.toCharArray());
- return ks;
- }
-
- private File getFile(String fileName) {
- return new File(fileName);
- }
-
- private InputStream getResource(String fileName) throws FileNotFoundException {
- return new FileInputStream(fileName);
- }
-
- private String loadPasswordFromFile(String path) throws IOException {
- return new String(Files.readAllBytes(Paths.get(path)));
- }
-
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java
index ff574f46..1cd3544e 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java
@@ -20,23 +20,25 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer;
+import javax.net.ssl.SSLException;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder;
-
public class PublisherReactiveHttpClientFactory {
private final DmaaPRestTemplateFactory restTemplateFactory;
private final JsonBodyBuilder jsonBodyBuilder;
- public PublisherReactiveHttpClientFactory(DmaaPRestTemplateFactory restTemplateFactory, JsonBodyBuilder jsonBodyBuilder) {
+ public PublisherReactiveHttpClientFactory(DmaaPRestTemplateFactory restTemplateFactory,
+ JsonBodyBuilder jsonBodyBuilder) {
this.restTemplateFactory = restTemplateFactory;
this.jsonBodyBuilder = jsonBodyBuilder;
}
- public DMaaPPublisherReactiveHttpClient create(DmaapPublisherConfiguration publisherConfiguration) {
+ public DMaaPPublisherReactiveHttpClient create(DmaapPublisherConfiguration publisherConfiguration)
+ throws SSLException {
return new DMaaPPublisherReactiveHttpClient(publisherConfiguration,
- restTemplateFactory.build(publisherConfiguration), jsonBodyBuilder);
+ restTemplateFactory.build(publisherConfiguration), jsonBodyBuilder);
}
}