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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations