Search in sources :

Example 36 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class StylesheetUserPreferencesServiceImpl method getStylesheetDescriptor.

@Override
public IStylesheetDescriptor getStylesheetDescriptor(HttpServletRequest request, PreferencesScope prefScope) {
    String stylesheetName = this.getStyleSheetName(request, prefScope);
    if (!StringUtils.isBlank(stylesheetName)) {
        return this.stylesheetDescriptorDao.getStylesheetDescriptorByName(stylesheetName);
    } else {
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
        final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
        final IUserProfile userProfile = preferencesManager.getUserProfile();
        final int stylesheetId = prefScope.getStylesheetId(userProfile);
        return this.stylesheetDescriptorDao.getStylesheetDescriptor(stylesheetId);
    }
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserProfile(org.apereo.portal.IUserProfile) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 37 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class ThemeNameRequestPropertiesManager method populateRequestProperties.

@Override
public <P extends Populator<String, String>> void populateRequestProperties(HttpServletRequest portletRequest, IPortletWindow portletWindow, P propertiesPopulator) {
    // get the current user profile
    IUserInstance ui = userInstanceManager.getUserInstance(portletRequest);
    IUserPreferencesManager upm = ui.getPreferencesManager();
    IUserProfile profile = upm.getUserProfile();
    // get the theme for this profile
    long themeId = profile.getThemeStylesheetId();
    IStylesheetDescriptor theme = stylesheetDao.getStylesheetDescriptor(themeId);
    // set the theme name as a portlet response property
    final String themeName = theme.getName();
    propertiesPopulator.put(IPortletRenderer.THEME_NAME_PROPERTY, themeName);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserProfile(org.apereo.portal.IUserProfile) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager)

Example 38 with IUserInstance

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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) HashMap(java.util.HashMap) ISecurityContext(org.apereo.portal.security.ISecurityContext)

Example 39 with IUserInstance

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;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) IUserLayout(org.apereo.portal.layout.IUserLayout) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 40 with IUserInstance

use of org.apereo.portal.user.IUserInstance in project uPortal by Jasig.

the class PortletWorkerFactoryImpl method getErrorPortletWindowId.

protected IPortletWindowId getErrorPortletWindowId(HttpServletRequest request, String fname) {
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IPortletEntity errorPortletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
    final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, errorPortletEntity.getPortletEntityId());
    return portletWindow.getPortletWindowId();
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Aggregations

IUserInstance (org.apereo.portal.user.IUserInstance)65 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)28 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)28 IPerson (org.apereo.portal.security.IPerson)25 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)15 PortalException (org.apereo.portal.PortalException)14 IUserLayoutNodeDescription (org.apereo.portal.layout.node.IUserLayoutNodeDescription)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ModelAndView (org.springframework.web.servlet.ModelAndView)13 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)12 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)10 IUserProfile (org.apereo.portal.IUserProfile)10 Locale (java.util.Locale)9 IUserLayout (org.apereo.portal.layout.IUserLayout)7 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)7 HashMap (java.util.HashMap)6 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)6 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)6 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)5