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


Java Permission.Action方法代码示例

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


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

示例1: createTable

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
private void createTable(Admin admin, TableName tableName, boolean setVersion,
    boolean acl) throws IOException {
  if (!admin.tableExists(tableName)) {
    HTableDescriptor htd = new HTableDescriptor(tableName);
    HColumnDescriptor family = new HColumnDescriptor(FAMILY_NAME);
    if (setVersion) {
      family.setMaxVersions(DEFAULT_TABLES_COUNT);
    }
    htd.addFamily(family);
    admin.createTable(htd);
    if (acl) {
      LOG.info("Granting permissions for user " + USER.getShortName());
      Permission.Action[] actions = { Permission.Action.READ };
      try {
        AccessControlClient.grant(ConnectionFactory.createConnection(getConf()), tableName,
            USER.getShortName(), null, null, actions);
      } catch (Throwable e) {
        LOG.fatal("Error in granting permission for the user " + USER.getShortName(), e);
        throw new IOException(e);
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:IntegrationTestBigLinkedListWithVisibility.java

示例2: toPermissionAction

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * Converts a Permission.Action proto to a client Permission.Action object.
 *
 * @param action the protobuf Action
 * @return the converted Action
 */
public static Permission.Action toPermissionAction(
    AccessControlProtos.Permission.Action action) {
  switch (action) {
    case READ:
      return Permission.Action.READ;
    case WRITE:
      return Permission.Action.WRITE;
    case EXEC:
      return Permission.Action.EXEC;
    case CREATE:
      return Permission.Action.CREATE;
    case ADMIN:
      return Permission.Action.ADMIN;
  }
  throw new IllegalArgumentException("Unknown action value "+action.name());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ProtobufUtil.java

示例3: createTable

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
private void createTable(Admin admin, TableName tableName, boolean setVersion,
    boolean acl) throws IOException {
  if (!admin.tableExists(tableName)) {
    HTableDescriptor htd = new HTableDescriptor(tableName);
    HColumnDescriptor family = new HColumnDescriptor(FAMILY_NAME);
    if (setVersion) {
      family.setMaxVersions(DEFAULT_TABLES_COUNT);
    }
    htd.addFamily(family);
    admin.createTable(htd);
    if (acl) {
      LOG.info("Granting permissions for user " + USER.getShortName());
      Permission.Action[] actions = { Permission.Action.READ };
      try {
        AccessControlClient.grant(ConnectionFactory.createConnection(getConf()), tableName,
            USER.getShortName(), null, null, actions);
      } catch (Throwable e) {
        LOG.error(HBaseMarkers.FATAL, "Error in granting permission for the user " +
            USER.getShortName(), e);
        throw new IOException(e);
      }
    }
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:IntegrationTestBigLinkedListWithVisibility.java

示例4: toPermission

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * Convert a client Permission to a Permission proto
 *
 * @param perm the client Permission
 * @return the protobuf Permission
 */
public static AccessControlProtos.Permission toPermission(Permission perm) {
  AccessControlProtos.Permission.Builder builder = AccessControlProtos.Permission.newBuilder();
  if (perm instanceof TablePermission) {
    TablePermission tablePerm = (TablePermission)perm;
    if (tablePerm.hasTable()) {
      builder.setTable(ByteString.copyFrom(tablePerm.getTable()));
    }
    if (tablePerm.hasFamily()) {
      builder.setFamily(ByteString.copyFrom(tablePerm.getFamily()));
    }
    if (tablePerm.hasQualifier()) {
      builder.setQualifier(ByteString.copyFrom(tablePerm.getQualifier()));
    }
  }
  for (Permission.Action a : perm.getActions()) {
    builder.addAction(toPermissionAction(a));
  }
  return builder.build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:26,代码来源:ProtobufUtil.java

示例5: toUserPermission

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * Convert a client user permission to a user permission proto
 *
 * @param perm the client UserPermission
 * @return the protobuf UserPermission
 */
public static AccessControlProtos.UserPermission toUserPermission(UserPermission perm) {
  AccessControlProtos.Permission.Builder permissionBuilder =
      AccessControlProtos.Permission.newBuilder();
  for (Permission.Action a : perm.getActions()) {
    permissionBuilder.addAction(toPermissionAction(a));
  }
  if (perm.hasTable()) {
    permissionBuilder.setTable(ByteString.copyFrom(perm.getTable()));
  }
  if (perm.hasFamily()) {
    permissionBuilder.setFamily(ByteString.copyFrom(perm.getFamily()));
  }
  if (perm.hasQualifier()) {
    permissionBuilder.setQualifier(ByteString.copyFrom(perm.getQualifier()));
  }

  return AccessControlProtos.UserPermission.newBuilder()
      .setUser(ByteString.copyFrom(perm.getUser()))
      .setPermission(permissionBuilder)
      .build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:28,代码来源:ProtobufUtil.java

示例6: toPermission

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * Converts a Permission proto to a client Permission object.
 *
 * @param proto the protobuf Permission
 * @return the converted Permission
 */
public static Permission toPermission(AccessControlProtos.Permission proto) {
  if (proto.getType() != AccessControlProtos.Permission.Type.Global) {
    return toTablePermission(proto);
  } else {
    List<Permission.Action> actions = toPermissionActions(proto.getGlobalPermission().getActionList());
    return new Permission(actions.toArray(new Permission.Action[actions.size()]));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ProtobufUtil.java

示例7: toPermissionActions

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * Converts a list of Permission.Action proto to a list of client Permission.Action objects.
 *
 * @param protoActions the list of protobuf Actions
 * @return the converted list of Actions
 */
public static List<Permission.Action> toPermissionActions(
    List<AccessControlProtos.Permission.Action> protoActions) {
  List<Permission.Action> actions = new ArrayList<Permission.Action>(protoActions.size());
  for (AccessControlProtos.Permission.Action a : protoActions) {
    actions.add(toPermissionAction(a));
  }
  return actions;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ProtobufUtil.java

示例8: grant

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to grant a user global permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param userShortName the short name of the user to grant permissions
 * @param actions the permissions to be granted
 * @throws ServiceException
 */
public static void grant(RpcController controller,
    AccessControlService.BlockingInterface protocol, String userShortName,
    Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.GrantRequest request = RequestConverter.
    buildGrantRequest(userShortName, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.grant(controller, request);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:ProtobufUtil.java

示例9: revoke

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to revoke a user's global permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param userShortName the short name of the user to revoke permissions
 * @param actions the permissions to be revoked
 * @throws ServiceException
 */
public static void revoke(RpcController controller,
    AccessControlService.BlockingInterface protocol, String userShortName,
    Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.RevokeRequest request = RequestConverter.
    buildRevokeRequest(userShortName, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.revoke(controller, request);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:ProtobufUtil.java

示例10: grant

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to grant a user global permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param userShortName the short name of the user to grant permissions
 * @param actions the permissions to be granted
 * @throws ServiceException
 */
public static void grant(AccessControlService.BlockingInterface protocol,
    String userShortName, Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.GrantRequest request = RequestConverter.
    buildGrantRequest(userShortName, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.grant(null, request);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:ProtobufUtil.java

示例11: revoke

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to revoke a user's global permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param userShortName the short name of the user to revoke permissions
 * @param actions the permissions to be revoked
 * @throws ServiceException
 */
public static void revoke(AccessControlService.BlockingInterface protocol,
    String userShortName, Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.RevokeRequest request = RequestConverter.
    buildRevokeRequest(userShortName, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.revoke(null, request);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:ProtobufUtil.java

示例12: checkGlobalPerms

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
public void checkGlobalPerms(Permission.Action... actions) throws IOException {
  Permission[] perms = new Permission[actions.length];
  for (int i = 0; i < actions.length; i++) {
    perms[i] = new Permission(actions[i]);
  }
  HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
  try {
    AccessControllerProtocol protocol = acl.coprocessorProxy(AccessControllerProtocol.class,
      new byte[0]);
    protocol.checkPermissions(perms);
  } finally {
    acl.close();
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:15,代码来源:TestAccessController.java

示例13: checkTablePerms

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
public void checkTablePerms(byte[] table, byte[] family, byte[] column,
    Permission.Action... actions) throws IOException {
  Permission[] perms = new Permission[actions.length];
  for (int i = 0; i < actions.length; i++) {
    perms[i] = new TablePermission(table, family, column, actions[i]);
  }

  checkTablePerms(table, perms);
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:10,代码来源:TestAccessController.java

示例14: grant

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to grant a user namespace permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param namespace the short name of the user to grant permissions
 * @param actions the permissions to be granted
 * @throws ServiceException
 */
public static void grant(AccessControlService.BlockingInterface protocol,
    String userShortName, String namespace,
    Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.GrantRequest request = RequestConverter.
    buildGrantRequest(userShortName, namespace, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.grant(null, request);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:24,代码来源:ProtobufUtil.java

示例15: revoke

import org.apache.hadoop.hbase.security.access.Permission; //导入方法依赖的package包/类
/**
 * A utility used to revoke a user's namespace permissions.
 * <p>
 * It's also called by the shell, in case you want to find references.
 *
 * @param protocol the AccessControlService protocol proxy
 * @param userShortName the short name of the user to revoke permissions
 * @param namespace optional table name
 * @param actions the permissions to be revoked
 * @throws ServiceException
 */
public static void revoke(AccessControlService.BlockingInterface protocol,
    String userShortName, String namespace,
    Permission.Action... actions) throws ServiceException {
  List<AccessControlProtos.Permission.Action> permActions =
      Lists.newArrayListWithCapacity(actions.length);
  for (Permission.Action a : actions) {
    permActions.add(ProtobufUtil.toPermissionAction(a));
  }
  AccessControlProtos.RevokeRequest request = RequestConverter.
    buildRevokeRequest(userShortName, namespace, permActions.toArray(
      new AccessControlProtos.Permission.Action[actions.length]));
  protocol.revoke(null, request);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:25,代码来源:ProtobufUtil.java


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