Search in sources :

Example 11 with Person

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

the class MembershipServiceImpl method deleteGroupingMemberByUuid.

// todo
// finds a user by a uuid and remove them from a grouping
@Override
public List<GroupingsServiceResult> deleteGroupingMemberByUuid(String ownerUsername, String groupingPath, String userToDeleteUuid) {
    logger.info("deleteGroupingMemberByUuid; ownerUsername: " + ownerUsername + "; groupingPath: " + groupingPath + "; userToDelete: " + userToDeleteUuid + ";");
    List<GroupingsServiceResult> gsrList = new ArrayList<>();
    String action = ownerUsername + " deletes " + userToDeleteUuid + " from " + groupingPath;
    String basis = groupingPath + BASIS;
    String exclude = groupingPath + EXCLUDE;
    String include = groupingPath + INCLUDE;
    Person personToDelete = new Person(null, userToDeleteUuid, null);
    boolean inBasis = mas.isMember(basis, personToDelete);
    boolean inComposite = mas.isMember(groupingPath, personToDelete);
    boolean inExclude = mas.isMember(exclude, personToDelete);
    // if they are in the include group, get them out
    gsrList.add(deleteGroupMemberByUuid(ownerUsername, include, userToDeleteUuid));
    // make sure userToDelete is actually in the Grouping
    if (inComposite) {
        // if they are not in the include group, then they are in the basis, so add them to the exclude group
        if (inBasis) {
            gsrList.addAll(addGroupMemberByUuid(ownerUsername, exclude, userToDeleteUuid));
        }
    } else // since they are not in the Grouping, do nothing, but return SUCCESS
    {
        gsrList.add(hs.makeGroupingsServiceResult(SUCCESS + userToDeleteUuid + " was not in " + groupingPath, action));
    }
    // should not be in exclude if not in basis
    if (!inBasis && inExclude) {
        gsrList.add(deleteGroupMemberByUuid(ownerUsername, exclude, userToDeleteUuid));
    }
    return gsrList;
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Person(edu.hawaii.its.api.type.Person)

Example 12 with Person

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

the class MembershipServiceImpl method addGroupMemberByUsername.

// finds a user by a username and adds that user to the group
@Override
public List<GroupingsServiceResult> addGroupMemberByUsername(String ownerUsername, String groupPath, String userToAddUsername) {
    logger.info("addGroupMemberByUsername; user: " + ownerUsername + "; groupPath: " + groupPath + "; userToAdd: " + userToAddUsername + ";");
    Person personToAdd = new Person(null, null, userToAddUsername);
    return addMemberHelper(ownerUsername, groupPath, personToAdd);
}
Also used : Person(edu.hawaii.its.api.type.Person)

Example 13 with Person

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

the class GrouperFactoryServiceImplLocal method addIncludedMembers.

private Group addIncludedMembers(Group include, Group basis) {
    Group unionGroup = new Group();
    List<Person> unionList = new ArrayList<>();
    unionList.addAll(include.getMembers());
    unionList.addAll(basis.getMembers());
    // remove duplicates
    Set<Person> s = new TreeSet<>();
    s.addAll(unionList);
    unionGroup.setMembers(Arrays.asList(s.toArray(new Person[s.size()])));
    return unionGroup;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Person(edu.hawaii.its.api.type.Person)

Example 14 with Person

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

the class GrouperFactoryServiceImplLocal method removeExcludedMembers.

private Group removeExcludedMembers(Group basisPlusInclude, Group exclude) {
    Group basisPlusIncludeMinusExcludeGroup = new Group();
    ArrayList<Person> newBasisPlusInclude = new ArrayList<>();
    newBasisPlusInclude.addAll(basisPlusInclude.getMembers());
    newBasisPlusInclude.removeAll(exclude.getMembers());
    basisPlusIncludeMinusExcludeGroup.setMembers(newBasisPlusInclude);
    return basisPlusIncludeMinusExcludeGroup;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) Person(edu.hawaii.its.api.type.Person)

Example 15 with Person

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

the class GrouperFactoryServiceImplLocal method makeWsHasMemberResults.

@Override
public WsHasMemberResults makeWsHasMemberResults(String group, Person person) {
    WsHasMemberResults wsHasMemberResults = new WsHasMemberResults();
    WsHasMemberResult wsHasMemberResult = new WsHasMemberResult();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsHasMemberResult.setResultMetadata(wsResultMeta);
    wsHasMemberResults.setResults(new WsHasMemberResult[] { wsHasMemberResult });
    wsResultMeta.setResultCode("not member");
    Group groupToCheck = groupRepository.findByPath(group);
    // first try username
    if (person.getUsername() != null) {
        person = personRepository.findByUsername(person.getUsername());
        if (groupToCheck.isMember(person)) {
            wsResultMeta.setResultCode(IS_MEMBER);
        }
    // if username is null, try uuid
    } else if (person.getUuid() != null) {
        Person person0 = personRepository.findByUuid(person.getUuid());
        if (groupToCheck.isMember(person0)) {
            wsResultMeta.setResultCode(IS_MEMBER);
        }
    }
    return wsHasMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsHasMemberResult(edu.internet2.middleware.grouperClient.ws.beans.WsHasMemberResult) WsHasMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsHasMemberResults) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

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