Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Do we have java API for HBase access control?

Do we have java API for HBase access control?

Rising Star

I would like to grant permission to HBase table using java API. is there any java api available for HBase 1.1.2 ?


Re: Do we have java API for HBase access control?


Yes there is, from reference guide

public static void grantOnTable(final HBaseTestingUtility util, final String user,
    final TableName table, final byte[] family, final byte[] qualifier,
    final Permission.Action... actions) throws Exception {

il.updateACLs(util, new Callable<Void>() {
    public Void call() throws Exception {
      Configuration conf = HBaseConfiguration.create();
      Connection connection = ConnectionFactory.createConnection(conf);
      try (Connection connection = ConnectionFactory.createConnection(conf)) {
        try (Table table = connection.getTable(TableName.valueOf(tablename)) {
          try {
            BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW);
            AccessControlService.BlockingInterface protocol =
            ProtobufUtil.grant(protocol, user, table, family, qualifier, actions);
          } finally {
          return null;

Re: Do we have java API for HBase access control?


Thanks Artem. This is still a little bit low level. You can use as a client-facing API to grant / revoke at a higher level.

Re: Do we have java API for HBase access control?

New Contributor

An alternate option would be to leverage the Ranger REST API which can be called from a Java app.

You can find information about the Ranger REST API, which allows for the creation of Security Policies for Hive, HDFS and HBase among other HDP components:

There are many tutorials available for invoking REST APIs from Java.

The following example provides some clear directions for working with REST APIs and JSON content in Java:

Don't have an account?
Coming from Hortonworks? Activate your account here