Search in sources :

Example 1 with WsDeleteMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class MemberAttributeServiceImpl method removeOwnership.

// remove ownership of a grouping from a current owner
// todo change ownerUsername to "actor"?
@Override
public GroupingsServiceResult removeOwnership(String groupingPath, String ownerUsername, String ownerToRemove) {
    logger.info("removeOwnership; grouping: " + groupingPath + "; username: " + ownerUsername + "; ownerToRemove: " + ownerToRemove + ";");
    GroupingsServiceResult ownershipResults;
    String action = "remove ownership of " + groupingPath + " from " + ownerToRemove;
    if (isOwner(groupingPath, ownerUsername) || isAdmin(ownerUsername)) {
        WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(ownerUsername);
        WsDeleteMemberResults memberResults = grouperFS.makeWsDeleteMemberResults(groupingPath + OWNERS, lookup, ownerToRemove);
        ownershipResults = hs.makeGroupingsServiceResult(memberResults, action);
        return ownershipResults;
    }
    ownershipResults = hs.makeGroupingsServiceResult(FAILURE + ", " + ownerUsername + " does not own " + groupingPath, action);
    return ownershipResults;
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 2 with WsDeleteMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class MembershipServiceImpl method deleteGroupMemberByUsername.

// find a user by a username and remove them from a group
@Override
public GroupingsServiceResult deleteGroupMemberByUsername(String ownerUsername, String groupPath, String userToDeleteUsername) {
    logger.info("deleteGroupMemberByUsername; user: " + ownerUsername + "; group: " + groupPath + "; userToDelete: " + userToDeleteUsername + ";");
    String action = "delete " + userToDeleteUsername + " from " + groupPath;
    String composite = hs.parentGroupingPath(groupPath);
    if (mas.isOwner(composite, ownerUsername) || mas.isSuperuser(ownerUsername) || userToDeleteUsername.equals(ownerUsername)) {
        WsSubjectLookup user = grouperFS.makeWsSubjectLookup(ownerUsername);
        if (groupPath.endsWith(EXCLUDE) || groupPath.endsWith(INCLUDE) || groupPath.endsWith(OWNERS)) {
            if (mas.isMember(groupPath, userToDeleteUsername)) {
                WsDeleteMemberResults deleteMemberResults = grouperFS.makeWsDeleteMemberResults(groupPath, user, userToDeleteUsername);
                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);
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 3 with WsDeleteMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class MembershipServiceImpl method deleteAdmin.

// removes a user from the admins group
@Override
public GroupingsServiceResult deleteAdmin(String adminUsername, String adminToDeleteUsername) {
    logger.info("deleteAdmin; username: " + adminUsername + "; adminToDelete: " + adminToDeleteUsername + ";");
    String action = "delete " + adminToDeleteUsername + " from " + GROUPING_ADMINS;
    if (mas.isSuperuser(adminUsername)) {
        WsSubjectLookup user = grouperFS.makeWsSubjectLookup(adminUsername);
        WsDeleteMemberResults deleteMemberResults = grouperFS.makeWsDeleteMemberResults(GROUPING_ADMINS, user, adminToDeleteUsername);
        return hs.makeGroupingsServiceResult(deleteMemberResults, action);
    }
    // todo replace hard coded string with value from top
    return hs.makeGroupingsServiceResult("FAILURE: " + adminUsername + " is not an admin", action);
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 4 with WsDeleteMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsDeleteMemberResults.

@Override
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, Person personToDelete) {
    WsDeleteMemberResults wsDeleteMemberResults = new WsDeleteMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsDeleteMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToDelete.getUsername() != null) {
        personToDelete = personRepository.findByUsername(personToDelete.getUsername());
    } else if (personToDelete.getUuid() != null) {
        personToDelete = personRepository.findByUuid(personToDelete.getUuid());
    }
    if (grouping == null) {
        Group groupToDeleteFrom = groupRepository.findByPath(group);
        deleteMember(groupToDeleteFrom, personToDelete);
    } else {
        if (group.endsWith(OWNERS)) {
            deleteMember(grouping.getOwners(), personToDelete);
        } else if (group.endsWith(EXCLUDE)) {
            deleteMember(grouping.getExclude(), personToDelete);
        } else if (group.endsWith(INCLUDE)) {
            deleteMember(grouping.getInclude(), personToDelete);
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsDeleteMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 5 with WsDeleteMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImpl method makeWsDeleteMemberResults.

@Override
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, List<String> membersToDelete) {
    GcDeleteMember deleteMember = new GcDeleteMember();
    deleteMember.assignActAsSubject(lookup);
    deleteMember.assignGroupName(group);
    membersToDelete.forEach(deleteMember::addSubjectIdentifier);
    return deleteMember.execute();
}
Also used : GcDeleteMember(edu.internet2.middleware.grouperClient.api.GcDeleteMember)

Aggregations

WsDeleteMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)8 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)6 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)2 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)2 ArrayList (java.util.ArrayList)2 Group (edu.hawaii.its.api.type.Group)1 Grouping (edu.hawaii.its.api.type.Grouping)1 Person (edu.hawaii.its.api.type.Person)1 GcDeleteMember (edu.internet2.middleware.grouperClient.api.GcDeleteMember)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1