2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.config;
20 import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
21 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
25 * bootstrapServers=abc:9092,def:9092
26 * securityProtocol=PLAINTEXT #OTHER POSSIBLE VALUES - SSL, SASL_PLAINTEXT, SASL_SSL
27 * saslMechanism=PLAIN #Need to understand more
32 public class StrimziKafkaConfig implements Configuration {
34 private static final String SECTION_MARKER = "strimzi-kafka";
36 private static final String PROPERTY_KEY_ENABLED = "strimziEnabled";
38 private static final String PROPERTY_KEY_BOOTSTRAPSERVERS = "bootstrapServers";
39 private static final String DEFAULT_VALUE_BOOTSTRAPSERVERS = "onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094";
41 private static final String PROPERTY_KEY_SECURITYPROTOCOL = "securityProtocol";
42 private static final String DEFAULT_VALUE_SECURITYPROTOCOL = "PLAINTEXT";
44 private static final String PROPERTY_KEY_SASLMECHANISM = "saslMechanism";
45 private static final String DEFAULT_VALUE_SASLMECHANISM = "PLAIN";
47 private static final String PROPERTY_KEY_SASLJAASCONFIG = "saslJaasConfig";
48 private static final String DEFAULT_VALUE_SASLJAASCONFIG = "PLAIN"; // TBD
50 private ConfigurationFileRepresentation configuration;
52 public StrimziKafkaConfig(ConfigurationFileRepresentation configuration) {
53 this.configuration = configuration;
54 configuration.addSection(SECTION_MARKER);
58 public Boolean getEnabled() {
59 return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
62 public String getBootstrapServers() {
63 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_BOOTSTRAPSERVERS);
66 public String getSecurityProtocol() {
67 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SECURITYPROTOCOL);
70 public String getSaslMechanism() {
71 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SASLMECHANISM);
74 public String getSaslJaasConfig() {
75 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SASLJAASCONFIG);
79 public String getSectionName() {
80 return SECTION_MARKER;
84 public void defaults() {
85 // The default value should be "false" given that SDNR can be run in
86 // environments where Strimzi is not used
87 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_ENABLED, Boolean.FALSE);
88 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_BOOTSTRAPSERVERS,
89 DEFAULT_VALUE_BOOTSTRAPSERVERS);
90 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SECURITYPROTOCOL,
91 DEFAULT_VALUE_SECURITYPROTOCOL);
92 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SASLMECHANISM,
93 DEFAULT_VALUE_SASLMECHANISM);
94 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SASLJAASCONFIG,
95 DEFAULT_VALUE_SASLJAASCONFIG);