use of cz.metacentrum.perun.core.api.exceptions.RoleManagementRulesNotExistsException in project perun by CESNET.
the class AuthzResolver method setRole.
/**
* Set role for user and <b>one</b> complementary object.
*
* If complementary object is wrong for the role, throw an exception.
* For role "PERUNADMIN" ignore complementary object.
*
* @param sess perun session
* @param user the user for setting role
* @param role role of user in a session
* @param complementaryObject object for which role will be set
*/
public static void setRole(PerunSession sess, User user, PerunBean complementaryObject, String role) throws PrivilegeException, UserNotExistsException, AlreadyAdminException, RoleCannotBeManagedException {
Utils.notNull(role, "role");
if (!roleExists(role)) {
throw new InternalErrorException("Role: " + role + " does not exists.");
}
((PerunBl) sess.getPerun()).getUsersManagerBl().checkUserExists(sess, user);
try {
if (!authorizedToManageRole(sess, complementaryObject, role)) {
throw new PrivilegeException("You are not privileged to use the method setRole.");
}
} catch (RoleManagementRulesNotExistsException e) {
throw new InternalErrorException("Management rules not exist for the role " + role, e);
}
AuthzResolverBlImpl.setRole(sess, user, complementaryObject, role);
}
Aggregations