use of cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException in project perun by CESNET.
the class UsersManagerEntry method removeSpecificUserOwner.
@Override
public void removeSpecificUserOwner(PerunSession sess, User user, User specificUser) throws UserNotExistsException, PrivilegeException, SpecificUserExpectedException, NotSpecificUserExpectedException, RelationNotExistsException, SpecificUserOwnerAlreadyRemovedException {
Utils.checkPerunSession(sess);
getUsersManagerBl().checkUserExists(sess, user);
getUsersManagerBl().checkUserExists(sess, specificUser);
if (user.isServiceUser())
throw new NotSpecificUserExpectedException(user);
if (user.isSponsoredUser() && specificUser.isSponsoredUser())
throw new NotSpecificUserExpectedException(specificUser);
if (!specificUser.isSpecificUser())
throw new SpecificUserExpectedException(specificUser);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "removeSpecificUserOwner_User_User_policy", specificUser) && !AuthzResolver.authorizedInternal(sess, "owner-removeSpecificUserOwner_User_User_policy", user)) {
throw new PrivilegeException(sess, "removeSpecificUserOwner");
}
getUsersManagerBl().removeSpecificUserOwner(sess, user, specificUser);
}
use of cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException in project perun by CESNET.
the class UsersManagerEntry method addSpecificUserOwner.
@Override
public void addSpecificUserOwner(PerunSession sess, User user, User specificUser) throws UserNotExistsException, PrivilegeException, SpecificUserExpectedException, NotSpecificUserExpectedException, RelationExistsException {
Utils.checkPerunSession(sess);
getUsersManagerBl().checkUserExists(sess, user);
getUsersManagerBl().checkUserExists(sess, specificUser);
if (user.isServiceUser())
throw new NotSpecificUserExpectedException(user);
if (user.isSponsoredUser() && specificUser.isSponsoredUser())
throw new NotSpecificUserExpectedException(specificUser);
if (!specificUser.isSpecificUser())
throw new SpecificUserExpectedException(specificUser);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "addSpecificUserOwner_User_User_policy", specificUser) && !AuthzResolver.authorizedInternal(sess, "owner-addSpecificUserOwner_User_User_policy", user)) {
throw new PrivilegeException(sess, "addSpecificUserOwner");
}
getUsersManagerBl().addSpecificUserOwner(sess, user, specificUser);
}
use of cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException in project perun by CESNET.
the class UsersManagerEntry method getUsersBySpecificUser.
@Override
public List<User> getUsersBySpecificUser(PerunSession sess, User specificUser) throws UserNotExistsException, PrivilegeException, SpecificUserExpectedException {
Utils.checkPerunSession(sess);
getUsersManagerBl().checkUserExists(sess, specificUser);
if (!specificUser.isSpecificUser())
throw new SpecificUserExpectedException(specificUser);
List<Vo> vos = getUsersManagerBl().getVosWhereUserIsMember(sess, specificUser);
for (Vo vo : vos) {
if (!AuthzResolver.authorizedInternal(sess, "getUsersBySpecificUser_User_policy", Arrays.asList(specificUser, vo))) {
throw new PrivilegeException(sess, "getUsersBySpecificUser");
}
}
return getUsersManagerBl().getUsersBySpecificUser(sess, specificUser);
}
Aggregations