Search in sources :

Example 31 with IEntityGroup

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));
        }
    });
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IPerson(org.apereo.portal.security.IPerson) ImmutableSet(com.google.common.collect.ImmutableSet) CompositeName(javax.naming.CompositeName) LoginEvent(org.apereo.portal.events.LoginEvent) DateTime(org.joda.time.DateTime) CallableWithoutResult(org.apereo.portal.concurrency.CallableWithoutResult) Test(org.junit.Test) BaseAggrEventsJpaDaoTest(org.apereo.portal.test.BaseAggrEventsJpaDaoTest)

Example 32 with IEntityGroup

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;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) JsonEntityBean(org.apereo.portal.layout.dlm.remoting.JsonEntityBean) ArrayList(java.util.ArrayList)

Example 33 with IEntityGroup

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;
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) GroupsException(org.apereo.portal.groups.GroupsException)

Example 34 with IEntityGroup

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;
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) EntityGroupImpl(org.apereo.portal.groups.EntityGroupImpl)

Example 35 with IEntityGroup

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()]);
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Aggregations

IEntityGroup (org.apereo.portal.groups.IEntityGroup)77 IGroupMember (org.apereo.portal.groups.IGroupMember)29 ArrayList (java.util.ArrayList)21 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)16 EntityIdentifier (org.apereo.portal.EntityIdentifier)14 HashSet (java.util.HashSet)11 HashMap (java.util.HashMap)10 LinkedList (java.util.LinkedList)9 GroupsException (org.apereo.portal.groups.GroupsException)9 JsonEntityBean (org.apereo.portal.layout.dlm.remoting.JsonEntityBean)9 EntityEnum (org.apereo.portal.portlets.groupselector.EntityEnum)9 IPermission (org.apereo.portal.security.IPermission)9 AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)8 List (java.util.List)7 CompositeName (javax.naming.CompositeName)7 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)7 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 IPerson (org.apereo.portal.security.IPerson)7 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)7 DateTime (org.joda.time.DateTime)7