Search in sources :

Example 1 with WsStemLookup

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

the class GrouperFactoryServiceImplLocal method makeWsGetGroupsResults.

@Override
public WsGetGroupsResults makeWsGetGroupsResults(String username, WsStemLookup stemLookup, StemScope stemScope) {
    WsGetGroupsResults wsGetGroupsResults = new WsGetGroupsResults();
    WsGetGroupsResult wsGetGroupsResult = new WsGetGroupsResult();
    WsGroup[] groups;
    List<WsGroup> wsGroupList = new ArrayList<>();
    List<Group> groupList = groupRepository.findByMembersUsername(username);
    for (Group group : groupList) {
        WsGroup g = new WsGroup();
        g.setName(group.getPath());
        wsGroupList.add(g);
    }
    groups = wsGroupList.toArray(new WsGroup[wsGroupList.size()]);
    wsGetGroupsResult.setWsGroups(groups);
    wsGetGroupsResults.setResults(new WsGetGroupsResult[] { wsGetGroupsResult });
    return wsGetGroupsResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 2 with WsStemLookup

use of edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup in project uPortal by Jasig.

the class GrouperEntityGroupStore method findParentGroups.

/* (non-Javadoc)
     * @see org.apereo.portal.groups.IEntityGroupStore#findParentGroups(org.apereo.portal.groups.IGroupMember)
     */
@SuppressWarnings("unchecked")
public Iterator findParentGroups(IGroupMember gm) throws GroupsException {
    final List<IEntityGroup> parents = new LinkedList<IEntityGroup>();
    GcGetGroups getGroups = new GcGetGroups();
    String uportalStem = getStemPrefix();
    // if only searching in a specific stem
    if (!StringUtils.isBlank(uportalStem)) {
        getGroups.assignStemScope(StemScope.ALL_IN_SUBTREE);
        getGroups.assignWsStemLookup(new WsStemLookup(uportalStem, null));
    }
    String key = null;
    String subjectSourceId = null;
    if (gm.isGroup()) {
        key = ((IEntityGroup) gm).getLocalKey();
        if (!validKey(key)) {
            return parents.iterator();
        }
        subjectSourceId = "g:gsa";
    } else {
        // Determine the key to use for this entity. If the entity is a
        // group, we should use the group's local key (excluding the
        // "grouper." portion of the full key. If the entity is not a
        // group type, just use the key.
        key = gm.getKey();
    }
    getGroups.addSubjectLookup(new WsSubjectLookup(null, subjectSourceId, key));
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Searching Grouper for parent groups of the entity with key: " + key);
    }
    try {
        WsGetGroupsResults results = getGroups.execute();
        if (results == null || results.getResults() == null || results.getResults().length != 1) {
            LOGGER.debug("Grouper service returned no matches for key " + key);
            return parents.iterator();
        }
        WsGetGroupsResult wsg = results.getResults()[0];
        if (wsg.getWsGroups() != null) {
            for (WsGroup g : wsg.getWsGroups()) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.trace("Retrieved group: " + g.getName());
                }
                IEntityGroup parent = createUportalGroupFromGrouperGroup(g);
                parents.add(parent);
            }
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Retrieved " + parents.size() + " parent groups of entity with key " + key);
        }
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "parents for entity with key " + key + " from Grouper web services: " + e.getMessage());
        return Collections.<IEntityGroup>emptyList().iterator();
    }
    return parents.iterator();
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) GcGetGroups(edu.internet2.middleware.grouperClient.api.GcGetGroups) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) LinkedList(java.util.LinkedList) GroupsException(org.apereo.portal.groups.GroupsException)

Example 3 with WsStemLookup

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

the class GrouperFactoryServiceImpl method makeWsStemSaveResults.

@Override
public WsStemSaveResults makeWsStemSaveResults(String username, String stemPath) {
    String[] splitString = stemPath.split(":");
    String splitStringName = splitString[splitString.length - 1];
    WsStemToSave stemToSave = new WsStemToSave();
    WsStemLookup stemLookup = new WsStemLookup();
    stemLookup.setStemName(stemPath);
    WsStem stem = new WsStem();
    stem.setName(stemPath);
    stem.setExtension(splitStringName);
    stem.setDescription(splitStringName);
    stem.setDisplayExtension(splitStringName);
    stemToSave.setWsStem(stem);
    stemToSave.setWsStemLookup(stemLookup);
    WsSubjectLookup subject = makeWsSubjectLookup(username);
    return new GcStemSave().addStemToSave(stemToSave).assignActAsSubject(subject).execute();
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsStem(edu.internet2.middleware.grouperClient.ws.beans.WsStem) WsStemToSave(edu.internet2.middleware.grouperClient.ws.beans.WsStemToSave) GcStemSave(edu.internet2.middleware.grouperClient.api.GcStemSave)

Example 4 with WsStemLookup

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

the class GroupingAssignmentServiceImpl method getGroupPaths.

// returns the list of groups that the user is in
@Override
public List<String> getGroupPaths(String username) {
    logger.info("getGroupPaths; username: " + username + ";");
    WsStemLookup stemLookup = grouperFS.makeWsStemLookup(STEM);
    WsGetGroupsResults wsGetGroupsResults = grouperFS.makeWsGetGroupsResults(username, stemLookup, StemScope.ALL_IN_SUBTREE);
    WsGetGroupsResult groupResults = wsGetGroupsResults.getResults()[0];
    List<WsGroup> groups = new ArrayList<>();
    if (groupResults.getWsGroups() != null) {
        groups = new ArrayList<>(Arrays.asList(groupResults.getWsGroups()));
    }
    return extractGroupPaths(groups);
}
Also used : WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 5 with WsStemLookup

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

the class GroupingFactoryServiceImpl method addGrouping.

@Override
public // todo change basis to a String
List<GroupingsServiceResult> addGrouping(String adminUsername, String groupingPath, List<String> basis, List<String> include, List<String> exclude, List<String> owners) {
    List<GroupingsServiceResult> addGroupingResults = new ArrayList<>();
    String action = adminUsername + " is adding a Grouping: " + groupingPath;
    // make sure that adminUsername is actually an admin
    if (!memberAttributeService.isAdmin(adminUsername)) {
        GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(FAILURE + ": " + adminUsername + " does not have permission to add this grouping", action);
        addGroupingResults.add(gsr);
        return addGroupingResults;
    }
    // make sure that there is not already a group there
    if (!pathIsEmpty(adminUsername, groupingPath)) {
        GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(FAILURE + ": a group already exists at " + groupingPath, action);
        addGroupingResults.add(gsr);
        return addGroupingResults;
    }
    Map<String, List<String>> memberLists = new HashMap<>();
    memberLists.put("", new ArrayList<>());
    memberLists.put(BASIS_PLUS_INCLUDE, new ArrayList<>());
    memberLists.put(BASIS, new ArrayList<>());
    memberLists.put(INCLUDE, include);
    memberLists.put(EXCLUDE, exclude);
    memberLists.put(OWNERS, owners);
    // a stem the same as a folder
    // create main stem
    grouperFactoryService.makeWsStemSaveResults(adminUsername, groupingPath);
    // create basis stem
    grouperFactoryService.makeWsStemSaveResults(adminUsername, groupingPath + BASIS);
    for (Map.Entry<String, List<String>> entry : memberLists.entrySet()) {
        String groupPath = groupingPath + entry.getKey();
        // make the groups in grouper
        addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.addEmptyGroup(adminUsername, groupPath), action));
        // add members to the groups
        addGroupingResults.addAll(membershipService.addGroupMembersByUsername(adminUsername, groupPath, entry.getValue()));
        if (groupingPath.equals(groupPath)) {
        // todo create is-trio attribute
        }
        // todo this needs to be created not updated
        // update the last modified values of those groups
        addGroupingResults.add(membershipService.updateLastModified(groupPath));
    }
    WsSubjectLookup lookup = grouperFactoryService.makeWsSubjectLookup(adminUsername);
    WsStemLookup stemLookup = grouperFactoryService.makeWsStemLookup(STEM);
    String basisUid = getGroupId(groupingPath + BASIS);
    String includeUid = getGroupId(groupingPath + INCLUDE);
    String excludeUid = getGroupId(groupingPath + EXCLUDE);
    String basisPlusIncludeUid = getGroupId(groupingPath + BASIS_PLUS_INCLUDE);
    // add memberships for BASIS_PLUS_INCLUDE (basis group and include group)
    addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath + BASIS_PLUS_INCLUDE, lookup, basisUid), "add " + groupingPath + BASIS + " to " + groupingPath + BASIS_PLUS_INCLUDE));
    addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath + BASIS_PLUS_INCLUDE, lookup, includeUid), "add " + groupingPath + INCLUDE + " to " + groupingPath + BASIS_PLUS_INCLUDE));
    // add members for the composite (basisPlusInclude group complement exclude group)
    addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath, lookup, basisPlusIncludeUid), "add " + groupingPath + BASIS_PLUS_INCLUDE + " to " + groupingPath));
    // todo do a complement
    // add the isTrio attribute to the grouping
    grouperFactoryService.makeWsAssignAttributesResultsForGroup(lookup, ASSIGN_TYPE_GROUP, OPERATION_ASSIGN_ATTRIBUTE, TRIO, groupingPath);
    return addGroupingResults;
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) HashMap(java.util.HashMap) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)4 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)3 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)3 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)3 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)3 ArrayList (java.util.ArrayList)3 Group (edu.hawaii.its.api.type.Group)1 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)1 GcGetGroups (edu.internet2.middleware.grouperClient.api.GcGetGroups)1 GcStemSave (edu.internet2.middleware.grouperClient.api.GcStemSave)1 WsStem (edu.internet2.middleware.grouperClient.ws.beans.WsStem)1 WsStemToSave (edu.internet2.middleware.grouperClient.ws.beans.WsStemToSave)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 GroupsException (org.apereo.portal.groups.GroupsException)1 IEntityGroup (org.apereo.portal.groups.IEntityGroup)1