use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class JpaEventSessionDaoTest method testEventSessionDao.
@Test
public void testEventSessionDao() throws Exception {
final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(everyoneGroup.getName()).thenReturn("Everyone");
when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
final IEntityGroup adminGroup = mock(IEntityGroup.class);
when(adminGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(adminGroup.getName()).thenReturn("Admins");
when(compositeGroupService.findGroup("local.1")).thenReturn(adminGroup);
final IPerson person = mock(IPerson.class);
//
// Example event session "1234567890_abcdefg";
final int EVENT_SESSION_LENGTH = 17;
final int EVENT_SESSION_HYPHEN_LENGTH = 10;
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
DateTime timeStamp = null;
for (int i = 0; i <= 100; i++) {
String sessionId = UUID.randomUUID().toString().replaceAll("[\\s\\-()]", "").substring(0, EVENT_SESSION_LENGTH - 1);
sessionId = sessionId.substring(0, 10) + "_" + sessionId.substring(EVENT_SESSION_HYPHEN_LENGTH, sessionId.length());
LoginEvent loginEvent = TestEventFactory.newLoginEvent(this, "testServer", sessionId, person, ImmutableSet.<String>of("local.0", "local.1"), Collections.<String, List<String>>emptyMap());
final EventSession eventSession = eventSessionDao.getEventSession(loginEvent);
assertNotNull(eventSession);
assertEquals(sessionId, eventSession.getEventSessionId());
final Set<AggregatedGroupMapping> groupMappings = eventSession.getGroupMappings();
assertEquals(2, groupMappings.size());
timeStamp = loginEvent.getTimestampAsDate();
}
eventSessionDao.purgeEventSessionsBefore(timeStamp.plusYears(1));
}
});
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class UserAccountHelper method getParentGroups.
public List<JsonEntityBean> getParentGroups(String target) {
IGroupMember member = GroupService.getEntity(target, IPerson.class);
List<JsonEntityBean> parents = new ArrayList<>();
for (IEntityGroup ancestor : member.getAncestorGroups()) {
parents.add(groupListHelper.getEntity(ancestor));
}
Collections.sort(parents);
return parents;
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method find.
/* (non-Javadoc)
* @see org.apereo.portal.groups.IEntityGroupStore#find(java.lang.String)
*/
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;
}
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class LDAPGroupStore method makeGroup.
protected IEntityGroup makeGroup(GroupShadow shadow) throws GroupsException {
IEntityGroup group = null;
if (shadow != null) {
group = new EntityGroupImpl(shadow.key, iperson);
group.setDescription(shadow.description);
group.setName(shadow.name);
}
return group;
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class LDAPGroupStore method findMemberGroupKeys.
public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException {
List keys = new ArrayList();
for (Iterator itr = findMemberGroups(group); itr.hasNext(); ) {
IEntityGroup eg = (IEntityGroup) itr.next();
keys.add(eg.getKey());
}
return (String[]) keys.toArray(new String[keys.size()]);
}
Aggregations