[ 
https://issues.apache.org/jira/browse/HBASE-15465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

li xiang updated HBASE-15465:
-----------------------------
    Fix Version/s: master
           Status: Patch Available  (was: In Progress)

> userPermission returned by getUserPermission() for the selected namespace 
> does not have namespace set
> -----------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-15465
>                 URL: https://issues.apache.org/jira/browse/HBASE-15465
>             Project: HBase
>          Issue Type: Bug
>          Components: Protobufs
>    Affects Versions: 1.2.0
>            Reporter: li xiang
>            Assignee: li xiang
>            Priority: Minor
>             Fix For: master
>
>         Attachments: HBASE-15465.patch.v0, HBASE-15465.patch.v1
>
>
> The request sent is with type = Namespace, but the response returned contains 
> Global permissions (that is, the field of namespace is not set)
> It is in 
> hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java,
>  from line 2380, and I made some comments into it
> {code}
> /**
>    * 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(ByteStringer.wrap(namespace)); 
>     }
>     builder.setType(AccessControlProtos.Permission.Type.Namespace);  
> //builder is set with type = Namespace
>     AccessControlProtos.GetUserPermissionsRequest request = builder.build();  
> //I printed the request, its type is Namespace, which is correct.
>     AccessControlProtos.GetUserPermissionsResponse response =  
>        protocol.getUserPermissions(null, request);
> /* I printed the response, it contains Global permissions, as below, not a 
> Namespace permission.
> user_permission {
>   user: "a1"
>   permission {
>     type: Global
>     global_permission {
>       action: READ
>       action: WRITE
>       action: ADMIN
>       action: EXEC
>       action: CREATE
>     }
>   }
> }
> AccessControlProtos.GetUserPermissionsRequest has a member called type_ to 
> store the type, but AccessControlProtos.GetUserPermissionsResponse does not.
> */
>      
>     List<UserPermission> perms = new 
> ArrayList<UserPermission>(response.getUserPermissionCount());
>     for (AccessControlProtos.UserPermission perm: 
> response.getUserPermissionList()) {
>       perms.add(ProtobufUtil.toUserPermission(perm));  // (1)
>     }
>     return perms;
>   }
> {code}
> it could be more reasonable to return user permissions with namespace set in 
> getUserPermission() for selected namespace ?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to