Search in sources :

Example 31 with Person

use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.

the class MembershipServiceImpl method addGroupingMemberByUuid.

// find a user by a uuid and add them to a grouping
@Override
public List<GroupingsServiceResult> addGroupingMemberByUuid(String username, String groupingPath, String userToAddUuid) {
    logger.info("addGroupingMemberByUuid; user: " + username + "; grouping: " + groupingPath + "; userToAdd: " + userToAddUuid + ";");
    List<GroupingsServiceResult> gsrs = new ArrayList<>();
    String action = "add user to " + groupingPath;
    String basis = groupingPath + BASIS;
    String exclude = groupingPath + EXCLUDE;
    String include = groupingPath + INCLUDE;
    Person personToAdd = new Person(null, userToAddUuid, null);
    boolean inBasis = mas.isMember(basis, personToAdd);
    boolean inComposite = mas.isMember(groupingPath, personToAdd);
    boolean inInclude = mas.isMember(include, personToAdd);
    // check to see if they are already in the grouping
    if (!inComposite) {
        // get them out of the exclude
        gsrs.add(deleteGroupMemberByUuid(username, exclude, userToAddUuid));
        // only add them to the include if they are not in the basis
        if (!inBasis) {
            gsrs.addAll(addGroupMemberByUuid(username, include, userToAddUuid));
        } else {
            gsrs.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + userToAddUuid + " was in " + basis, action));
        }
    } else {
        gsrs.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + userToAddUuid + " was already in " + groupingPath, action));
    }
    // should only be in one or the other
    if (inBasis && inInclude) {
        gsrs.add(deleteGroupMemberByUuid(username, include, userToAddUuid));
    }
    return gsrs;
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Person(edu.hawaii.its.api.type.Person)

Example 32 with Person

use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.

the class MembershipServiceImpl method deleteGroupMemberByUuid.

@Override
public GroupingsServiceResult deleteGroupMemberByUuid(String ownerUsername, String groupPath, String userToDeleteUuid) {
    logger.info("deleteGroupMemberByUuid; user: " + ownerUsername + "; group: " + groupPath + "; userToDelete: " + userToDeleteUuid + ";");
    String action = "delete " + userToDeleteUuid + " from " + groupPath;
    Person personToDelete = new Person(null, userToDeleteUuid, null);
    String composite = hs.parentGroupingPath(groupPath);
    if (mas.isOwner(composite, ownerUsername) || mas.isSuperuser(ownerUsername)) {
        WsSubjectLookup user = grouperFS.makeWsSubjectLookup(ownerUsername);
        if (groupPath.endsWith(EXCLUDE) || groupPath.endsWith(INCLUDE) || groupPath.endsWith(OWNERS)) {
            if (mas.isMember(groupPath, personToDelete)) {
                WsDeleteMemberResults deleteMemberResults = grouperFS.makeWsDeleteMemberResults(groupPath, user, personToDelete);
                updateLastModified(composite);
                updateLastModified(groupPath);
                return hs.makeGroupingsServiceResult(deleteMemberResults, action);
            }
            return hs.makeGroupingsServiceResult(SUCCESS + ": " + ownerUsername + " was not in " + groupPath, action);
        }
        return hs.makeGroupingsServiceResult(FAILURE + ": " + ownerUsername + " may only delete from exclude, include or owner group", action);
    }
    return hs.makeGroupingsServiceResult(FAILURE + ": " + ownerUsername + " does not have permission to edit " + groupPath, action);
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) Person(edu.hawaii.its.api.type.Person) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Aggregations

Person (edu.hawaii.its.api.type.Person)32 Group (edu.hawaii.its.api.type.Group)20 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)9 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)8 Before (org.junit.Before)8 Grouping (edu.hawaii.its.api.type.Grouping)7 ArrayList (java.util.ArrayList)7 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)6 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Membership (edu.hawaii.its.api.type.Membership)5 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)3 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)3 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)2 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)1 WsAssignGrouperPrivilegesLiteResult (edu.internet2.middleware.grouperClient.ws.beans.WsAssignGrouperPrivilegesLiteResult)1 WsDeleteMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)1 WsGetGrouperPrivilegesLiteResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGrouperPrivilegesLiteResult)1