hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [2/3] hbase git commit: HBASE-15465 userPermission returned by getUserPermission() for the selected namespace does not have namespace set (li xiang)
Date Sat, 28 May 2016 01:34:07 GMT
HBASE-15465 userPermission returned by getUserPermission() for the selected namespace does
not have namespace set (li xiang)

Conflicts:
	hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java


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

Branch: refs/heads/0.98
Commit: 821093439fd7afd9397898b3334109f4a3fbb2d5
Parents: 77befee
Author: Jerry He <jerryjch@apache.org>
Authored: Thu May 19 20:35:58 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Fri May 27 18:33:41 2016 -0700

----------------------------------------------------------------------
 .../security/access/AccessControlLists.java     | 22 +++++++++++++-------
 .../security/access/TestAccessController.java   |  5 ++---
 2 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/82109343/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 41f7b63..98ab676 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
@@ -498,11 +498,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;
   }
@@ -621,11 +629,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/82109343/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 f4534db..5ce90eb 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
@@ -2421,11 +2421,10 @@ public class TestAccessController extends SecureTestUtil {
       List<UserPermission> namespacePermissions = AccessControlClient.getUserPermissions(
         conf, AccessControlLists.toNamespaceEntry(namespaceRegexWithoutPrefix));
       assertTrue(namespacePermissions != null);
-      assertEquals(expectedAmount, namespacePermissions.size());
+      assertTrue(namespacePermissions.size() == 1);
       for (UserPermission namespacePermission : namespacePermissions) {
         assertFalse(namespacePermission.isGlobal());  // Verify it is not a global user permission
-        // Verify namespace is set
-        assertEquals(expectedNamespace, namespacePermission.getNamespace());
+        assertEquals(expectedNamespace, namespacePermission.getNamespace());  // Verify namespace
is set
       }
     } catch (Throwable thw) {
       throw new HBaseException(thw);


Mime
View raw message