Search in sources :

Example 1 with UserAttribute

use of org.apache.pluto.container.om.portlet.UserAttribute in project uPortal by Jasig.

the class RequestAttributeServiceImpl method getMultiValuedUserInfoMap.

/**
 * @param remoteUser
 * @param expectedUserAttributes
 * @return an unmodifiable map containing the multi-valued attributes for the user within the
 *     list of expected attributes
 */
protected Map<String, List<Object>> getMultiValuedUserInfoMap(String remoteUser, List<? extends UserAttribute> expectedUserAttributes) {
    final IPersonAttributes personAttributes = this.personAttributeDao.getPerson(remoteUser);
    if (personAttributes == null) {
        return Collections.emptyMap();
    }
    final Map<String, List<Object>> resultUserInfoMap = new HashMap<String, List<Object>>(expectedUserAttributes.size());
    // Copy expected attributes to the USER_INFO Map
    final Map<String, List<Object>> attributes = personAttributes.getAttributes();
    for (final UserAttribute userAttributeDD : expectedUserAttributes) {
        final String userAttributeName = userAttributeDD.getName();
        // containsKey check to handle attributes with a single null value
        if (attributes.containsKey(userAttributeName)) {
            final List<Object> list_valueObjs = attributes.get(userAttributeName);
            resultUserInfoMap.put(userAttributeName, list_valueObjs);
        }
    }
    return Collections.unmodifiableMap(resultUserInfoMap);
}
Also used : IPersonAttributes(org.apereo.services.persondir.IPersonAttributes) HashMap(java.util.HashMap) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) List(java.util.List)

Example 2 with UserAttribute

use of org.apache.pluto.container.om.portlet.UserAttribute in project uPortal by Jasig.

the class CachedPasswordUserInfoService method isPasswordRequested.

/**
 * Determine whether the portlet has expects a password as one of the user attributes.
 *
 * @param request portlet request
 * @param plutoPortletWindow portlet window
 * @return <code>true</code> if a password is expected, <code>false</code> otherwise
 * @throws PortletContainerException if expeced attributes cannot be determined
 */
public boolean isPasswordRequested(PortletRequest request, PortletWindow plutoPortletWindow) throws PortletContainerException {
    // get the list of requested user attributes
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
    // check to see if the password key is one of the requested user attributes
    List<? extends UserAttribute> requestedUserAttributes = portletApplicationDescriptor.getUserAttributes();
    for (final UserAttribute userAttributeDD : requestedUserAttributes) {
        final String attributeName = userAttributeDD.getName();
        if (attributeName.equals(this.passwordKey))
            return true;
    }
    // if the password key wasn't found in the list of requested attributes
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 3 with UserAttribute

use of org.apache.pluto.container.om.portlet.UserAttribute in project uPortal by Jasig.

the class PersonDirectoryUserInfoService method generateUserInfo.

/**
 * Using the Map of portal user attributes and a List of expected attributes generate the
 * USER_INFO map for the portlet
 *
 * @param portalUserAttributes All the attributes the portal knows about the user
 * @param expectedUserAttributes The attributes the portlet expects to get
 * @return The Map to use for the USER_INFO attribute
 */
protected Map<String, String> generateUserInfo(final IPersonAttributes personAttributes, final List<? extends UserAttribute> expectedUserAttributes, HttpServletRequest httpServletRequest) {
    final Map<String, String> portletUserAttributes = new HashMap<String, String>(expectedUserAttributes.size());
    // Copy expected attributes to the USER_INFO Map
    final Map<String, List<Object>> attributes = personAttributes.getAttributes();
    for (final UserAttribute userAttributeDD : expectedUserAttributes) {
        final String attributeName = userAttributeDD.getName();
        // null then put the key with no value in the returned map
        if (attributes.containsKey(attributeName)) {
            final Object valueObj = personAttributes.getAttributeValue(attributeName);
            final String value = valueObj == null ? null : String.valueOf(valueObj);
            portletUserAttributes.put(attributeName, value);
        }
    }
    return portletUserAttributes;
}
Also used : HashMap(java.util.HashMap) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) List(java.util.List)

Example 4 with UserAttribute

use of org.apache.pluto.container.om.portlet.UserAttribute in project uPortal by Jasig.

the class CasTicketUserInfoService method isCasProxyTicketRequested.

/**
 * Determine whether the portlet has expects a CAS proxy ticket as one of the user attributes.
 *
 * @param request portlet request
 * @param plutoPortletWindow portlet window
 * @return <code>true</code> if a CAS proxy ticket is expected, <code>false</code> otherwise
 * @throws PortletContainerException if expeced attributes cannot be determined
 */
public boolean isCasProxyTicketRequested(PortletRequest request, PortletWindow plutoPortletWindow) throws PortletContainerException {
    // get the list of requested user attributes
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
    // check to see if the proxy ticket key is one of the requested user attributes
    List<? extends UserAttribute> requestedUserAttributes = portletApplicationDescriptor.getUserAttributes();
    for (final UserAttribute userAttributeDD : requestedUserAttributes) {
        final String attributeName = userAttributeDD.getName();
        if (attributeName.equals(this.proxyTicketKey))
            return true;
    }
    // if the proxy ticket key wasn't found in the list of requested attributes
    return false;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletApplicationDefinition(org.apache.pluto.container.om.portlet.PortletApplicationDefinition) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) UserAttribute(org.apache.pluto.container.om.portlet.UserAttribute) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

UserAttribute (org.apache.pluto.container.om.portlet.UserAttribute)4 HashMap (java.util.HashMap)2 List (java.util.List)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)2 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)2 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)2 IPersonAttributes (org.apereo.services.persondir.IPersonAttributes)1