You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2014/04/01 18:09:36 UTC
svn commit: r1583725 - in /hbase/trunk:
hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
hbase-shell/src/main/ruby/hbase/security.rb
Author: tedyu
Date: Tue Apr 1 16:09:35 2014
New Revision: 1583725
URL: http://svn.apache.org/r1583725
Log:
HBASE-10879 user_permission shell command on namespace doesn't work
Modified:
hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
hbase/trunk/hbase-shell/src/main/ruby/hbase/security.rb
Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1583725&r1=1583724&r2=1583725&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java Tue Apr 1 16:09:35 2014
@@ -2179,6 +2179,34 @@ public final class ProtobufUtil {
}
/**
+ * 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
* ListMultimap<String, TablePermission> where key is username.
*
Modified: hbase/trunk/hbase-shell/src/main/ruby/hbase/security.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-shell/src/main/ruby/hbase/security.rb?rev=1583725&r1=1583724&r2=1583725&view=diff
==============================================================================
--- hbase/trunk/hbase-shell/src/main/ruby/hbase/security.rb (original)
+++ hbase/trunk/hbase-shell/src/main/ruby/hbase/security.rb Tue Apr 1 16:09:35 2014
@@ -168,7 +168,7 @@ module Hbase
raise(ArgumentError, "Can't find a namespace: #{namespace_name}") unless namespace_exists?(namespace_name)
# invoke cp endpoint to perform access controls
perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions(
- protocol, table_name.to_java_bytes)
+ protocol, namespace_name.to_java_bytes)
else
raise(ArgumentError, "Can't find table: #{table_name}") unless exists?(table_name)
perms = org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions(