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


Java User.getShortName方法代码示例

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


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

示例1: requireGlobalPermission

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
/**
 * Checks that the user has the given global permission. The generated
 * audit log message will contain context information for the operation
 * being authorized, based on the given parameters.
 * @param perm Action being requested
 * @param tableName Affected table name.
 * @param familyMap Affected column families.
 */
private void requireGlobalPermission(String request, Action perm, TableName tableName,
    Map<byte[], ? extends Collection<byte[]>> familyMap) throws IOException {
  User user = getActiveUser();
  AuthResult result = null;
  if (authManager.authorize(user, perm)) {
    result = AuthResult.allow(request, "Global check allowed", user, perm, tableName, familyMap);
    result.getParams().setTableName(tableName).setFamilies(familyMap);
    logResult(result);
  } else {
    result = AuthResult.deny(request, "Global check failed", user, perm, tableName, familyMap);
    result.getParams().setTableName(tableName).setFamilies(familyMap);
    logResult(result);
    if (authorizationEnabled) {
      throw new AccessDeniedException("Insufficient permissions for user '" +
        (user != null ? user.getShortName() : "null") +"' (global, action=" +
        perm.toString() + ")");
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:AccessController.java

示例2: initGlobal

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
/**
 * Returns a new {@code PermissionCache} initialized with permission assignments
 * from the {@code hbase.superuser} configuration key.
 */
private PermissionCache<Permission> initGlobal(Configuration conf) throws IOException {
  UserProvider userProvider = UserProvider.instantiate(conf);
  User user = userProvider.getCurrent();
  if (user == null) {
    throw new IOException("Unable to obtain the current user, " +
        "authorization checks for internal operations will not work correctly!");
  }
  PermissionCache<Permission> newCache = new PermissionCache<Permission>();
  String currentUser = user.getShortName();

  // the system user is always included
  List<String> superusers = Lists.asList(currentUser, conf.getStrings(
      Superusers.SUPERUSER_CONF_KEY, new String[0]));
  if (superusers != null) {
    for (String name : superusers) {
      if (AuthUtil.isGroupPrincipal(name)) {
        newCache.putGroup(AuthUtil.getGroupName(name),
            new Permission(Permission.Action.values()));
      } else {
        newCache.putUser(name, new Permission(Permission.Action.values()));
      }
    }
  }
  return newCache;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:TableAuthManager.java

示例3: postScannerOpen

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
    final Scan scan, final RegionScanner s) throws IOException {
  User user = VisibilityUtils.getActiveUser();
  if (user != null && user.getShortName() != null) {
    scannerOwners.put(s, user.getShortName());
  }
  return s;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:VisibilityController.java

示例4: getLabels

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public List<String> getLabels(User user, Authorizations authorizations) {
  if (authorizations != null) {
    List<String> labels = authorizations.getLabels();
    String userName = user.getShortName();
    Set<String> auths = new HashSet<String>();
    auths.addAll(this.labelsCache.getUserAuths(userName));
    auths.addAll(this.labelsCache.getGroupAuths(user.getGroupNames()));
    return dropLabelsNotInUserAuths(labels, new ArrayList<String>(auths), userName);
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:DefinedSetFilterScanLabelGenerator.java

示例5: getLabels

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public List<String> getLabels(User user, Authorizations authorizations) {
  if (authorizations == null || authorizations.getLabels() == null
      || authorizations.getLabels().isEmpty()) {
    String userName = user.getShortName();
    Set<String> auths = new HashSet<String>();
    auths.addAll(this.labelsCache.getUserAuths(userName));
    auths.addAll(this.labelsCache.getGroupAuths(user.getGroupNames()));
    return new ArrayList<String>(auths);
  }
  return authorizations.getLabels();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:FeedUserAuthScanLabelGenerator.java

示例6: getLabels

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public List<String> getLabels(User user, Authorizations authorizations) {
  String userName = user.getShortName();
  if (authorizations != null) {
    LOG.warn("Dropping authorizations requested by user " + userName + ": " + authorizations);
  }
  Set<String> auths = new HashSet<String>();
  auths.addAll(this.labelsCache.getUserAuths(userName));
  auths.addAll(this.labelsCache.getGroupAuths(user.getGroupNames()));
  return new ArrayList<String>(auths);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:EnforcingScanLabelGenerator.java

示例7: postScannerOpen

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
    final Scan scan, final RegionScanner s) throws IOException {
  User user = getActiveUser();
  if (user != null && user.getShortName() != null) {
    // store reference to scanner owner for later checks
    scannerOwners.put(s, user.getShortName());
  }
  return s;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:AccessController.java

示例8: checkSystemOrSuperUser

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
private void checkSystemOrSuperUser() throws IOException {
  // No need to check if we're not going to throw
  if (!authorizationEnabled) {
    return;
  }
  User activeUser = getActiveUser();
  if (!Superusers.isSuperUser(activeUser)) {
    throw new AccessDeniedException("User '" + (activeUser != null ?
      activeUser.getShortName() : "null") + "is not system or super user.");
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:AccessController.java

示例9: createStagingDir

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
private Path createStagingDir(Path baseDir,
                              User user,
                              TableName tableName) throws IOException {
  String tblName = tableName.getNameAsString().replace(":", "_");
  String randomDir = user.getShortName()+"__"+ tblName +"__"+
      (new BigInteger(RANDOM_WIDTH, random).toString(RANDOM_RADIX));
  return createStagingDir(baseDir, user, randomDir);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:SecureBulkLoadEndpoint.java

示例10: getRequestUserName

import org.apache.hadoop.hbase.security.User; //导入方法依赖的package包/类
@Override
public String getRequestUserName() {
  User user = getRequestUser();
  return user == null? null: user.getShortName();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:6,代码来源:RpcServer.java


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