Kafka producer configuration modified to accept the SCRAM-SHA-512 based authentication
Issue-ID: NONRTRIC-1020
Change-Id: Iefa4a30c1bec2a71d7c511ada54fa8e1b4e0892f
Signed-off-by: aravind.est <aravindhan.a@est.tech>
ARG JAR
WORKDIR /opt/app/teiv
-ADD src/main/resources/application.properties /opt/app/teiv/config/application.properties
+ADD src/main/resources/application.yaml /opt/app/teiv/config/application.yaml
ADD target/${JAR} /opt/app/teiv/ncmp-to-teiv-adapter.jar
CMD ["/bin/sh", "-c", "java -jar ncmp-to-teiv-adapter.jar"]
<artifactId>adapters</artifactId>
<version>0.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.oran.smo</groupId>
<artifactId>ncmp-to-teiv-adapter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
package org.oran.smo.ncmp_to_teiv_adapter;
import io.cloudevents.CloudEvent;
+import lombok.RequiredArgsConstructor;
+import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import io.cloudevents.kafka.CloudEventSerializer;
import java.util.Map;
@Configuration
+@RequiredArgsConstructor
public class KafkaProducerConfig {
+ private final KafkaSecurityConfig securityConfig;
+
@Value("${spring.kafka.bootstrap-servers}")
private String bootstrapServer;
+ @Value("${spring.kafka.security.enabled}")
+ private boolean securityEnabled;
+
@Bean
public ProducerFactory<String, CloudEvent> producerFactory() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, CloudEventSerializer.class);
-
+ if (securityConfig.isEnabled()) {
+ configProps.put(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, securityConfig.getProtocol());
+ configProps.putAll(securityConfig.getProperties());
+ }
return new DefaultKafkaProducerFactory<>(configProps);
}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Ericsson
+ * Modifications Copyright (C) 2024 OpenInfra Foundation Europe
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.oran.smo.ncmp_to_teiv_adapter;
+
+import java.util.Map;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@Data
+@Slf4j
+@ConfigurationProperties("spring.kafka.security")
+public class KafkaSecurityConfig {
+ private boolean enabled = false;
+
+ private String protocol;
+
+ private Map<String, String> properties;
+}
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
+spring:
+ application:
+ name: ncmp-to-teiv-adapter
+ kafka:
+ bootstrap-servers: localhost:9093
+ security:
+ enabled: false
+ protocol: SASL_PLAINTEXT
+ properties:
+ sasl.mechanism: SCRAM-SHA-512
+ sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="" password="";
+ producer:
+ key-serializer: org.apache.kafka.common.serialization.StringSerializer
+ value-serializer: io.cloudevents.kafka.CloudEventSerializer
-spring.application.name=ncmp-to-teiv-adapter
+kafka:
+ topic: topology-inventory-ingestion
-spring.kafka.bootstrap-servers=localhost:9093
-spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
-spring.kafka.producer.value-serializer=io.cloudevents.kafka.CloudEventSerializer
-kafka.topic=topology-inventory-ingestion
+send-sample-ocucp-event: false
-send-sample-ocucp-event=false
-
-polling.base-url=http://localhost:8883/ncmp/v1/ch
-polling.data-store-url=/data/ds/ncmp-datastore:passthrough-running
-polling.searches-url=/id-searches
-polling.include-descendants=false
-polling.interval=60000
+polling:
+ base-url: http://localhost:8883/ncmp/v1/ch
+ data-store-url: /data/ds/ncmp-datastore:passthrough-running
+ searches-url: /id-searches
+ include-descendants: false
+ interval: 60000
\ No newline at end of file
-->
<!-- spotless:on -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.oran.smo</groupId>
<version>0.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.oran.smo</groupId>
<artifactId>adapters</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>pom</packaging>