Search in sources :

Example 16 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project cas by apereo.

the class GrouperFacadeTests method verifyAttributes.

@Test
public void verifyAttributes() {
    val group = new WsGroup();
    group.setExtension("GroupExtension");
    group.setDisplayName("DisplayNameGroupExtension");
    group.setDisplayExtension("DisplaySampleGroupExtension");
    group.setDescription("Group Desc");
    group.setName("SampleGroup");
    group.setUuid(UUID.randomUUID().toString());
    assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.DISPLAY_EXTENSION, group));
    assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.DISPLAY_NAME, group));
    assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.EXTENSION, group));
    assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.NAME, group));
}
Also used : lombok.val(lombok.val) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Test(org.junit.jupiter.api.Test)

Example 17 with WsGroup

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

the class GrouperEntityGroupStore method find.

/* (non-Javadoc)
     * @see org.apereo.portal.groups.IEntityGroupStore#find(java.lang.String)
     */
@Override
public IEntityGroup find(String key) throws GroupsException {
    try {
        // key
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Searching Grouper for a direct match for key: " + key);
        }
        WsGroup wsGroup = findGroupFromKey(key);
        if (wsGroup == null) {
            return null;
        }
        IEntityGroup group = createUportalGroupFromGrouperGroup(wsGroup);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Retrieved group from the Grouper server matching key " + key + ": " + group.toString());
        }
        // return the group
        return group;
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "group with key " + key + " from Grouper web services: " + e.getMessage());
        return null;
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) GroupsException(org.apereo.portal.groups.GroupsException)

Example 18 with WsGroup

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

the class GrouperEntityGroupStore method findMemberGroups.

@Override
@SuppressWarnings("unchecked")
public Iterator findMemberGroups(IEntityGroup group) throws GroupsException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Searching for group-type members of group with key: " + group.getKey());
    }
    try {
        if (!validKey(group.getLocalKey())) {
            return Collections.<IEntityGroup>emptyList().iterator();
        }
        GcGetMembers gcGetMembers = new GcGetMembers();
        gcGetMembers.addGroupName(group.getLocalKey());
        gcGetMembers.assignIncludeSubjectDetail(true);
        gcGetMembers.addSourceId("g:gsa");
        WsGetMembersResults results = gcGetMembers.execute();
        if (results == null || results.getResults() == null || results.getResults().length == 0 || results.getResults()[0].getWsSubjects() == null) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("No group-type members found for group with key " + group.getKey());
            }
            return Collections.<IEntityGroup>emptyList().iterator();
        }
        final List<IEntityGroup> members = new ArrayList<IEntityGroup>();
        WsSubject[] subjects = results.getResults()[0].getWsSubjects();
        for (WsSubject wsSubject : subjects) {
            if (validKey(wsSubject.getName())) {
                WsGroup wsGroup = findGroupFromKey(wsSubject.getName());
                if (wsGroup != null) {
                    IEntityGroup member = createUportalGroupFromGrouperGroup(wsGroup);
                    members.add(member);
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("found IEntityGroup member: " + member);
                    }
                }
            }
        }
        return members.iterator();
    } catch (Exception e) {
        LOGGER.warn("Exception while attempting to retrieve " + "member groups of group with key " + group.getKey() + " from Grouper web services: " + e.getMessage());
        return Collections.<IGroupMember>emptyList().iterator();
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) GcGetMembers(edu.internet2.middleware.grouperClient.api.GcGetMembers) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) GroupsException(org.apereo.portal.groups.GroupsException)

Example 19 with WsGroup

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

the class GrouperEntityGroupStore method findGroupFromKey.

/**
 * Find the Grouper group matching the specified key.
 *
 * @param key
 * @return the group or null
 */
protected WsGroup findGroupFromKey(String key) {
    WsGroup wsGroup = null;
    if (key != null) {
        GcFindGroups gcFindGroups = new GcFindGroups();
        gcFindGroups.addGroupName(key);
        WsFindGroupsResults results = gcFindGroups.execute();
        // if no results were returned, return null
        if (results != null && results.getGroupResults() != null && results.getGroupResults().length > 0) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("found group from key " + key + ": " + results.getGroupResults()[0]);
            }
            wsGroup = results.getGroupResults()[0];
        }
    }
    return wsGroup;
}
Also used : WsFindGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults) GcFindGroups(edu.internet2.middleware.grouperClient.api.GcFindGroups) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 20 with WsGroup

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

the class GrouperEntityGroupStore method update.

/**
 * @see IEntityGroupStore#update(IEntityGroup)
 */
@Override
public void update(IEntityGroup group) throws GroupsException {
    // assume key is fully qualified group name
    String groupName = group.getLocalKey();
    String description = group.getDescription();
    // the name is the displayExtension
    String displayExtension = group.getName();
    WsGroupToSave wsGroupToSave = new WsGroupToSave();
    wsGroupToSave.setCreateParentStemsIfNotExist("T");
    wsGroupToSave.setWsGroupLookup(new WsGroupLookup(groupName, null));
    WsGroup wsGroup = new WsGroup();
    wsGroup.setName(groupName);
    wsGroup.setDisplayExtension(displayExtension);
    wsGroup.setDescription(description);
    wsGroupToSave.setWsGroup(wsGroup);
    new GcGroupSave().addGroupToSave(wsGroupToSave).execute();
    updateMembers(group);
}
Also used : GcGroupSave(edu.internet2.middleware.grouperClient.api.GcGroupSave) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsGroupToSave(edu.internet2.middleware.grouperClient.ws.beans.WsGroupToSave) WsGroupLookup(edu.internet2.middleware.grouperClient.ws.beans.WsGroupLookup)

Aggregations

WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)20 ArrayList (java.util.ArrayList)9 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)5 GroupsException (org.apereo.portal.groups.GroupsException)5 IEntityGroup (org.apereo.portal.groups.IEntityGroup)5 WsFindGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults)4 Grouping (edu.hawaii.its.api.type.Grouping)3 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)3 GcGroupSave (edu.internet2.middleware.grouperClient.api.GcGroupSave)3 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)3 WsGroupToSave (edu.internet2.middleware.grouperClient.ws.beans.WsGroupToSave)3 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)3 lombok.val (lombok.val)3 Test (org.junit.jupiter.api.Test)3 Group (edu.hawaii.its.api.type.Group)2 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 WsGroupLookup (edu.internet2.middleware.grouperClient.ws.beans.WsGroupLookup)2 WsQueryFilter (edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter)2 WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)2