From 59a32948ea9ad4f1e8018ff07e994320c966ac0b Mon Sep 17 00:00:00 2001 From: Maurizio Colleluori Date: Mon, 7 Nov 2016 17:11:59 +0100 Subject: [PATCH] NIFI-2923 Added evaluation of attribute expressions for Kerberos principal and keytab Signed-off-by: Bryan Bende --- .../nifi/processors/hadoop/AbstractHadoopProcessor.java | 8 ++++---- .../org/apache/nifi/dbcp/hive/HiveConnectionPool.java | 8 ++++---- .../org/apache/nifi/processors/hive/PutHiveStreaming.java | 4 ++-- .../org/apache/nifi/hbase/HBase_1_1_2_ClientService.java | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java b/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java index 9f99500a7b..d88f774a70 100644 --- a/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java +++ b/nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java @@ -148,8 +148,8 @@ public abstract class AbstractHadoopProcessor extends AbstractProcessor { @Override protected Collection customValidate(ValidationContext validationContext) { final String configResources = validationContext.getProperty(HADOOP_CONFIGURATION_RESOURCES).getValue(); - final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keytab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keytab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); final List results = new ArrayList<>(); @@ -262,8 +262,8 @@ public abstract class AbstractHadoopProcessor extends AbstractProcessor { UserGroupInformation ugi; synchronized (RESOURCES_LOCK) { if (SecurityUtil.isSecurityEnabled(config)) { - String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); ugi = SecurityUtil.loginKerberos(config, principal, keyTab); fs = getFileSystemAsUser(config, ugi); lastKerberosReloginTime = System.currentTimeMillis() / 1000; diff --git a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java index bdf2f1012c..c6941d371d 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java +++ b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java @@ -190,8 +190,8 @@ public class HiveConnectionPool extends AbstractControllerService implements Hiv if (confFileProvided) { final String configFiles = validationContext.getProperty(HIVE_CONFIGURATION_RESOURCES).evaluateAttributeExpressions().getValue(); - final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keyTab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keyTab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); problems.addAll(hiveConfigurator.validate(configFiles, principal, keyTab, validationResourceHolder, getLogger())); } @@ -229,8 +229,8 @@ public class HiveConnectionPool extends AbstractControllerService implements Hiv final String drv = HiveDriver.class.getName(); if (SecurityUtil.isSecurityEnabled(hiveConfig)) { - final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); log.info("Hive Security Enabled, logging in as principal {} with keytab {}", new Object[]{principal, keyTab}); try { diff --git a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java index f08310e7cc..fe677e5532 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java +++ b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java @@ -349,8 +349,8 @@ public class PutHiveStreaming extends AbstractSessionFactoryProcessor { hiveConfigurator.preload(hiveConfig); if (SecurityUtil.isSecurityEnabled(hiveConfig)) { - final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); log.info("Hive Security Enabled, logging in as principal {} with keytab {}", new Object[]{principal, keyTab}); try { diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java index fa71d0634e..2d1166c01f 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientService.java @@ -167,8 +167,8 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme } final Configuration hbaseConfig = resources.getConfiguration(); - final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keytab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = validationContext.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keytab = validationContext.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); problems.addAll(KerberosProperties.validatePrincipalAndKeytab( this.getClass().getSimpleName(), hbaseConfig, principal, keytab, getLogger())); @@ -223,8 +223,8 @@ public class HBase_1_1_2_ClientService extends AbstractControllerService impleme } if (SecurityUtil.isSecurityEnabled(hbaseConfig)) { - final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).getValue(); - final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).getValue(); + final String principal = context.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue(); + final String keyTab = context.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue(); getLogger().info("HBase Security Enabled, logging in as principal {} with keytab {}", new Object[] {principal, keyTab}); ugi = SecurityUtil.loginKerberos(hbaseConfig, principal, keyTab);