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;
}
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);
}
Aggregations