summaryrefslogtreecommitdiffstats
path: root/rest-services/dmaap-client/src/main
diff options
context:
space:
mode:
authorIzabela Zawadzka <izabela.zawadzka@nokia.com>2019-04-09 08:24:18 +0200
committerIzabela Zawadzka <izabela.zawadzka@nokia.com>2019-04-09 11:49:02 +0200
commit8daac07f7a45e38702901252972039cf8d46fe53 (patch)
treebedb857806a03ac58152f5582b1179bc7bfdf9d8 /rest-services/dmaap-client/src/main
parentc04fd10cc5e3b49e84f5a7a7d6da318891b591cb (diff)
Get rid of deprecated SslFactory
Change-Id: I928d6911a2516ffbfc05e9193e5d2d8467ec2545 Signed-off-by: Izabela Zawadzka <izabela.zawadzka@nokia.com> Issue-ID: DCAEGEN2-1408
Diffstat (limited to 'rest-services/dmaap-client/src/main')
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java7
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java19
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/DmaaPRestTemplateFactory.java20
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/producer/PublisherReactiveHttpClientFactory.java11
-rw-r--r--rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java51
5 files changed, 79 insertions, 29 deletions
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java
index 7fd1021f..e92ad3f1 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/ConsumerReactiveHttpClientFactory.java
@@ -30,12 +30,13 @@ public class ConsumerReactiveHttpClientFactory {
private final DMaaPReactiveWebClientFactory reactiveWebClientFactory;
- public ConsumerReactiveHttpClientFactory(DMaaPReactiveWebClientFactory reactiveWebClientFactory) {
+ public ConsumerReactiveHttpClientFactory(
+ DMaaPReactiveWebClientFactory reactiveWebClientFactory) {
this.reactiveWebClientFactory = reactiveWebClientFactory;
}
- public DMaaPConsumerReactiveHttpClient create(DmaapConsumerConfiguration consumerConfiguration)
- throws SSLException {
+ public DMaaPConsumerReactiveHttpClient create(
+ DmaapConsumerConfiguration consumerConfiguration) {
return new DMaaPConsumerReactiveHttpClient(consumerConfiguration,
reactiveWebClientFactory.build(consumerConfiguration));
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java
index fba6f188..3d3c54af 100644
--- a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/service/consumer/DMaaPReactiveWebClientFactory.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -21,10 +21,11 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer;
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.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.ssl.SslFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.utlis.SecurityKeysUtil;
+import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys;
+import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
@@ -47,18 +48,16 @@ public class DMaaPReactiveWebClientFactory {
* @return CloudHttpClient
*/
- public CloudHttpClient build(DmaapConsumerConfiguration consumerConfiguration) throws SSLException {
+ public CloudHttpClient build(DmaapConsumerConfiguration consumerConfiguration){
SslContext sslContext = createSslContext(consumerConfiguration);
return new CloudHttpClient(sslContext);
}
- private SslContext createSslContext(DmaapConsumerConfiguration consumerConfiguration) throws SSLException {
+ private SslContext createSslContext(DmaapConsumerConfiguration consumerConfiguration){
if (consumerConfiguration.enableDmaapCertAuth()) {
- return sslFactory.createSecureContext(
- consumerConfiguration.keyStorePath(), consumerConfiguration.keyStorePasswordPath(),
- consumerConfiguration.trustStorePath(), consumerConfiguration.trustStorePasswordPath()
- );
+ final SecurityKeys securityKeys = SecurityKeysUtil.fromDmappCustomConfig(consumerConfiguration);
+ return sslFactory.createSecureClientContext(securityKeys);
}
- return sslFactory.createInsecureContext();
+ return sslFactory.createInsecureClientContext();
}
}
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 765c64b7..2d71760d 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -21,10 +21,11 @@
package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.producer;
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.onap.dcaegen2.services.sdk.rest.services.ssl.SslFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.utlis.SecurityKeysUtil;
+import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys;
+import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory;
public class DmaaPRestTemplateFactory {
@@ -44,18 +45,17 @@ public class DmaaPRestTemplateFactory {
* @param publisherConfiguration - DMaaP publisher configuration object
* @return RestTemplate with correct ssl configuration
*/
- public CloudHttpClient build(DmaapPublisherConfiguration publisherConfiguration) throws SSLException {
+ public CloudHttpClient build(DmaapPublisherConfiguration publisherConfiguration){
SslContext sslContext = createSslContext(publisherConfiguration);
return new CloudHttpClient(sslContext);
}
- private SslContext createSslContext(DmaapPublisherConfiguration consumerConfiguration) throws SSLException {
+ private SslContext createSslContext(DmaapPublisherConfiguration consumerConfiguration) {
if (consumerConfiguration.enableDmaapCertAuth()) {
- return sslFactory.createSecureContext(
- consumerConfiguration.keyStorePath(), consumerConfiguration.keyStorePasswordPath(),
- consumerConfiguration.trustStorePath(), consumerConfiguration.trustStorePasswordPath()
- );
+ final SecurityKeys securityKeys = SecurityKeysUtil
+ .fromDmappCustomConfig(consumerConfiguration);
+ return sslFactory.createSecureClientContext(securityKeys);
}
- return sslFactory.createInsecureContext();
+ return sslFactory.createInsecureClientContext();
}
}
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 1cd3544e..953a3319 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -20,7 +20,6 @@
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;
@@ -31,14 +30,14 @@ public class PublisherReactiveHttpClientFactory {
private final JsonBodyBuilder jsonBodyBuilder;
public PublisherReactiveHttpClientFactory(DmaaPRestTemplateFactory restTemplateFactory,
- JsonBodyBuilder jsonBodyBuilder) {
+ JsonBodyBuilder jsonBodyBuilder) {
this.restTemplateFactory = restTemplateFactory;
this.jsonBodyBuilder = jsonBodyBuilder;
}
- public DMaaPPublisherReactiveHttpClient create(DmaapPublisherConfiguration publisherConfiguration)
- throws SSLException {
+ public DMaaPPublisherReactiveHttpClient create(
+ DmaapPublisherConfiguration publisherConfiguration) {
return new DMaaPPublisherReactiveHttpClient(publisherConfiguration,
- restTemplateFactory.build(publisherConfiguration), jsonBodyBuilder);
+ restTemplateFactory.build(publisherConfiguration), jsonBodyBuilder);
}
}
diff --git a/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java
new file mode 100644
index 00000000..7ee06e9c
--- /dev/null
+++ b/rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/utlis/SecurityKeysUtil.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2019 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.utlis;
+
+import io.vavr.control.Try;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import org.jetbrains.annotations.NotNull;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapCustomConfig;
+import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeys;
+import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeysStore;
+import org.onap.dcaegen2.services.sdk.security.ssl.Passwords;
+import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys;
+
+public final class SecurityKeysUtil {
+
+ private SecurityKeysUtil(){
+
+ }
+
+ @NotNull
+ public static SecurityKeys fromDmappCustomConfig(DmaapCustomConfig configuration){
+ return ImmutableSecurityKeys.builder()
+ .keyStore(ImmutableSecurityKeysStore.of(resource(configuration.keyStorePath()).get()))
+ .keyStorePassword(Passwords.fromResource(configuration.keyStorePasswordPath()))
+ .trustStore(ImmutableSecurityKeysStore.of(resource(configuration.trustStorePath()).get()))
+ .trustStorePassword(Passwords.fromResource(configuration.trustStorePasswordPath()))
+ .build();
+ }
+
+ private static Try<Path> resource(String resource) {
+ return Try.of(() -> Paths.get(Passwords.class.getResource(resource).toURI()));
+ }}