use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceTest method makeWsDeleteMemberResultsTest.
@Test
public void makeWsDeleteMemberResultsTest() {
WsDeleteMemberResults results;
List<String> members = new ArrayList<>();
members.add(users.get(5).getUsername());
WsSubjectLookup lookup = gfsl.makeWsSubjectLookup(users.get(5).getUsername());
results = gfsl.makeWsDeleteMemberResults(GROUPING_3_PATH, lookup, members);
assertTrue(results.getResultMetadata().getResultCode().startsWith("SUCCESS"));
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsDeleteMemberResults.
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, List<String> membersToDelete) {
WsDeleteMemberResults wsDeleteMemberResults = new WsDeleteMemberResults();
WsResultMeta wsResultMeta = new WsResultMeta();
wsResultMeta.setResultCode(SUCCESS);
for (String username : membersToDelete) {
WsResultMeta wsResultMetaData = makeWsDeleteMemberResults(group, lookup, username).getResultMetadata();
if (wsResultMetaData.getResultCode().equals(FAILURE)) {
wsResultMeta = wsResultMetaData;
}
}
wsDeleteMemberResults.setResultMetadata(wsResultMeta);
return wsDeleteMemberResults;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceImpl method addMemberHelper.
// logic for adding a member
public List<GroupingsServiceResult> addMemberHelper(String username, String groupPath, Person personToAdd) {
logger.info("addMemberHelper; user: " + username + "; group: " + groupPath + "; personToAdd: " + personToAdd + ";");
List<GroupingsServiceResult> gsrList = new ArrayList<>();
String action = "add users to " + groupPath;
if (mas.isOwner(hs.parentGroupingPath(groupPath), username) || mas.isSuperuser(username) || personToAdd.getUsername().equals(username)) {
WsSubjectLookup user = grouperFS.makeWsSubjectLookup(username);
String composite = hs.parentGroupingPath(groupPath);
String exclude = composite + EXCLUDE;
String include = composite + INCLUDE;
String owners = composite + OWNERS;
boolean updateComposite = false;
boolean updateExclude = false;
boolean updateInclude = false;
boolean updateOwners = false;
// check to see if it is the include, exclude or owners
if (groupPath.endsWith(INCLUDE)) {
// if personToAdd is in exclude, get them out
if (mas.isMember(exclude, personToAdd)) {
WsDeleteMemberResults wsDeleteMemberResults = grouperFS.makeWsDeleteMemberResults(exclude, user, personToAdd);
updateExclude = true;
gsrList.add(hs.makeGroupingsServiceResult(wsDeleteMemberResults, "delete " + personToAdd.toString() + " from " + exclude));
}
// check to see if personToAdd is already in include
if (!mas.isMember(include, personToAdd)) {
// add to include
WsAddMemberResults addMemberResults = grouperFS.makeWsAddMemberResults(include, user, personToAdd);
updateInclude = true;
gsrList.add(hs.makeGroupingsServiceResult(addMemberResults, action));
} else {
// They are already in the group, so just return SUCCESS
gsrList.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + personToAdd.toString() + " was already in " + groupPath, action));
}
} else // if exclude check if personToAdd is in the include
if (groupPath.endsWith(EXCLUDE)) {
// if personToAdd is in include, get them out
if (mas.isMember(include, personToAdd)) {
WsDeleteMemberResults wsDeleteMemberResults = grouperFS.makeWsDeleteMemberResults(include, user, personToAdd);
updateInclude = true;
gsrList.add(hs.makeGroupingsServiceResult(wsDeleteMemberResults, "delete " + personToAdd.toString() + " from " + include));
}
// check to see if userToAdd is already in exclude
if (!mas.isMember(exclude, personToAdd)) {
// add to exclude
WsAddMemberResults addMemberResults = grouperFS.makeWsAddMemberResults(exclude, user, personToAdd);
updateExclude = true;
gsrList.add(hs.makeGroupingsServiceResult(addMemberResults, action));
}
// They are already in the group, so just return SUCCESS
gsrList.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + personToAdd.toString() + " was already in " + groupPath, action));
} else // if owners check to see if the user is already in owners
if (groupPath.endsWith(OWNERS)) {
// check to see if userToAdd is already in owners
if (!mas.isMember(owners, personToAdd)) {
// add userToAdd to owners
WsAddMemberResults addMemberResults = grouperFS.makeWsAddMemberResults(owners, user, personToAdd);
updateOwners = true;
gsrList.add(hs.makeGroupingsServiceResult(addMemberResults, action));
}
// They are already in the group, so just return SUCCESS
gsrList.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + personToAdd.toString() + " was already in " + groupPath, action));
} else // Owners can only change include, exclude and owners groups
{
gsrList.add(hs.makeGroupingsServiceResult(FAILURE + ": " + username + " may only add to exclude, include or owner group", action));
}
// update groups that were changed
if (updateExclude) {
updateLastModified(exclude);
updateComposite = true;
}
if (updateInclude) {
updateLastModified(include);
updateComposite = true;
}
if (updateComposite) {
updateLastModified(composite);
}
if (updateOwners) {
updateLastModified(owners);
}
} else {
gsrList.add(hs.makeGroupingsServiceResult(FAILURE + ": " + username + "does not have permission to edit " + groupPath, action));
}
return gsrList;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults 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);
}
Aggregations