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;
}
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();
}
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();
}
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);
}
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;
}
Aggregations