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


Java User.getGroupNames方法代码示例

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


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

示例1: authorize

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
/**
 * Authorize a global permission based on ACLs for the given user and the
 * user's groups.
 * @param user
 * @param action
 * @return true if known and authorized, false otherwise
 */
public boolean authorize(User user, Permission.Action action) {
  if (user == null) {
    return false;
  }

  if (authorize(globalCache.getUser(user.getShortName()), action)) {
    return true;
  }

  String[] groups = user.getGroupNames();
  if (groups != null) {
    for (String group : groups) {
      if (authorize(globalCache.getGroup(group), action)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:TableAuthManager.java

示例2: getCellPermissionsForUser

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
public static List<Permission> getCellPermissionsForUser(User user, Cell cell)
    throws IOException {
  // Save an object allocation where we can
  if (cell.getTagsLength() == 0) {
    return null;
  }
  List<Permission> results = Lists.newArrayList();
  Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
     cell.getTagsLength());
  while (tagsIterator.hasNext()) {
    Tag tag = tagsIterator.next();
    if (tag.getType() == ACL_TAG_TYPE) {
      // Deserialize the table permissions from the KV
      // TODO: This can be improved. Don't build UsersAndPermissions just to unpack it again,
      // use the builder
      AccessControlProtos.UsersAndPermissions.Builder builder = 
        AccessControlProtos.UsersAndPermissions.newBuilder();
      ProtobufUtil.mergeFrom(builder, tag.getBuffer(), tag.getTagOffset(), tag.getTagLength());
      ListMultimap<String,Permission> kvPerms =
        ProtobufUtil.toUsersAndPermissions(builder.build());
      // Are there permissions for this user?
      List<Permission> userPerms = kvPerms.get(user.getShortName());
      if (userPerms != null) {
        results.addAll(userPerms);
      }
      // Are there permissions for any of the groups this user belongs to?
      String groupNames[] = user.getGroupNames();
      if (groupNames != null) {
        for (String group : groupNames) {
          List<Permission> groupPerms = kvPerms.get(AuthUtil.toGroupEntry(group));
          if (results != null) {
            results.addAll(groupPerms);
          }
        }
      }
    }
  }
  return results;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:AccessControlLists.java

示例3: hasAccess

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
public boolean hasAccess(User user, TableName table, Permission.Action action) {
  if (userHasAccess(user, table, action)) {
    return true;
  }

  String[] groups = user.getGroupNames();
  if (groups != null) {
    for (String group : groups) {
      if (groupHasAccess(group, table, action)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TableAuthManager.java


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