Search in sources :

Example 21 with PortletSession

use of javax.portlet.PortletSession in project uPortal by Jasig.

the class LoginPortletHelper method getSelectedProfile.

/**
 * Get the profile that should be pre-selected in the local login form.
 *
 * @param request
 * @return
 */
public String getSelectedProfile(PortletRequest request) {
    // if a profile selection exists in the session, use it
    final PortletSession session = request.getPortletSession();
    String profileName = (String) session.getAttribute(SessionAttributeProfileMapperImpl.DEFAULT_SESSION_ATTRIBUTE_NAME, PortletSession.APPLICATION_SCOPE);
    // the user
    if (profileName == null) {
        // get the profile for the current request
        final HttpServletRequest httpServletRequest = portalRequestUtils.getPortletHttpRequest(request);
        final IUserInstance ui = userInstanceManager.getUserInstance(httpServletRequest);
        final IUserProfile profile = ui.getPreferencesManager().getUserProfile();
        // the profile key map used by the session attribute profile mapper
        for (Map.Entry<String, String> entry : mappings.entrySet()) {
            if (entry.getValue().equals(profile.getProfileFname())) {
                profileName = entry.getKey();
                break;
            }
        }
    }
    return profileName;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IUserInstance(org.apereo.portal.user.IUserInstance) PortletSession(javax.portlet.PortletSession) IUserProfile(org.apereo.portal.IUserProfile) Map(java.util.Map)

Example 22 with PortletSession

use of javax.portlet.PortletSession in project uPortal by Jasig.

the class IdentitySwapperManagerImpl method impersonateUser.

@Override
public void impersonateUser(PortletRequest portletRequest, String currentUserName, String targetUsername, String profile) {
    if (!canImpersonateUser(currentUserName, targetUsername)) {
        throw new RuntimeAuthorizationException(currentUserName, IPermission.IMPERSONATE_USER_ACTIVITY, targetUsername);
    }
    final PortletSession portletSession = portletRequest.getPortletSession();
    portletSession.setAttribute(SWAP_TARGET_UID, targetUsername, PortletSession.APPLICATION_SCOPE);
    portletSession.setAttribute(SWAP_TARGET_PROFILE, profile, PortletSession.APPLICATION_SCOPE);
}
Also used : PortletSession(javax.portlet.PortletSession)

Aggregations

PortletSession (javax.portlet.PortletSession)22 IOException (java.io.IOException)5 HashMap (java.util.HashMap)4 PortletRequest (javax.portlet.PortletRequest)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 SessionUser (org.alfresco.repo.SessionUser)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 PortletException (javax.portlet.PortletException)2 PortletRequestDispatcher (javax.portlet.PortletRequestDispatcher)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpSession (javax.servlet.http.HttpSession)2 AuthenticationException (org.alfresco.repo.security.authentication.AuthenticationException)2 AuthenticationService (org.alfresco.service.cmr.security.AuthenticationService)2 ErrorBean (org.alfresco.web.bean.ErrorBean)2 User (org.alfresco.web.bean.repository.User)2 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2