use of edu.hawaii.its.api.type.Membership 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;
}
use of edu.hawaii.its.api.type.Membership in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method deleteMember.
private void deleteMember(Group group, Person person) {
Membership membership = membershipRepository.findByPersonAndGroup(person, group);
if (membership != null) {
group.getMembers().remove(person);
groupRepository.save(group);
membershipRepository.delete(membership);
}
}
use of edu.hawaii.its.api.type.Membership 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.hawaii.its.api.type.Membership in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsGetAttributeAssignmentsResultsForMembership.
@Override
public WsGetAttributeAssignmentsResults makeWsGetAttributeAssignmentsResultsForMembership(String assignType, String attributeDefNameName, String membershipId) {
Membership membership = membershipRepository.findById(membershipId);
WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults = new WsGetAttributeAssignmentsResults();
WsResultMeta wsResultMeta = new WsResultMeta();
wsResultMeta.setResultCode(SUCCESS);
WsAttributeAssign[] wsAttributeAssigns = new WsAttributeAssign[1];
WsAttributeAssign wsAttributeAssign = new WsAttributeAssign();
if (membership.isSelfOpted()) {
wsAttributeAssign.setAttributeDefNameName(SELF_OPTED);
}
wsAttributeAssigns[0] = wsAttributeAssign;
wsGetAttributeAssignmentsResults.setResultMetadata(wsResultMeta);
wsGetAttributeAssignmentsResults.setWsAttributeAssigns(wsAttributeAssigns);
return wsGetAttributeAssignmentsResults;
}
use of edu.hawaii.its.api.type.Membership 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;
}
Aggregations