Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A88910819 for ; Tue, 1 Apr 2014 16:08:38 +0000 (UTC) Received: (qmail 74039 invoked by uid 500); 1 Apr 2014 16:08:37 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 73786 invoked by uid 500); 1 Apr 2014 16:08:34 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 73729 invoked by uid 99); 1 Apr 2014 16:08:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 16:08:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 16:08:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B314B23888E4; Tue, 1 Apr 2014 16:08:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Tue, 01 Apr 2014 16:08:09 -0000 To: commits@hbase.apache.org From: tedyu@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140401160809.B314B23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + *

+ * 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 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 perms = new ArrayList(); + for (AccessControlProtos.UserPermission perm: response.getUserPermissionList()) { + perms.add(ProtobufUtil.toUserPermission(perm)); + } + return perms; + } + + /** * Convert a protobuf UserTablePermissions to a * ListMultimap 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(