HBASE-10879 user_permission shell command on namespace doesn't work

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1583725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2014-04-01 16:09:35 +00:00
parent 6217e4367d
commit e8f7f46609
2 changed files with 29 additions and 1 deletions

View File

@ -2178,6 +2178,34 @@ public final class ProtobufUtil {
return perms; return perms;
} }
/**
* A utility used to get permissions for selected namespace.
* <p>
* It's also called by the shell, in case you want to find references.
*
* @param protocol the AccessControlService protocol proxy
* @param namespace name of the namespace
* @throws ServiceException
*/
public static List<UserPermission> getUserPermissions(
AccessControlService.BlockingInterface protocol,
byte[] namespace) throws ServiceException {
AccessControlProtos.GetUserPermissionsRequest.Builder builder =
AccessControlProtos.GetUserPermissionsRequest.newBuilder();
if (namespace != null) {
builder.setNamespaceName(HBaseZeroCopyByteString.wrap(namespace));
}
builder.setType(AccessControlProtos.Permission.Type.Namespace);
AccessControlProtos.GetUserPermissionsRequest request = builder.build();
AccessControlProtos.GetUserPermissionsResponse response =
protocol.getUserPermissions(null, request);
List<UserPermission> perms = new ArrayList<UserPermission>();
for (AccessControlProtos.UserPermission perm: response.getUserPermissionList()) {
perms.add(ProtobufUtil.toUserPermission(perm));
}
return perms;
}
/** /**
* Convert a protobuf UserTablePermissions to a * Convert a protobuf UserTablePermissions to a
* ListMultimap<String, TablePermission> where key is username. * ListMultimap<String, TablePermission> where key is username.

View File

@ -168,7 +168,7 @@ module Hbase
raise(ArgumentError, "Can't find a namespace: #{namespace_name}") unless namespace_exists?(namespace_name) raise(ArgumentError, "Can't find a namespace: #{namespace_name}") unless namespace_exists?(namespace_name)
# invoke cp endpoint to perform access controls # invoke cp endpoint to perform access controls
perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions( perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions(
protocol, table_name.to_java_bytes) protocol, namespace_name.to_java_bytes)
else else
raise(ArgumentError, "Can't find table: #{table_name}") unless exists?(table_name) raise(ArgumentError, "Can't find table: #{table_name}") unless exists?(table_name)
perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions( perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions(