hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerry...@apache.org
Subject hbase git commit: HBASE-15465 userPermission returned by getUserPermission() for the selected namespace does not have namespace set (li xiang)
Date Fri, 20 May 2016 03:44:16 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.3 1eb004d88 -> be2252d08


HBASE-15465 userPermission returned by getUserPermission() for the selected namespace does
not have namespace set (li xiang)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/be2252d0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/be2252d0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/be2252d0

Branch: refs/heads/branch-1.3
Commit: be2252d085539354916e8574e3c7504fd068f177
Parents: 1eb004d
Author: Jerry He <jerryjch@apache.org>
Authored: Thu May 19 20:35:58 2016 -0700
Committer: Jerry He <jerryjch@apache.org>
Committed: Thu May 19 20:41:38 2016 -0700

----------------------------------------------------------------------
 .../security/access/AccessControlLists.java     | 22 +++++++++++++-------
 .../security/access/TestAccessController.java   |  4 ++++
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/be2252d0/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
index 887af0a..6849790 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlLists.java
@@ -496,11 +496,19 @@ public class AccessControlLists {
 
     List<UserPermission> perms = new ArrayList<UserPermission>();
 
-    for (Map.Entry<String, TablePermission> entry : allPerms.entries()) {
-      UserPermission up = new UserPermission(Bytes.toBytes(entry.getKey()),
-          entry.getValue().getTableName(), entry.getValue().getFamily(),
-          entry.getValue().getQualifier(), entry.getValue().getActions());
-      perms.add(up);
+    if(isNamespaceEntry(entryName)) {  // Namespace
+      for (Map.Entry<String, TablePermission> entry : allPerms.entries()) {
+        UserPermission up = new UserPermission(Bytes.toBytes(entry.getKey()),
+          entry.getValue().getNamespace(), entry.getValue().getActions());
+        perms.add(up);
+      }
+    } else {  // Table
+      for (Map.Entry<String, TablePermission> entry : allPerms.entries()) {
+        UserPermission up = new UserPermission(Bytes.toBytes(entry.getKey()),
+            entry.getValue().getTableName(), entry.getValue().getFamily(),
+            entry.getValue().getQualifier(), entry.getValue().getActions());
+        perms.add(up);
+      }
     }
     return perms;
   }
@@ -619,11 +627,11 @@ public class AccessControlLists {
   }
 
   public static boolean isNamespaceEntry(String entryName) {
-    return entryName.charAt(0) == NAMESPACE_PREFIX;
+    return entryName != null && entryName.charAt(0) == NAMESPACE_PREFIX;
   }
 
   public static boolean isNamespaceEntry(byte[] entryName) {
-    return entryName[0] == NAMESPACE_PREFIX;
+    return entryName != null && entryName.length !=0 && entryName[0] == NAMESPACE_PREFIX;
   }
 
   public static String toNamespaceEntry(String namespace) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/be2252d0/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
index 173067a..a588a6c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
@@ -2599,6 +2599,10 @@ public class TestAccessController extends SecureTestUtil {
           systemUserConnection, AccessControlLists.toNamespaceEntry(namespace));
       assertTrue(namespacePermissions != null);
       assertTrue(namespacePermissions.size() == 1);
+      for (UserPermission namespacePermission : namespacePermissions) {
+        assertFalse(namespacePermission.isGlobal());  // Verify it is not a global user permission
+        assertEquals(namespace, namespacePermission.getNamespace());  // Verify namespace
is set
+      }
     } catch (Throwable thw) {
       throw new HBaseException(thw);
     }


Mime
View raw message