diff options
author | 2018-10-15 15:15:50 -0400 | |
---|---|---|
committer | 2018-10-15 15:16:22 -0400 | |
commit | 97bb8fd7e436b07dc0a8e0d56ed9c1952e7ba41e (patch) | |
tree | f9c95eeeaa080e5028360ec4f2fbcdbcaadc69ac /src/main | |
parent | 3c077fdac44a644167b246ed4e0377603f54804d (diff) |
enable/disable AAF using a flag1.1.10
Issue-ID: DMAAP-849
Change-Id: I9aa4cce6c9b484170e006866a58f99926b53e2fc
Signed-off-by: sunil unnava <sunil.unnava@att.com>
Diffstat (limited to 'src/main')
5 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/com/att/dmf/mr/backends/kafka/KafkaPublisher.java b/src/main/java/com/att/dmf/mr/backends/kafka/KafkaPublisher.java index f5751f0..1e78b01 100644 --- a/src/main/java/com/att/dmf/mr/backends/kafka/KafkaPublisher.java +++ b/src/main/java/com/att/dmf/mr/backends/kafka/KafkaPublisher.java @@ -75,10 +75,11 @@ public class KafkaPublisher implements Publisher { } - + if(Utils.isCadiEnabled()){ transferSetting( props, "sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='"+Utils.getKafkaproperty()+"';"); transferSetting( props, "security.protocol", "SASL_PLAINTEXT"); - transferSetting( props, "sasl.mechanism", "PLAIN"); + transferSetting( props, "sasl.mechanism", "PLAIN"); + } transferSetting( props, "bootstrap.servers",kafkaConnUrl); transferSetting( props, "request.required.acks", "1"); diff --git a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java index 2f13be8..fb0ace0 100644 --- a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java +++ b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaConsumerFactory.java @@ -289,10 +289,11 @@ public class DMaaPKafkaConsumerFactory implements ConsumerFactory { props.put("group.id", fakeGroupName); props.put("enable.auto.commit", "false"); // 0.11 props.put("bootstrap.servers", fkafkaBrokers); + if(Utils.isCadiEnabled()){ props.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='"+Utils.getKafkaproperty()+"';"); props.put("security.protocol", "SASL_PLAINTEXT"); props.put("sasl.mechanism", "PLAIN"); - + } props.put("client.id", consumerId); // additional settings: start with our defaults, then pull in configured diff --git a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaMetaBroker.java b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaMetaBroker.java index cbb58e4..acf4824 100644 --- a/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaMetaBroker.java +++ b/src/main/java/com/att/dmf/mr/beans/DMaaPKafkaMetaBroker.java @@ -84,9 +84,11 @@ public class DMaaPKafkaMetaBroker implements Broker1 { } props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, fkafkaBrokers ); + if(Utils.isCadiEnabled()){ props.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='"+Utils.getKafkaproperty()+"';"); props.put(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, "SASL_PLAINTEXT"); props.put("sasl.mechanism", "PLAIN"); + } fKafkaAdminClient=AdminClient.create ( props ); @@ -119,10 +121,11 @@ public class DMaaPKafkaMetaBroker implements Broker1 { fkafkaBrokers = "localhost:9092"; } - + if(Utils.isCadiEnabled()){ props.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username='admin' password='"+Utils.getKafkaproperty()+"';"); props.put(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, "SASL_PLAINTEXT"); props.put("sasl.mechanism", "PLAIN"); + } props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, fkafkaBrokers ); fKafkaAdminClient=AdminClient.create ( props ); diff --git a/src/main/java/com/att/dmf/mr/service/impl/TopicServiceImpl.java b/src/main/java/com/att/dmf/mr/service/impl/TopicServiceImpl.java index f6d7b21..983af7e 100644 --- a/src/main/java/com/att/dmf/mr/service/impl/TopicServiceImpl.java +++ b/src/main/java/com/att/dmf/mr/service/impl/TopicServiceImpl.java @@ -52,6 +52,7 @@ import com.att.dmf.mr.security.DMaaPAAFAuthenticatorImpl; import com.att.dmf.mr.security.DMaaPAuthenticatorImpl; import com.att.dmf.mr.service.TopicService; import com.att.dmf.mr.utils.DMaaPResponseBuilder; +import com.att.dmf.mr.utils.Utils; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.att.nsa.configs.ConfigDbException; @@ -215,7 +216,7 @@ public class TopicServiceImpl implements TopicService { // else if (user==null && // (null==dmaapContext.getRequest().getHeader("Authorization") && null // == dmaapContext.getRequest().getHeader("cookie")) ) { - else if (user == null && null == dmaapContext.getRequest().getHeader("Authorization") + else if (Utils.isCadiEnabled()&&user == null && null == dmaapContext.getRequest().getHeader("Authorization") && (null == appName && null == dmaapContext.getRequest().getHeader("cookie"))) { LOGGER.error("Failed to create topic" + topicBean.getTopicName() + ", Authentication failed."); diff --git a/src/main/java/com/att/dmf/mr/utils/Utils.java b/src/main/java/com/att/dmf/mr/utils/Utils.java index c2b8b88..5f84d85 100644 --- a/src/main/java/com/att/dmf/mr/utils/Utils.java +++ b/src/main/java/com/att/dmf/mr/utils/Utils.java @@ -162,4 +162,14 @@ public class Utils { } + + public static boolean isCadiEnabled(){ + boolean enableCadi=false; + if(System.getenv("enableCadi")!=null){ + enableCadi=Boolean.getBoolean(System.getenv("enableCadi")); + } + + return enableCadi; + } + } |