use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class CachedPasswordUserInfoService method getUserInfo.
/*
* (non-Javadoc)
* @see org.apache.pluto.container.UserInfoService#getUserInfo(javax.portlet.PortletRequest, org.apache.pluto.container.PortletWindow)
*/
@Override
public Map<String, String> getUserInfo(PortletRequest request, PortletWindow portletWindow) throws PortletContainerException {
Map<String, String> userInfo = new HashMap<String, String>();
// check to see if a password is expected by this portlet
if (isPasswordRequested(request, portletWindow)) {
log.debug("Portlet named {} wants a password", portletWindow.getPortletDefinition().getPortletName());
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final IUserInstance userInstance = userInstanceManager.getUserInstance(httpServletRequest);
final IPerson person = userInstance.getPerson();
final ISecurityContext context = person.getSecurityContext();
// if it is, attempt to request a password
String password = getPassword(context);
log.debug(password != null ? "Have a non-null password" : "password was null");
if (this.decryptPassword && password != null) {
log.debug("Attempting to decrypt password");
password = stringEncryptionService.decrypt(password);
log.debug("Password decryption complete, password is length {}", password != null ? password.length() : "is null");
}
if (password != null) {
userInfo.put(this.passwordKey, password);
log.debug("Found password with length {} for portlet name {}", password.length() != 0 ? "non-zero" : 0, portletWindow.getPortletDefinition().getPortletName());
}
}
return userInfo;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class PortalSpELServiceImpl method getEvaluationContext.
/**
* Return a SpEL evaluation context for the supplied web request.
*
* @param request
* @return
*/
protected EvaluationContext getEvaluationContext(WebRequest request) {
final HttpServletRequest httpRequest = this.portalRequestUtils.getOriginalPortalRequest(request);
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(httpRequest);
final IPerson person = userInstance.getPerson();
final SpELEnvironmentRoot root = new SpELEnvironmentRoot(request, person);
final StandardEvaluationContext context = new StandardEvaluationContext(root);
context.setBeanResolver(this.beanResolver);
return context;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class UserLayoutParameterProcessor method processParameters.
@Override
public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final String tabId = portalRequestInfo.getTargetedLayoutNodeId();
if (tabId != null) {
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "focusedTabID", tabId);
}
// on a portlet, it will get overwritten with the new value below.
if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
transientUserLayoutManagerWrapper.setFocusedId(null);
}
final UrlState urlState = portalRequestInfo.getUrlState();
switch(urlState) {
case DETACHED:
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "detached", Boolean.TRUE.toString());
case MAX:
{
final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, targetWindowId);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
final String channelSubscribeId = portletEntity.getLayoutNodeId();
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", channelSubscribeId);
if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
// get wrapper implementation for focusing
final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
// .. and now set it as the focused id
transientUserLayoutManagerWrapper.setFocusedId(channelSubscribeId);
}
//If portletRequestInfo was null just fall through to NORMAL state
break;
}
}
case NORMAL:
default:
{
this.stylesheetUserPreferencesService.setStylesheetParameter(request, PreferencesScope.STRUCTURE, "userLayoutRoot", IUserLayout.ROOT_NODE_NAME);
break;
}
}
return true;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class FavoritesController method initializeView.
/**
* Handles all Favorites portlet VIEW mode renders. Populates model with user's favorites and
* selects a view to display those favorites.
*
* <p>View selection:
*
* <p>Returns "jsp/Favorites/view" in the normal case where the user has at least one favorited
* portlet or favorited collection.
*
* <p>Returns "jsp/Favorites/view_zero" in the edge case where the user has zero favorited
* portlets AND zero favorited collections.
*
* <p>Model: marketPlaceFname --> String functional name of Marketplace portlet, or null if not
* available. collections --> List of favorited collections (IUserLayoutNodeDescription s)
* favorites --> List of favorited individual portlets (IUserLayoutNodeDescription s)
*
* @param model . Spring model. This method adds three model attributes.
* @return jsp/Favorites/view[_zero]
*/
@RenderMapping
public String initializeView(Model model) {
IUserInstance ui = userInstanceManager.getUserInstance(portalRequestUtils.getCurrentPortalRequest());
UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
IUserLayoutManager ulm = upm.getUserLayoutManager();
IUserLayout userLayout = ulm.getUserLayout();
// TODO: the portlet could predicate including a non-null marketplace portlet fname
// on the accessing user having permission to render the portlet referenced by that fname
// so that portlet would gracefully degrade when configured with bad marketplace portlet fname
// and also gracefully degrade when the accessing user doesn't have permission to access an otherwise
// viable configured marketplace. This complexity may not be worth it. Anyway it is not yet implemented.
model.addAttribute("marketplaceFname", this.marketplaceFName);
List<IUserLayoutNodeDescription> collections = FavoritesUtils.getFavoriteCollections(userLayout);
model.addAttribute("collections", collections);
List<IUserLayoutNodeDescription> favorites = FavoritesUtils.getFavoritePortlets(userLayout);
model.addAttribute("favorites", favorites);
// default to the regular old view
String viewName = "jsp/Favorites/view";
if (collections.isEmpty() && favorites.isEmpty()) {
// special edge case of zero favorites, switch to special view
viewName = "jsp/Favorites/view_zero";
}
logger.trace("Favorites Portlet VIEW mode render populated model [{}] for render by view {}.", model, viewName);
return viewName;
}
use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.
the class FavoritesEditController method initializeView.
/**
* Handles all Favorites portlet EDIT mode renders. Populates model with user's favorites and
* selects a view to display those favorites.
*
* <p>View selection:
*
* <p>Returns "jsp/Favorites/edit" in the normal case where the user has at least one favorited
* portlet or favorited collection.
*
* <p>Returns "jsp/Favorites/edit_zero" in the edge case where the user has zero favorited
* portlets AND zero favorited collections.
*
* <p>Model: marketPlaceFname --> String functional name of Marketplace portlet, or null if not
* available. collections --> List of favorited collections (IUserLayoutNodeDescription s)
* favorites --> List of favorited individual portlets (IUserLayoutNodeDescription s)
* successMessageCode --> String success message bundle key, or null if none errorMessageCode
* --> String error message bundle key, or null if none nameOfFavoriteActedUpon --> Name of
* favorite acted upon, intended as parameter to success or error message
*
* @param model . Spring model. This method adds five model attributes.
* @return jsp/Favorites/edit[_zero]
*/
@RenderMapping
public String initializeView(Model model, RenderRequest renderRequest) {
IUserInstance ui = userInstanceManager.getUserInstance(portalRequestUtils.getCurrentPortalRequest());
UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
IUserLayoutManager ulm = upm.getUserLayoutManager();
IUserLayout userLayout = ulm.getUserLayout();
// TODO: the portlet could predicate including a non-null marketplace portlet fname
// on the accessing user having permission to render the portlet referenced by that fname
// so that portlet would gracefully degrade when configured with bad marketplace portlet fname
// and also gracefully degrade when the accessing user doesn't have permission to access an otherwise
// viable configured marketplace. This complexity may not be worth it. Anyway it is not yet implemented.
model.addAttribute("marketplaceFname", this.marketplaceFName);
List<IUserLayoutNodeDescription> collections = FavoritesUtils.getFavoriteCollections(userLayout);
model.addAttribute("collections", collections);
List<IUserLayoutNodeDescription> favorites = FavoritesUtils.getFavoritePortlets(userLayout);
model.addAttribute("favorites", favorites);
model.addAttribute("successMessageCode", renderRequest.getParameter("successMessageCode"));
model.addAttribute("errorMessageCode", renderRequest.getParameter("errorMessageCode"));
model.addAttribute("nameOfFavoriteActedUpon", renderRequest.getParameter("nameOfFavoriteActedUpon"));
// default to the regular old edit view
String viewName = "jsp/Favorites/edit";
if (collections.isEmpty() && favorites.isEmpty()) {
// use the special case view
viewName = "jsp/Favorites/edit_zero";
}
logger.trace("Favorites Portlet EDIT mode built model [{}] and selected view {}.", model, viewName);
return viewName;
}
Aggregations