Search in sources :

Example 1 with NotSpecificUserExpectedException

use of cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException 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);
}
Also used : SpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException) NotSpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) NotSpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException)

Example 2 with NotSpecificUserExpectedException

use of cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException 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);
}
Also used : SpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException) NotSpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) NotSpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException)

Example 3 with NotSpecificUserExpectedException

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

the class UsersManagerEntry method getSpecificUsersByUser.

@Override
public List<User> getSpecificUsersByUser(PerunSession sess, User user) throws UserNotExistsException, PrivilegeException, NotSpecificUserExpectedException {
    Utils.checkPerunSession(sess);
    getUsersManagerBl().checkUserExists(sess, user);
    if (user.isServiceUser())
        throw new NotSpecificUserExpectedException(user);
    List<Vo> vos = getUsersManagerBl().getVosWhereUserIsMember(sess, user);
    for (Vo vo : vos) {
        if (!AuthzResolver.authorizedInternal(sess, "getSpecificUsersByUser_User_policy", Arrays.asList(user, vo))) {
            throw new PrivilegeException(sess, "getSpecificUsersByUser");
        }
    }
    return getUsersManagerBl().getSpecificUsersByUser(sess, user);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) Vo(cz.metacentrum.perun.core.api.Vo) NotSpecificUserExpectedException(cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException)

Aggregations

NotSpecificUserExpectedException (cz.metacentrum.perun.core.api.exceptions.NotSpecificUserExpectedException)3 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)3 SpecificUserExpectedException (cz.metacentrum.perun.core.api.exceptions.SpecificUserExpectedException)2 Vo (cz.metacentrum.perun.core.api.Vo)1