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:08:09 UTC

svn commit: r1583724 - in /hbase/branches/0.98: 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:08:09 2014
New Revision: 1583724

URL: http://svn.apache.org/r1583724
Log:
HBASE-10879 user_permission shell command on namespace doesn't work


Modified:
    hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
    hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/security.rb

Modified: hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1583724&r1=1583723&r2=1583724&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java (original)
+++ hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java Tue Apr  1 16:08:09 2014
@@ -2201,6 +2201,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/branches/0.98/hbase-shell/src/main/ruby/hbase/security.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/security.rb?rev=1583724&r1=1583723&r2=1583724&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/security.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/security.rb Tue Apr  1 16:08:09 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(