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


Java User.getAccountId方法代码示例

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


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

示例1: checkAccess

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public boolean checkAccess(final User user, final String commandName) throws PermissionDeniedException {
    final Account account = _accountService.getAccount(user.getAccountId());
    if (account == null) {
        throw new PermissionDeniedException("The account id=" + user.getAccountId() + "for user id=" + user.getId() + "is null");
    }

    final RoleType roleType = _accountService.getRoleType(account);
    final boolean isAllowed =
            commandsPropertiesOverrides.contains(commandName) ? commandsPropertiesRoleBasedApisMap.get(roleType).contains(commandName) : annotationRoleBasedApisMap.get(
                    roleType).contains(commandName);

    if (!isAllowed) {
        throw new PermissionDeniedException("The API does not exist or is blacklisted. Role type=" + roleType.toString() + " is not allowed to request the api: " +
                commandName);
    }
    return isAllowed;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:StaticRoleBasedAPIAccessChecker.java

示例2: getEntityOwnerId

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public long getEntityOwnerId() {
    final User user = _entityMgr.findById(User.class, getId());
    if (user != null) {
        return user.getAccountId();
    }

    return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:10,代码来源:RegisterCmd.java

示例3: checkAccess

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public boolean checkAccess(final User user, final String apiCommandName) throws PermissionDeniedException {
    // check if api rate limiting is enabled or not
    if (!enabled) {
        return true;
    }
    final Long accountId = user.getAccountId();
    final Account account = _accountService.getAccount(accountId);
    if (_accountService.isRootAdmin(account.getId())) {
        // no API throttling on root admin
        return true;
    }
    StoreEntry entry = _store.get(accountId);

    if (entry == null) {

        /* Populate the entry, thus unlocking any underlying mutex */
        entry = _store.create(accountId, timeToLive);
    }

    /* Increment the client count and see whether we have hit the maximum allowed clients yet. */
    final int current = entry.incrementAndGet();

    if (current <= maxAllowed) {
        s_logger.trace("account (" + account.getAccountId() + "," + account.getAccountName() + ") has current count = " + current);
        return true;
    } else {
        final long expireAfter = entry.getExpireDuration();
        // for this exception, we can just show the same message to user and admin users.
        final String msg = "The given user has reached his/her account api limit, please retry after " + expireAfter + " ms.";
        s_logger.warn(msg);
        throw new RequestLimitException(msg);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:35,代码来源:ApiRateLimitServiceImpl.java

示例4: getEventDescription

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public String getEventDescription() {
    final User user = _responseGenerator.findUserById(getId());
    return (user != null ? ("deleting User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId())
            : "user delete, but this user does not exist in the system");
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:7,代码来源:DeleteAccountCmd.java


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