Search in sources :

Example 31 with PrivilegeException

use of cz.metacentrum.perun.core.api.exceptions.PrivilegeException 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
	 *
	 * @throws InternalErrorException
	 * @throws PrivilegeException
	 * @throws UserNotExistsException
	 * @throws AlreadyAdminException
	 */
public static void setRole(PerunSession sess, User user, PerunBean complementaryObject, Role role) throws InternalErrorException, PrivilegeException, UserNotExistsException, AlreadyAdminException {
    Utils.notNull(role, "role");
    ((PerunBl) sess.getPerun()).getUsersManagerBl().checkUserExists(sess, user);
    if (!isAuthorized(sess, Role.PERUNADMIN))
        throw new PrivilegeException("You are not privileged to use this method setRole.");
    cz.metacentrum.perun.core.blImpl.AuthzResolverBlImpl.setRole(sess, user, complementaryObject, role);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 32 with PrivilegeException

use of cz.metacentrum.perun.core.api.exceptions.PrivilegeException in project perun by CESNET.

the class AuthzResolver method unsetRole.

/**
	 * Unset role for group and <b>all</b> complementary objects
	 *
	 * If some complementary object is wrong for the role, throw an exception.
	 * For role "perunadmin" ignore complementary objects.
	 *
	 * @param sess perun session
	 * @param authorizedGroup the group for unsetting role
	 * @param role role of user in a session
	 * @param complementaryObjects objects for which role will be unset
	 *
	 * @throws InternalErrorException
	 * @throws PrivilegeException
	 * @throws GroupNotExistsException
	 * @throws GroupNotAdminException
	 */
public static void unsetRole(PerunSession sess, Group authorizedGroup, Role role, List<PerunBean> complementaryObjects) throws InternalErrorException, PrivilegeException, GroupNotExistsException, GroupNotAdminException {
    Utils.notNull(role, "role");
    ((PerunBl) sess.getPerun()).getGroupsManagerBl().checkGroupExists(sess, authorizedGroup);
    if (!isAuthorized(sess, Role.PERUNADMIN))
        throw new PrivilegeException("You are not privileged to use this method setRole.");
    cz.metacentrum.perun.core.blImpl.AuthzResolverBlImpl.unsetRole(sess, authorizedGroup, role, complementaryObjects);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 33 with PrivilegeException

use of cz.metacentrum.perun.core.api.exceptions.PrivilegeException in project perun by CESNET.

the class AuthzResolver method setRole.

/**
	 * Set role for authorizedGroup 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 authorizedGroup the group for setting role
	 * @param role role of user in a session
	 * @param complementaryObject object for which role will be set
	 *
	 * @throws InternalErrorException
	 * @throws PrivilegeException
	 * @throws GroupNotExistsException
	 * @throws AlreadyAdminException
	 */
public static void setRole(PerunSession sess, Group authorizedGroup, PerunBean complementaryObject, Role role) throws InternalErrorException, PrivilegeException, GroupNotExistsException, AlreadyAdminException {
    Utils.notNull(role, "role");
    ((PerunBl) sess.getPerun()).getGroupsManagerBl().checkGroupExists(sess, authorizedGroup);
    if (!isAuthorized(sess, Role.PERUNADMIN))
        throw new PrivilegeException("You are not privileged to use this method setRole.");
    cz.metacentrum.perun.core.blImpl.AuthzResolverBlImpl.setRole(sess, authorizedGroup, complementaryObject, role);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 34 with PrivilegeException

use of cz.metacentrum.perun.core.api.exceptions.PrivilegeException in project perun by CESNET.

the class GeneralServiceManagerImpl method createCompleteService.

@Override
@Transactional(rollbackFor = Exception.class)
public Service createCompleteService(PerunSession perunSession, String serviceName, String scriptPath, int defaultDelay, boolean enabled) throws InternalErrorException, PrivilegeException, ServiceExistsException {
    if (!AuthzResolver.isAuthorized(perunSession, Role.PERUNADMIN)) {
        throw new PrivilegeException(perunSession, "createCompleteService");
    }
    Service service = null;
    try {
        service = servicesManager.getServiceByName(perunSession, serviceName);
        if (service != null) {
            throw new ServiceExistsException(service);
        }
    } catch (ServiceNotExistsException e) {
        service = new Service();
        service.setName(serviceName);
        service = servicesManager.createService(perunSession, service);
    }
    ExecService genExecService = new ExecService();
    genExecService.setService(service);
    genExecService.setDefaultDelay(defaultDelay);
    genExecService.setEnabled(enabled);
    genExecService.setScript(scriptPath);
    genExecService.setExecServiceType(ExecServiceType.GENERATE);
    genExecService.setId(execServiceDao.insertExecService(genExecService));
    ExecService sendExecService = new ExecService();
    sendExecService.setService(service);
    sendExecService.setDefaultDelay(defaultDelay);
    sendExecService.setEnabled(enabled);
    sendExecService.setScript(scriptPath);
    sendExecService.setExecServiceType(ExecServiceType.SEND);
    sendExecService.setId(execServiceDao.insertExecService(sendExecService));
    this.createDependency(sendExecService, genExecService);
    return service;
}
Also used : ServiceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ServiceNotExistsException) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) ExecService(cz.metacentrum.perun.taskslib.model.ExecService) Service(cz.metacentrum.perun.core.api.Service) ServiceExistsException(cz.metacentrum.perun.core.api.exceptions.ServiceExistsException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with PrivilegeException

use of cz.metacentrum.perun.core.api.exceptions.PrivilegeException in project perun by CESNET.

the class AuthzResolver method setRole.

/**
	 * Set role for auhtorizedGroup and <b>all</b> complementary objects.
	 *
	 * If some complementary object is wrong for the role, throw an exception.
	 * For role "perunadmin" ignore complementary objects.
	 *
	 * @param sess perun session
	 * @param authorizedGroup the group for setting role
	 * @param role role of user in a session
	 * @param complementaryObjects objects for which role will be set
	 *
	 * @throws InternalErrorException
	 * @throws PrivilegeException
	 * @throws GroupNotExistsException
	 * @throws AlreadyAdminException
	 */
public static void setRole(PerunSession sess, Group authorizedGroup, Role role, List<PerunBean> complementaryObjects) throws InternalErrorException, PrivilegeException, GroupNotExistsException, AlreadyAdminException {
    Utils.notNull(role, "role");
    ((PerunBl) sess.getPerun()).getGroupsManagerBl().checkGroupExists(sess, authorizedGroup);
    if (!isAuthorized(sess, Role.PERUNADMIN))
        throw new PrivilegeException("You are not privileged to use this method setRole.");
    cz.metacentrum.perun.core.blImpl.AuthzResolverBlImpl.setRole(sess, authorizedGroup, role, complementaryObjects);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Aggregations

PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)66 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)22 Facility (cz.metacentrum.perun.core.api.Facility)18 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)13 Group (cz.metacentrum.perun.core.api.Group)13 RichFacility (cz.metacentrum.perun.core.api.RichFacility)13 Vo (cz.metacentrum.perun.core.api.Vo)8 RichGroup (cz.metacentrum.perun.core.api.RichGroup)7 ArrayList (java.util.ArrayList)7 User (cz.metacentrum.perun.core.api.User)6 Service (cz.metacentrum.perun.core.api.Service)5 FacilityNotExistsException (cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException)5 ServiceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ServiceNotExistsException)5 Member (cz.metacentrum.perun.core.api.Member)4 RichMember (cz.metacentrum.perun.core.api.RichMember)4 IllegalArgumentException (cz.metacentrum.perun.core.api.exceptions.IllegalArgumentException)4 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)4 Task (cz.metacentrum.perun.taskslib.model.Task)4 RichUser (cz.metacentrum.perun.core.api.RichUser)3 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)3