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
28 * saslJaasConfig=PLAIN
32 public class StrimziKafkaConfig implements Configuration {
34 private static final String SECTION_MARKER = "strimzi-kafka";
36 private static final String PROPERTY_KEY_ENABLED = "strimziEnabled";
37 private static final String DEFAULT_VALUE_KAFKA_ENABLED = "${SDNR_KAFKA_ENABLED}";
39 private static final String PROPERTY_KEY_BOOTSTRAPSERVERS = "bootstrapServers";
40 private static final String DEFAULT_VALUE_BOOTSTRAPSERVERS = "${SDNR_KAFKA_BOOTSTRAP_SERVERS}";
42 private static final String PROPERTY_KEY_SECURITYPROTOCOL = "securityProtocol";
43 private static final String DEFAULT_VALUE_SECURITYPROTOCOL = "${SDNR_KAFKA_SECURITY_PROTOCOL}";
45 private static final String PROPERTY_KEY_SASLMECHANISM = "saslMechanism";
46 private static final String DEFAULT_VALUE_SASLMECHANISM = "${SDNR_KAFKA_SASL_MECHANISM}";
48 private static final String PROPERTY_KEY_SASLJAASCONFIG = "saslJaasConfig";
49 private static final String DEFAULT_VALUE_SASLJAASCONFIG = "${SDNR_KAFKA_SASL_JAAS_CONFIG}";
51 private ConfigurationFileRepresentation configuration;
53 public StrimziKafkaConfig(ConfigurationFileRepresentation configuration) {
54 this.configuration = configuration;
55 configuration.addSection(SECTION_MARKER);
59 public Boolean getEnabled() {
60 return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
63 public String getBootstrapServers() {
64 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_BOOTSTRAPSERVERS);
67 public String getSecurityProtocol() {
68 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SECURITYPROTOCOL);
71 public String getSaslMechanism() {
72 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SASLMECHANISM);
75 public String getSaslJaasConfig() {
76 return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_SASLJAASCONFIG);
80 public String getSectionName() {
81 return SECTION_MARKER;
85 public void defaults() {
86 // The default value should be "false" given that SDNR can be run in
87 // environments where Strimzi is not used
88 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_ENABLED, DEFAULT_VALUE_KAFKA_ENABLED);
89 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_BOOTSTRAPSERVERS,
90 DEFAULT_VALUE_BOOTSTRAPSERVERS);
91 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SECURITYPROTOCOL,
92 DEFAULT_VALUE_SECURITYPROTOCOL);
93 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SASLMECHANISM,
94 DEFAULT_VALUE_SASLMECHANISM);
95 configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_SASLJAASCONFIG,
96 DEFAULT_VALUE_SASLJAASCONFIG);