本文整理汇总了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;
}
示例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
}
示例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);
}
}
示例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");
}