diff options
author | grabinsk <maciej.grabinski@nokia.com> | 2019-05-28 11:23:53 +0200 |
---|---|---|
committer | grabinsk <maciej.grabinski@nokia.com> | 2019-05-29 09:32:47 +0200 |
commit | 37444e2753f351cfe22b4651bcf777b833aeba92 (patch) | |
tree | 9280875024a947f1b644aa9f1c93bc81799d1201 /prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java | |
parent | 37dd2cb2d2ad38ad1e6dd83f3ff5b40bc2c0f614 (diff) |
SSL key loading for Dmaap client
Change-Id: I65b3d0bcd6735af655c9243f20f3596ce8f03aca
Issue-ID: DCAEGEN2-1501
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java')
-rw-r--r-- | prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java index 63947fa9..a57a5393 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java @@ -34,7 +34,16 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.Immutable import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.ImmutableMessageRouterSubscribeRequest; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterPublishRequest; import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.MessageRouterSubscribeRequest; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config.ImmutableMessageRouterPublisherConfig; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config.ImmutableMessageRouterSubscriberConfig; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config.MessageRouterPublisherConfig; +import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config.MessageRouterSubscriberConfig; +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; +import java.nio.file.Paths; import java.time.Duration; import java.util.Map; @@ -79,6 +88,31 @@ class CbsContentParser { .build(); } + MessageRouterPublisherConfig getMessageRouterPublisherConfig() { + return ImmutableMessageRouterPublisherConfig.builder() + .securityKeys(isDmaapCertAuthEnabled(jsonObject) ? createSecurityKeys(jsonObject) : null) + .build(); + } + + MessageRouterSubscriberConfig getMessageRouterSubscriberConfig() { + return ImmutableMessageRouterSubscriberConfig.builder() + .securityKeys(isDmaapCertAuthEnabled(jsonObject) ? createSecurityKeys(jsonObject) : null) + .build(); + } + + private SecurityKeys createSecurityKeys(JsonObject config) { + return ImmutableSecurityKeys.builder() + .keyStore(ImmutableSecurityKeysStore.of(Paths.get(config.get(SECURITY_KEY_STORE_PATH).getAsString()))) + .keyStorePassword(Passwords.fromPath(Paths.get(config.get(SECURITY_KEY_STORE_PASS_PATH).getAsString()))) + .trustStore(ImmutableSecurityKeysStore.of(Paths.get(config.get(SECURITY_TRUST_STORE_PATH).getAsString()))) + .trustStorePassword(Passwords.fromPath(Paths.get(config.get(SECURITY_TRUST_STORE_PASS_PATH).getAsString()))) + .build(); + } + + private boolean isDmaapCertAuthEnabled(JsonObject config) { + return config.get("security.enableDmaapCertAuth").getAsBoolean(); + } + AaiClientConfiguration getAaiClientConfig() { return new ImmutableAaiClientConfiguration.Builder() .pnfUrl(jsonObject.get("aai.aaiClientConfiguration.pnfUrl").getAsString()) |