use of edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup in project uPortal by Jasig.
the class GrouperEntityGroupStore method contains.
/* (non-Javadoc)
* @see org.apereo.portal.groups.IEntityGroupStore#contains(org.apereo.portal.groups.IEntityGroup, org.apereo.portal.groups.IGroupMember)
*/
public boolean contains(IEntityGroup group, IGroupMember member) throws GroupsException {
String groupContainerName = group.getLocalKey();
String groupMemberName = member.getKey();
if (!validKey(groupContainerName) || !validKey(groupMemberName)) {
return false;
}
GcHasMember gcHasMember = new GcHasMember();
gcHasMember.assignGroupName(groupContainerName);
gcHasMember.addSubjectLookup(new WsSubjectLookup(null, "g:gsa", groupMemberName));
WsHasMemberResults wsHasMemberResults = gcHasMember.execute();
if (GrouperClientUtils.length(wsHasMemberResults.getResults()) == 1) {
WsHasMemberResult wsHasMemberResult = wsHasMemberResults.getResults()[0];
return StringUtils.equals("IS_MEMBER", wsHasMemberResult.getResultMetadata().getResultCode());
}
return false;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup 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();
}
Aggregations