Search in sources :

Example 1 with SpecificUserExpectedException

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

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

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);
}
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) Vo(cz.metacentrum.perun.core.api.Vo)

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)3 Vo (cz.metacentrum.perun.core.api.Vo)1