Search in sources :

Example 1 with IPersonAttributeDao

use of org.jasig.services.persondir.IPersonAttributeDao in project uPortal by Jasig.

the class PersonAttributeDaoLocator method getPersonAttributeDao.

public static IPersonAttributeDao getPersonAttributeDao() {
    AbstractBeanLocator<IPersonAttributeDao> locator = locatorInstance;
    if (locator == null) {
        LOG.info("Looking up bean '" + BEAN_NAME + "' in ApplicationContext due to context not yet being initialized");
        final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
        applicationContext.getBean(PersonAttributeDaoLocator.class.getName());
        locator = locatorInstance;
        if (locator == null) {
            LOG.warn("Instance of '" + BEAN_NAME + "' still null after portal application context has been initialized");
            return applicationContext.getBean(BEAN_NAME, IPersonAttributeDao.class);
        }
    }
    return locator.getInstance();
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao)

Example 2 with IPersonAttributeDao

use of org.jasig.services.persondir.IPersonAttributeDao in project uPortal by Jasig.

the class PersonDirNameFinderTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    Map<String, List<Object>> userWithDisplayNameAttributes = new HashMap<String, List<Object>>();
    userWithDisplayNameAttributes.put("phone", Arrays.asList((Object) "777-7777"));
    userWithDisplayNameAttributes.put("displayName", Arrays.asList((Object) "Display Name"));
    Map<String, List<Object>> userWithEmptyDisplayNameAttributes = new HashMap<String, List<Object>>();
    userWithEmptyDisplayNameAttributes.put("phone", Arrays.asList((Object) "888-8888"));
    userWithEmptyDisplayNameAttributes.put("displayName", Arrays.asList((Object) ""));
    Map<String, List<Object>> userWithoutDisplayNameAttributes = new HashMap<String, List<Object>>();
    userWithoutDisplayNameAttributes.put("phone", Arrays.asList((Object) "666-6666"));
    userWithoutDisplayNameAttributes.put("givenName", Arrays.asList((Object) "Howard"));
    Map<String, Map<String, List<Object>>> daoBackingMap = new HashMap<String, Map<String, List<Object>>>();
    daoBackingMap.put("userWithDisplayName", userWithDisplayNameAttributes);
    daoBackingMap.put("userWithEmptyDisplayName", userWithEmptyDisplayNameAttributes);
    daoBackingMap.put("userWithoutDisplayName", userWithoutDisplayNameAttributes);
    IPersonAttributeDao paDao = new ComplexStubPersonAttributeDao(daoBackingMap);
    this.finder = new PersonDirNameFinder(paDao);
}
Also used : HashMap(java.util.HashMap) IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) ComplexStubPersonAttributeDao(org.jasig.services.persondir.support.ComplexStubPersonAttributeDao)

Example 3 with IPersonAttributeDao

use of org.jasig.services.persondir.IPersonAttributeDao in project uPortal by Jasig.

the class PersonDirNameFinderFactory method storeSingleton.

/**
     * Instantiates the static singleton field PERSON_DIR_NAME_FINDER_INSTANCE. Synchronized to
     * guarantee singleton-ness of the field.
     */
private static synchronized void storeSingleton() {
    // the lock on this object
    if (PERSON_DIR_NAME_FINDER_INSTANCE == null) {
        IPersonAttributeDao personAttributeDao = PersonAttributeDaoLocator.getPersonAttributeDao();
        PERSON_DIR_NAME_FINDER_INSTANCE = new PersonDirNameFinder(personAttributeDao);
    }
}
Also used : IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao)

Example 4 with IPersonAttributeDao

use of org.jasig.services.persondir.IPersonAttributeDao in project uPortal by Jasig.

the class RequestAttributeServiceImplTest method testControl.

/**
     * Default test for function, returns the multivalued attribute map with one multi-valued
     * attribute.
     */
@Test
public void testControl() {
    MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
    httpServletRequest.setRemoteUser("username");
    Map<String, List<Object>> attributes = new HashMap<String, List<Object>>();
    attributes.put("attribute1", Arrays.asList(new Object[] { "value1", "value2", "value3" }));
    NamedPersonImpl personAttributes = new NamedPersonImpl("username", attributes);
    PortletWindow plutoPortletWindow = mock(PortletWindow.class);
    IPortletWindow portletWindow = mock(IPortletWindow.class);
    IPortletEntity portletEntity = mock(IPortletEntity.class);
    when(portletWindow.getPortletEntity()).thenReturn(portletEntity);
    IPortletDefinition portletDefinition = mock(IPortletDefinition.class);
    when(portletEntity.getPortletDefinition()).thenReturn(portletDefinition);
    IPortletDefinitionId portletDefinitionId = mock(IPortletDefinitionId.class);
    when(portletDefinition.getPortletDefinitionId()).thenReturn(portletDefinitionId);
    IPersonAttributeDao personAttributeDao = mock(IPersonAttributeDao.class);
    when(personAttributeDao.getPerson("username")).thenReturn(personAttributes);
    IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
    when(portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow)).thenReturn(portletWindow);
    List<UserAttributeType> userAttributesList = new ArrayList<UserAttributeType>();
    UserAttributeType userAttribute = new UserAttributeType();
    userAttribute.setName("attribute1");
    userAttributesList.add(userAttribute);
    PortletAppType portletApplicationDefinition = new PortletAppType();
    portletApplicationDefinition.addUserAttribute("attribute1");
    IPortletDefinitionRegistry portletDefinitionRegistry = mock(IPortletDefinitionRegistry.class);
    when(portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinitionId)).thenReturn(portletApplicationDefinition);
    RequestAttributeServiceImpl service = new RequestAttributeServiceImpl();
    service.setPersonAttributeDao(personAttributeDao);
    service.setPortletDefinitionRegistry(portletDefinitionRegistry);
    service.setPortletWindowRegistry(portletWindowRegistry);
    Object attribute = service.getAttribute(httpServletRequest, plutoPortletWindow, IPortletRenderer.MULTIVALUED_USERINFO_MAP_ATTRIBUTE);
    Assert.assertNotNull(attribute);
    Assert.assertTrue(attribute instanceof Map);
    @SuppressWarnings("unchecked") Map<String, List<Object>> attributeMap = (Map<String, List<Object>>) attribute;
    List<Object> values = attributeMap.get("attribute1");
    Assert.assertEquals(3, values.size());
    Assert.assertTrue(values.contains("value1"));
    Assert.assertTrue(values.contains("value2"));
    Assert.assertTrue(values.contains("value3"));
}
Also used : IPortletWindowRegistry(org.apereo.portal.portlet.registry.IPortletWindowRegistry) PortletAppType(org.apache.pluto.container.om.portlet.impl.PortletAppType) HashMap(java.util.HashMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ArrayList(java.util.ArrayList) UserAttributeType(org.apache.pluto.container.om.portlet.impl.UserAttributeType) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletDefinitionRegistry(org.apereo.portal.portlet.registry.IPortletDefinitionRegistry) NamedPersonImpl(org.jasig.services.persondir.support.NamedPersonImpl) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao) ArrayList(java.util.ArrayList) List(java.util.List) PortletWindow(org.apache.pluto.container.PortletWindow) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) HashMap(java.util.HashMap) Map(java.util.Map) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Test(org.junit.Test)

Example 5 with IPersonAttributeDao

use of org.jasig.services.persondir.IPersonAttributeDao in project uPortal by Jasig.

the class PersonLookupHelperImplTest method init.

@Before
public void init() {
    // Must make the superclass use our collection of attribute names
    IPersonAttributeDao personAttributeDao = mock(IPersonAttributeDao.class);
    when(personAttributeDao.getPossibleUserAttributeNames()).thenReturn(ALL_ATTRIBUTES);
    setPersonAttributeDao(personAttributeDao);
    principal = mock(IAuthorizationPrincipal.class);
    // Generally permitted
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_USER_ATTRIBUTE_ACTIVITY, GENERALLY_PERMITTED_ATTRIBUTE)).thenReturn(true);
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_USER_ATTRIBUTE_ACTIVITY, PERMITTED_OWN_ATTRIBUTE)).thenReturn(false);
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_USER_ATTRIBUTE_ACTIVITY, NEVER_PERMITTED_ATTRIBUTE)).thenReturn(false);
    // Own attributes
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_OWN_USER_ATTRIBUTE_ACTIVITY, GENERALLY_PERMITTED_ATTRIBUTE)).thenReturn(true);
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_OWN_USER_ATTRIBUTE_ACTIVITY, PERMITTED_OWN_ATTRIBUTE)).thenReturn(true);
    when(principal.hasPermission(IPermission.PORTAL_USERS, IPermission.VIEW_OWN_USER_ATTRIBUTE_ACTIVITY, NEVER_PERMITTED_ATTRIBUTE)).thenReturn(false);
}
Also used : IPersonAttributeDao(org.jasig.services.persondir.IPersonAttributeDao) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Before(org.junit.Before)

Aggregations

IPersonAttributeDao (org.jasig.services.persondir.IPersonAttributeDao)6 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ArrayList (java.util.ArrayList)1 Element (net.sf.ehcache.Element)1 PortletWindow (org.apache.pluto.container.PortletWindow)1 PortletAppType (org.apache.pluto.container.om.portlet.impl.PortletAppType)1 UserAttributeType (org.apache.pluto.container.om.portlet.impl.UserAttributeType)1 GroupsException (org.apereo.portal.groups.GroupsException)1 IEntityGroup (org.apereo.portal.groups.IEntityGroup)1 PagsGroup (org.apereo.portal.groups.pags.PagsGroup)1 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)1 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)1 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)1 IPortletDefinitionRegistry (org.apereo.portal.portlet.registry.IPortletDefinitionRegistry)1 IPortletWindowRegistry (org.apereo.portal.portlet.registry.IPortletWindowRegistry)1 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)1 RestrictedPerson (org.apereo.portal.security.provider.RestrictedPerson)1