本文整理了Java中org.opencastproject.security.api.User.hasRole()
方法的一些代码示例,展示了User.hasRole()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。User.hasRole()
方法的具体详情如下:
包路径:org.opencastproject.security.api.User
类名称:User
方法名:hasRole
[英]Returns whether the user is in a specific role.
[中]返回用户是否处于特定角色。
代码示例来源:origin: opencast/opencast
/**
* Check if the current user has access to the capture agent with the given id.
* @param agentId
* The agent id to check.
* @throws UnauthorizedException
* If the user doesn't have access.
*/
public static void checkAgentAccess(final SecurityService securityService, final String agentId)
throws UnauthorizedException {
if (isBlank(agentId)) {
return;
}
final User user = securityService.getUser();
if (user.hasRole(SecurityConstants.GLOBAL_ADMIN_ROLE) || user.hasRole(user.getOrganization().getAdminRole())) {
return;
}
if (!user.hasRole(SecurityUtil.getCaptureAgentRole(agentId))) {
throw new UnauthorizedException(user, "schedule");
}
}
代码示例来源:origin: opencast/opencast
if (user.hasRole(GLOBAL_ADMIN_ROLE) || user.hasRole(org.getAdminRole()))
return true;
代码示例来源:origin: opencast/opencast
if (!originalUser.hasRole(GLOBAL_ADMIN_ROLE)) {
logger.warn("An unauthorized request is trying to switch from organization '{}' to '{}'",
originalOrganization.getId(), organizationHeader);
if (!originalUser.hasRole(GLOBAL_SUDO_ROLE)) {
logger.warn("An unauthorized request is trying to switch from user '{}' to '{}'", originalUser.getUsername(),
userHeader);
if (!originalUser.hasRole(GLOBAL_ADMIN_ROLE)) {
if (requestedUser.hasRole(systemRole)) {
logger.warn("An unauthorized request is trying to switch to an admin user, from '{}' to '{}'",
originalUser.getUsername(), userHeader);
if (!originalUser.hasRole(organizationAdminRole) && requestedUser.hasRole(organizationAdminRole)) {
logger.warn("An unauthorized request is trying to switch to an admin user, from '{}' to '{}'",
originalUser.getUsername(), userHeader);
if (!originalUser.hasRole(GLOBAL_SUDO_ROLE)) {
logger.warn("An unauthorized request is trying to switch roles from '{}' to '{}'", requestedUser.getRoles(),
rolesHeader);
if (!originalUser.hasRole(GLOBAL_ADMIN_ROLE)) {
if (!originalUser.hasRole(organizationAdminRole) && requestedRoles.contains(organizationAdminRole)) {
logger.warn("An unauthorized request by user '{}' is trying to gain admin role '{}'",
originalUser.getUsername(), organizationAdminRole);
内容来源于网络,如有侵权,请联系作者删除!