Search in sources :

Example 26 with Person

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

the class GrouperFactoryServiceImplLocal method makeWsAssignGrouperPrivilegesLiteResult.

@Override
public WsAssignGrouperPrivilegesLiteResult makeWsAssignGrouperPrivilegesLiteResult(String groupName, String privilegeName, WsSubjectLookup lookup, boolean allowed) {
    WsAssignGrouperPrivilegesLiteResult wsAssignGrouperPrivilegsLiteResult = new WsAssignGrouperPrivilegesLiteResult();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    Person person = personRepository.findByUsername(lookup.getSubjectIdentifier());
    Group group = groupRepository.findByPath(groupName);
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    if (privilegeName.equals(PRIVILEGE_OPT_IN)) {
        membership.setOptInEnabled(allowed);
    } else if (privilegeName.equals(PRIVILEGE_OPT_OUT)) {
        membership.setOptOutEnabled(allowed);
    } else {
        throw new IllegalArgumentException("Privilege Name not acceptable");
    }
    wsAssignGrouperPrivilegsLiteResult.setResultMetadata(wsResultMeta);
    return wsAssignGrouperPrivilegsLiteResult;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsAssignGrouperPrivilegesLiteResult(edu.internet2.middleware.grouperClient.ws.beans.WsAssignGrouperPrivilegesLiteResult) Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

Example 27 with Person

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

the class GrouperFactoryServiceImplLocal method makeWsGetMembershipsResults.

@Override
public WsGetMembershipsResults makeWsGetMembershipsResults(String groupName, WsSubjectLookup lookup) {
    Person person = personRepository.findByUsername(lookup.getSubjectIdentifier());
    Group group = groupRepository.findByPath(groupName);
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    WsGetMembershipsResults wsGetMembershipsResults = new WsGetMembershipsResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(FAILURE);
    WsMembership[] wsMemberships = new WsMembership[1];
    WsMembership wsMembership = new WsMembership();
    if (membership != null) {
        wsMembership.setMembershipId(membership.getId());
        wsResultMeta.setResultCode(SUCCESS);
    }
    wsMemberships[0] = wsMembership;
    wsGetMembershipsResults.setWsMemberships(wsMemberships);
    return wsGetMembershipsResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetMembershipsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

Example 28 with Person

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

the class GrouperFactoryServiceImplLocal method makeWsGetGrouperPrivilegesLiteResult.

@Override
public WsGetGrouperPrivilegesLiteResult makeWsGetGrouperPrivilegesLiteResult(String groupName, String privilegeName, WsSubjectLookup lookup) {
    WsGetGrouperPrivilegesLiteResult wsGetGrouperPrivilegesLiteResult = new WsGetGrouperPrivilegesLiteResult();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(FAILURE);
    Person person = personRepository.findByUsername(EVERY_ENTITY);
    Group group = groupRepository.findByPath(groupName);
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    boolean enabled = false;
    if (privilegeName.equals(PRIVILEGE_OPT_IN)) {
        if (membership.isOptInEnabled()) {
            enabled = true;
        }
    } else if (privilegeName.equals(PRIVILEGE_OPT_OUT)) {
        if (membership.isOptOutEnabled()) {
            enabled = true;
        }
    } else {
        throw new IllegalArgumentException("Privilege Name not acceptable");
    }
    if (enabled) {
        wsResultMeta.setResultCode(SUCCESS_ALLOWED);
    }
    wsGetGrouperPrivilegesLiteResult.setResultMetadata(wsResultMeta);
    return wsGetGrouperPrivilegesLiteResult;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetGrouperPrivilegesLiteResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGrouperPrivilegesLiteResult) Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Person(edu.hawaii.its.api.type.Person)

Example 29 with Person

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

the class GrouperFactoryServiceImplLocal method makeWsGetMembersResults.

@Override
public WsGetMembersResults makeWsGetMembersResults(String subjectAttributeName, WsSubjectLookup lookup, String groupName) {
    WsGetMembersResults wsGetMembersResults = new WsGetMembersResults();
    String[] attributeNames = new String[] { UID_KEY, UUID_KEY, LAST_NAME_KEY, COMPOSITE_NAME_KEY, FIRST_NAME_KEY };
    wsGetMembersResults.setSubjectAttributeNames(attributeNames);
    WsGetMembersResult wsGetMembersResult = new WsGetMembersResult();
    WsSubject[] subjects;
    Group group = groupRepository.findByPath(groupName);
    List<Person> members = group.getMembers();
    List<WsSubject> subjectList = new ArrayList<>();
    for (Person person : members) {
        WsSubject subject = new WsSubject();
        subject.setId(person.getUuid());
        subject.setName(person.getName());
        // has to be the same order as attributeNames array
        subject.setAttributeValues(new String[] { person.getUsername(), person.getUuid(), person.getLastName(), person.getName(), person.getFirstName() });
        subjectList.add(subject);
    }
    subjects = subjectList.toArray(new WsSubject[subjectList.size()]);
    wsGetMembersResult.setWsSubjects(subjects);
    wsGetMembersResults.setResults(new WsGetMembersResult[] { wsGetMembersResult });
    return wsGetMembersResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetMembersResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult) ArrayList(java.util.ArrayList) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Person(edu.hawaii.its.api.type.Person)

Example 30 with Person

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

the class MembershipServiceImpl method addGroupMemberByUuid.

// finds a user by a uuid and adds them to the group
@Override
public List<GroupingsServiceResult> addGroupMemberByUuid(String ownerUsername, String groupPath, String userToAddUuid) {
    logger.info("addGroupMemberByUuid; user: " + ownerUsername + "; groupPath: " + groupPath + "; userToAdd: " + userToAddUuid + ";");
    Person personToAdd = new Person(null, userToAddUuid, null);
    return addMemberHelper(ownerUsername, groupPath, personToAdd);
}
Also used : 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