Search in sources :

Example 1 with ExternallyManagedException

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

the class GroupsManagerEntry method addMember.

@Override
public void addMember(PerunSession sess, Group group, Member member) throws MemberNotExistsException, PrivilegeException, AlreadyMemberException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException {
    Utils.checkPerunSession(sess);
    getGroupsManagerBl().checkGroupExists(sess, group);
    getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
    // Check if the member and group are from the same VO
    if (member.getVoId() != (group.getVoId())) {
        throw new MembershipMismatchException("Member and group are form the different VO");
    }
    // Authorization
    if (!AuthzResolver.authorizedInternal(sess, "addMember_Group_Member_policy", Arrays.asList(group, member))) {
        throw new PrivilegeException(sess, "addMember");
    }
    // Check if the group is externally synchronized
    Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
    if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) {
        throw new ExternallyManagedException("Adding of member is not allowed. Group is externally managed.");
    }
    getGroupsManagerBl().addMember(sess, group, member);
}
Also used : MembershipMismatchException(cz.metacentrum.perun.core.api.exceptions.MembershipMismatchException) ExternallyManagedException(cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 2 with ExternallyManagedException

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

the class GroupsManagerEntry method addMembers.

@Override
public void addMembers(PerunSession sess, Group group, List<Member> members) throws MemberNotExistsException, PrivilegeException, AlreadyMemberException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException {
    Utils.checkPerunSession(sess);
    getGroupsManagerBl().checkGroupExists(sess, group);
    for (Member member : members) {
        getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
        // Check if the member and group are from the same VO
        if (member.getVoId() != (group.getVoId())) {
            throw new MembershipMismatchException("Member and group are form the different VO");
        }
    }
    // Authorization
    for (Member member : members) {
        if (!AuthzResolver.authorizedInternal(sess, "addMembers_Group_List<Member>_policy", member, group)) {
            throw new PrivilegeException(sess, "addMembers");
        }
    }
    // Check if the group is externally synchronized
    Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
    if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) {
        throw new ExternallyManagedException("Adding of member is not allowed. Group is externally managed.");
    }
    getGroupsManagerBl().addMembers(sess, group, members);
}
Also used : MembershipMismatchException(cz.metacentrum.perun.core.api.exceptions.MembershipMismatchException) ExternallyManagedException(cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Example 3 with ExternallyManagedException

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

the class GroupsManagerEntry method removeMember.

@Override
public void removeMember(PerunSession sess, Group group, Member member) throws MemberNotExistsException, NotGroupMemberException, PrivilegeException, GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException {
    Utils.checkPerunSession(sess);
    getGroupsManagerBl().checkGroupExists(sess, group);
    getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
    // Authorization
    if (!AuthzResolver.authorizedInternal(sess, "removeMember_Group_Member_policy", Arrays.asList(group, member))) {
        throw new PrivilegeException(sess, "removeMember");
    }
    // Check if the group is externally synchronized
    Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
    if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) {
        throw new ExternallyManagedException("Removing of member is not allowed. Group is externally managed.");
    }
    getGroupsManagerBl().removeMember(sess, group, member);
}
Also used : ExternallyManagedException(cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Example 4 with ExternallyManagedException

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

the class GroupsManagerEntry method removeMembers.

@Override
public void removeMembers(PerunSession sess, Group group, List<Member> members) throws MemberNotExistsException, NotGroupMemberException, PrivilegeException, GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException {
    Utils.checkPerunSession(sess);
    getGroupsManagerBl().checkGroupExists(sess, group);
    for (Member member : members) {
        getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
    }
    // Authorization
    for (Member member : members) {
        if (!AuthzResolver.authorizedInternal(sess, "removeMembers_Group_List<Member>_policy", member, group)) {
            throw new PrivilegeException(sess, "removeMembers");
        }
    }
    // Check if the group is externally synchronized
    Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
    if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) {
        throw new ExternallyManagedException("Removing of member is not allowed. Group is externally managed.");
    }
    getGroupsManagerBl().removeMembers(sess, group, members);
}
Also used : ExternallyManagedException(cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Example 5 with ExternallyManagedException

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

the class GroupsManagerEntry method removeMember.

@Override
public void removeMember(PerunSession sess, Member member, List<Group> groups) throws MemberNotExistsException, NotGroupMemberException, PrivilegeException, GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException {
    Utils.checkPerunSession(sess);
    for (Group group : groups) {
        getGroupsManagerBl().checkGroupExists(sess, group);
        // Check if the group is externally synchronized
        Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
        if ("true".equals(attrSynchronizeEnabled.getValue()) || getGroupsManagerBl().isGroupInStructureSynchronizationTree(sess, group)) {
            throw new ExternallyManagedException("Removing of member is not allowed. Group is externally managed.");
        }
    }
    getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
    // Authorization
    for (Group group : groups) {
        if (!AuthzResolver.authorizedInternal(sess, "removeMember_Member_List<Group>_policy", member, group)) {
            throw new PrivilegeException(sess, "removeMember");
        }
    }
    getGroupsManagerBl().removeMember(sess, groups, member);
}
Also used : ExternallyManagedException(cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException) Group(cz.metacentrum.perun.core.api.Group) RichGroup(cz.metacentrum.perun.core.api.RichGroup) Attribute(cz.metacentrum.perun.core.api.Attribute) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException)

Aggregations

ExternallyManagedException (cz.metacentrum.perun.core.api.exceptions.ExternallyManagedException)8 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)8 Attribute (cz.metacentrum.perun.core.api.Attribute)6 Group (cz.metacentrum.perun.core.api.Group)4 RichGroup (cz.metacentrum.perun.core.api.RichGroup)4 MembershipMismatchException (cz.metacentrum.perun.core.api.exceptions.MembershipMismatchException)3 Member (cz.metacentrum.perun.core.api.Member)2 RichMember (cz.metacentrum.perun.core.api.RichMember)2 ArrayList (java.util.ArrayList)1