HBASE-15465 userPermission returned by getUserPermission() for the selected namespace does not have namespace set (li xiang)
This commit is contained in:
parent
92f5595e7e
commit
af5146ee04
|
@ -497,11 +497,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;
|
||||
}
|
||||
|
@ -620,11 +628,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) {
|
||||
|
|
|
@ -2601,6 +2601,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue