You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2020/05/11 06:41:28 UTC

[hbase] branch branch-1.4 updated: HBASE-24190 : Make kerberos value of hbase.security.authentication property case insensitive (#1687)

This is an automated email from the ASF dual-hosted git repository.

vjasani pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new bd0a144  HBASE-24190 : Make kerberos value of hbase.security.authentication property case insensitive (#1687)
bd0a144 is described below

commit bd0a1447cdcb8000ebf338df889b9fe9f8871849
Author: shahrs87 <sh...@gmail.com>
AuthorDate: Mon May 11 12:03:47 2020 +0530

    HBASE-24190 : Make kerberos value of hbase.security.authentication property case insensitive (#1687)
    
    Signed-off-by: binlijin <bi...@gmail.com>
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 .../org/apache/hadoop/hbase/TestHBaseConfiguration.java   | 15 +++++++++++++++
 .../java/org/apache/hadoop/hbase/mapreduce/SyncTable.java |  4 ++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
index 1aa052b..4906f73 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
@@ -31,8 +31,10 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -123,6 +125,19 @@ public class TestHBaseConfiguration {
     }
   }
 
+  @Test
+  public void testSecurityConfCaseInsensitive() {
+    Configuration conf = HBaseConfiguration.create();
+    conf.set("hbase.security.authentication", "kerberos");
+    Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+
+    conf.set("hbase.security.authentication", "KERBEROS");
+    Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+
+    conf.set("hbase.security.authentication", "KERBeros");
+    Assert.assertTrue(User.isHBaseSecurityEnabled(conf));
+  }
+
   private static class ReflectiveCredentialProviderClient {
     public static final String HADOOP_CRED_PROVIDER_FACTORY_CLASS_NAME =
         "org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory";
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/SyncTable.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/SyncTable.java
index 31d5172..03c5e1a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/SyncTable.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/SyncTable.java
@@ -86,7 +86,7 @@ public class SyncTable extends Configured implements Tool {
   private void initCredentialsForHBase(String zookeeper, Job job) throws IOException {
     Configuration peerConf = HBaseConfiguration.createClusterConf(job
             .getConfiguration(), zookeeper);
-    if(peerConf.get("hbase.security.authentication").equals("kerberos")){
+    if("kerberos".equalsIgnoreCase(peerConf.get("hbase.security.authentication"))){
       TableMapReduceUtil.initCredentialsForCluster(job, peerConf);
     }
   }
@@ -100,7 +100,7 @@ public class SyncTable extends Configured implements Tool {
     Job job = Job.getInstance(getConf(),getConf().get("mapreduce.job.name",
         "syncTable_" + sourceTableName + "-" + targetTableName));
     Configuration jobConf = job.getConfiguration();
-    if (jobConf.get("hadoop.security.authentication").equals("kerberos")) {
+    if ("kerberos".equalsIgnoreCase(jobConf.get("hadoop.security.authentication"))) {
       TokenCache.obtainTokensForNamenodes(job.getCredentials(), new
           Path[] { sourceHashDir }, getConf());
     }