diff options
author | 2022-02-17 17:07:59 +0000 | |
---|---|---|
committer | 2022-03-02 16:56:59 +0000 | |
commit | 3cba071c0d52c446db67f3a73db2d31e594d1653 (patch) | |
tree | fae01c1f73544670dc1e72538cee617975133c81 /ms/blueprintsprocessor/modules/commons/message-lib/src/main | |
parent | 4db0643d321940dc0677f6953cb5701fb8ffb26b (diff) |
DMAAP-1706 - New Kafka Auth option
Change-Id: I8533721d23d6adb41f65cb96fb2b8f852bda47b8
Signed-off-by: david.mcweeney <david.mcweeney@est.tech>
Issue-ID: DMAAP-1706
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/message-lib/src/main')
3 files changed, 67 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt index 659295a6b..249af8812 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt @@ -1,6 +1,7 @@ /* * Copyright © 2019 IBM. * Modifications Copyright © 2018-2019 AT&T Intellectual Property. + * Modification Copyright (C) 2022 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,5 +68,6 @@ class MessageLibConstants { const val TYPE_KAFKA_STREAMS_BASIC_AUTH = "kafka-streams-basic-auth" const val TYPE_KAFKA_STREAMS_SSL_AUTH = "kafka-streams-ssl-auth" const val TYPE_KAFKA_STREAMS_SCRAM_SSL_AUTH = "kafka-streams-scram-ssl-auth" + const val TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH = "kafka-scram-plain-text-auth" } } diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt index 3e7db9597..886c87c0b 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt @@ -1,6 +1,7 @@ /* * Copyright © 2019 IBM. * Modifications Copyright © 2018-2019 AT&T Intellectual Property. + * Modification Copyright (C) 2022 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,6 +118,24 @@ class KafkaScramSslAuthMessageProducerProperties : KafkaSslAuthMessageProducerPr } } +/** (SASL) SCRAM Plaintext Auth */ +class KafkaScramPlainTextAuthMessageProducerProperties : KafkaBasicAuthMessageProducerProperties() { + + var saslMechanism: String = "SCRAM-SHA-512" + lateinit var scramUsername: String + lateinit var scramPassword: String + + override fun getConfig(): HashMap<String, Any> { + val configProps = super.getConfig() + configProps[CommonClientConfigs.SECURITY_PROTOCOL_CONFIG] = SecurityProtocol.SASL_PLAINTEXT.toString() + configProps[SaslConfigs.SASL_MECHANISM] = saslMechanism + configProps[SaslConfigs.SASL_JAAS_CONFIG] = "${ScramLoginModule::class.java.canonicalName} required " + + "username=\"${scramUsername}\" " + + "password=\"${scramPassword}\";" + return configProps + } +} + /** Consumer */ abstract class MessageConsumerProperties : CommonProperties() /** Kafka Streams */ @@ -265,3 +284,21 @@ class KafkaScramSslAuthMessageConsumerProperties : KafkaSslAuthMessageConsumerPr return configProps } } + +/** (SASL) SCRAM Plaintext Auth */ +class KafkaScramPlaintextAuthMessageConsumerProperties : KafkaBasicAuthMessageConsumerProperties() { + + var saslMechanism: String = "SCRAM-SHA-512" + lateinit var scramUsername: String + lateinit var scramPassword: String + + override fun getConfig(): HashMap<String, Any> { + val configProps = super.getConfig() + configProps[CommonClientConfigs.SECURITY_PROTOCOL_CONFIG] = SecurityProtocol.SASL_PLAINTEXT.toString() + configProps[SaslConfigs.SASL_MECHANISM] = saslMechanism + configProps[SaslConfigs.SASL_JAAS_CONFIG] = "${ScramLoginModule::class.java.canonicalName} required " + + "username=\"${scramUsername}\" " + + "password=\"${scramPassword}\";" + return configProps + } +} diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt index c0cf51b93..d10f2d43b 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt @@ -1,6 +1,7 @@ /* * Copyright © 2019 IBM. * Modifications Copyright © 2018-2021 AT&T, Bell Canada Intellectual Property + * Modification Copyright (C) 2022 Nordix Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,8 @@ import io.micrometer.core.instrument.MeterRegistry import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageConsumerProperties import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageProducerProperties +import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaScramPlainTextAuthMessageProducerProperties +import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaScramPlaintextAuthMessageConsumerProperties import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaScramSslAuthMessageConsumerProperties import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaScramSslAuthMessageProducerProperties import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaSslAuthMessageConsumerProperties @@ -71,6 +74,11 @@ open class BluePrintMessageLibPropertyService( prefix, KafkaScramSslAuthMessageProducerProperties::class.java ) } + MessageLibConstants.TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH -> { + bluePrintPropertiesService.propertyBeanType( + prefix, KafkaScramPlainTextAuthMessageProducerProperties::class.java + ) + } else -> { throw BluePrintProcessorException("Message adaptor($type) is not supported") } @@ -89,6 +97,9 @@ open class BluePrintMessageLibPropertyService( MessageLibConstants.TYPE_KAFKA_SCRAM_SSL_AUTH -> { JacksonUtils.readValue(jsonNode, KafkaScramSslAuthMessageProducerProperties::class.java)!! } + MessageLibConstants.TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH -> { + JacksonUtils.readValue(jsonNode, KafkaScramPlainTextAuthMessageProducerProperties::class.java)!! + } else -> { throw BluePrintProcessorException("Message adaptor($type) is not supported") } @@ -130,6 +141,12 @@ open class BluePrintMessageLibPropertyService( prefix, KafkaScramSslAuthMessageConsumerProperties::class.java ) } + MessageLibConstants.TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH -> { + bluePrintPropertiesService.propertyBeanType( + prefix, KafkaScramPlaintextAuthMessageConsumerProperties::class.java + ) + } + /** Stream Consumer */ MessageLibConstants.TYPE_KAFKA_STREAMS_BASIC_AUTH -> { bluePrintPropertiesService.propertyBeanType( @@ -146,6 +163,7 @@ open class BluePrintMessageLibPropertyService( prefix, KafkaStreamsScramSslAuthConsumerProperties::class.java ) } + else -> { throw BluePrintProcessorException("Message adaptor($type) is not supported") } @@ -165,6 +183,9 @@ open class BluePrintMessageLibPropertyService( MessageLibConstants.TYPE_KAFKA_SCRAM_SSL_AUTH -> { JacksonUtils.readValue(jsonNode, KafkaScramSslAuthMessageConsumerProperties::class.java)!! } + MessageLibConstants.TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH -> { + JacksonUtils.readValue(jsonNode, KafkaScramPlaintextAuthMessageConsumerProperties::class.java)!! + } /** Stream Consumer */ MessageLibConstants.TYPE_KAFKA_STREAMS_BASIC_AUTH -> { JacksonUtils.readValue(jsonNode, KafkaStreamsBasicAuthConsumerProperties::class.java)!! @@ -175,6 +196,7 @@ open class BluePrintMessageLibPropertyService( MessageLibConstants.TYPE_KAFKA_STREAMS_SCRAM_SSL_AUTH -> { JacksonUtils.readValue(jsonNode, KafkaStreamsScramSslAuthConsumerProperties::class.java)!! } + else -> { throw BluePrintProcessorException("Message adaptor($type) is not supported") } @@ -204,6 +226,12 @@ open class BluePrintMessageLibPropertyService( meterRegistry ) } + MessageLibConstants.TYPE_KAFKA_SCRAM_PLAIN_TEXT_AUTH -> { + return KafkaMessageConsumerService( + messageConsumerProperties as KafkaScramPlaintextAuthMessageConsumerProperties, + meterRegistry + ) + } /** Stream Consumer */ MessageLibConstants.TYPE_KAFKA_STREAMS_BASIC_AUTH -> { return KafkaStreamsConsumerService( |