use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceTest method extractFirstMembershipID.
@Test
public void extractFirstMembershipID() {
WsGetMembershipsResults mr = new WsGetMembershipsResults();
WsMembership[] memberships = new WsMembership[3];
for (int i = 0; i < 3; i++) {
memberships[i] = new WsMembership();
memberships[i].setMembershipId("membershipID_" + i);
}
mr.setWsMemberships(memberships);
assertEquals("membershipID_0", helperService.extractFirstMembershipID(mr));
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceTest method extractFirstMembershipIDTest.
@Test
public void extractFirstMembershipIDTest() {
WsGetMembershipsResults membershipsResults = null;
String firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "");
membershipsResults = new WsGetMembershipsResults();
firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "");
WsMembership[] memberships = null;
membershipsResults.setWsMemberships(memberships);
firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "");
memberships = new WsMembership[] { null };
membershipsResults.setWsMemberships(memberships);
firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "");
WsMembership membership = new WsMembership();
memberships = new WsMembership[] { membership };
membershipsResults.setWsMemberships(memberships);
firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "");
membership.setMembershipId("1234");
memberships = new WsMembership[] { membership };
membershipsResults.setWsMemberships(memberships);
firstMembershipId = helperService.extractFirstMembershipID(membershipsResults);
assertEquals(firstMembershipId, "1234");
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class MemberAttributeServiceImpl method isSelfOpted.
// return true if the membership between the group and user has the self-opted attribute, false otherwise
@Override
public boolean isSelfOpted(String groupPath, String username) {
logger.info("isSelfOpted; group: " + groupPath + "; username: " + username + ";");
if (isMember(groupPath, username)) {
WsGetMembershipsResults wsGetMembershipsResults = hs.membershipsResults(username, groupPath);
String membershipID = hs.extractFirstMembershipID(wsGetMembershipsResults);
WsAttributeAssign[] wsAttributes = getMembershipAttributes(ASSIGN_TYPE_IMMEDIATE_MEMBERSHIP, SELF_OPTED, membershipID);
for (WsAttributeAssign att : wsAttributes) {
if (att.getAttributeDefNameName() != null) {
if (att.getAttributeDefNameName().equals(SELF_OPTED)) {
return true;
}
}
}
}
return false;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults 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;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceImpl method membershipsResults.
// returns a list of groups that the user belongs to inside of a WsGetMembershipsResults object
@Override
public WsGetMembershipsResults membershipsResults(String username, String group) {
logger.info("membershipResults; username: " + username + "; group: " + group + ";");
WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(username);
return grouperFS.makeWsGetMembershipsResults(group, lookup);
}
Aggregations