当前位置: 首页>>代码示例>>Java>>正文


Java ProtobufUtil.getUserPermissions方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufUtil.getUserPermissions方法的具体用法?Java ProtobufUtil.getUserPermissions怎么用?Java ProtobufUtil.getUserPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.protobuf.ProtobufUtil的用法示例。


在下文中一共展示了ProtobufUtil.getUserPermissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGlobalPermissionList

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testGlobalPermissionList() throws Exception {
  List<UserPermission> perms;
  Table acl = systemUserConnection.getTable(AccessControlLists.ACL_TABLE_NAME);
  try {
    BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW);
    AccessControlService.BlockingInterface protocol =
      AccessControlService.newBlockingStub(service);
    perms = ProtobufUtil.getUserPermissions(null, protocol);
  } finally {
    acl.close();
  }
  UserPermission adminPerm = new UserPermission(Bytes.toBytes(USER_ADMIN.getShortName()),
    AccessControlLists.ACL_TABLE_NAME, null, null, Bytes.toBytes("ACRW"));
  assertTrue("Only global users and user admin has permission on table _acl_ per setup",
    perms.size() == 5 && hasFoundUserPermission(adminPerm, perms));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestAccessController.java

示例2: getUserPermissions

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * List all the userPermissions matching the given pattern.
 * @param connection The Connection instance to use
 * @param tableRegex The regular expression string to match against
 * @return - returns an array of UserPermissions
 * @throws Throwable
 */
public static List<UserPermission> getUserPermissions(Connection connection, String tableRegex)
    throws Throwable {
  PayloadCarryingRpcController controller
    = ((ClusterConnection) connection).getRpcControllerFactory().newController();
  List<UserPermission> permList = new ArrayList<UserPermission>();
  try (Table table = connection.getTable(ACL_TABLE_NAME)) {
    try (Admin admin = connection.getAdmin()) {
      CoprocessorRpcChannel service = table.coprocessorService(HConstants.EMPTY_START_ROW);
      BlockingInterface protocol =
          AccessControlProtos.AccessControlService.newBlockingStub(service);
      HTableDescriptor[] htds = null;
      if (tableRegex == null || tableRegex.isEmpty()) {
        permList = ProtobufUtil.getUserPermissions(controller, protocol);
      } else if (tableRegex.charAt(0) == '@') {
        String namespace = tableRegex.substring(1);
        permList = ProtobufUtil.getUserPermissions(controller, protocol,
          Bytes.toBytes(namespace));
      } else {
        htds = admin.listTables(Pattern.compile(tableRegex), true);
        for (HTableDescriptor hd : htds) {
          permList.addAll(ProtobufUtil.getUserPermissions(controller, protocol,
            hd.getTableName()));
        }
      }
    }
  }
  return permList;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:AccessControlClient.java


注:本文中的org.apache.hadoop.hbase.protobuf.ProtobufUtil.getUserPermissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。