public static AccessControlProtos.GrantRequest buildGrantRequest(String username,
    String namespace, boolean mergeExistingPermissions,
    AccessControlProtos.Permission.Action... actions) {
    AccessControlProtos.Permission.Builder ret = AccessControlProtos.Permission.newBuilder();
    AccessControlProtos.NamespacePermission.Builder permissionBuilder =
      AccessControlProtos.NamespacePermission.newBuilder();
    for (AccessControlProtos.Permission.Action a : actions) {
      permissionBuilder.addAction(a);
    }
    if (namespace != null) {
      permissionBuilder.setNamespaceName(ByteString.copyFromUtf8(namespace));
    }
    ret.setType(AccessControlProtos.Permission.Type.Namespace)
      .setNamespacePermission(permissionBuilder);
    return AccessControlProtos.GrantRequest.newBuilder()
      .setUserPermission(AccessControlProtos.UserPermission.newBuilder()
        .setUser(ByteString.copyFromUtf8(username)).setPermission(ret))
      .setMergeExistingPermissions(mergeExistingPermissions).build();
  }
Create a request to grant user namespace permissions.
@param username  the short user name who to grant permissions
@param namespace optional table name the permissions apply
@param actions   the permissions to be granted
@return A {@link AccessControlProtos} GrantRequest
hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlUtil.java