2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018,2019 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 * in compliance with the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License
11 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing permissions and limitations under
14 * ============LICENSE_END========================================================================
17 package org.onap.dcaegen2.collectors.datafile.configuration;
19 import java.net.MalformedURLException;
21 import org.immutables.gson.Gson;
22 import org.immutables.value.Value;
23 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
24 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
27 @Value.Style(redactedMask = "####")
29 public interface PublisherConfiguration {
40 String trustStorePath();
42 String trustStorePasswordPath();
44 String keyStorePath();
46 String keyStorePasswordPath();
48 Boolean enableDmaapCertAuth();
50 String changeIdentifier();
53 * Get the publisher configuration in SDK format.
55 * @return a <code>DmaapPublisherConfiguration</code> contining the publisher configuration.
56 * @throws MalformedURLException if the publish URL is malformed.
58 default DmaapPublisherConfiguration toDmaap() throws MalformedURLException {
59 URL url = new URL(publishUrl());
60 String urlPath = url.getPath();
62 return new ImmutableDmaapPublisherConfiguration.Builder() //
63 .dmaapContentType("application/octet-stream") //
64 .dmaapPortNumber(url.getPort()) //
65 .dmaapHostName(url.getHost()) //
66 .dmaapTopicName(urlPath) //
67 .dmaapProtocol(url.getProtocol()) //
68 .dmaapUserName(this.userName()) //
69 .dmaapUserPassword(this.passWord()) //
70 .trustStorePath(this.trustStorePath()) //
71 .trustStorePasswordPath(this.trustStorePasswordPath()) //
72 .keyStorePath(this.keyStorePath()) //
73 .keyStorePasswordPath(this.keyStorePasswordPath()) //
74 .enableDmaapCertAuth(this.enableDmaapCertAuth()) //