Search in sources :

Example 31 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class MarketplaceService method onApplicationEvent.

/**
     * Handle the portal LoginEvent. If marketplace caching is enabled, will preload marketplace
     * entries for the currently logged in user.
     *
     * @param loginEvent the login event.
     */
@Override
public void onApplicationEvent(LoginEvent loginEvent) {
    if (enableMarketplacePreloading) {
        final IPerson person = loginEvent.getPerson();
        /*
             * Passing an empty collection pre-loads an unfiltered collection;
             * instances of PortletMarketplace that specify filtering will
             * trigger a new collection to be loaded.
             */
        final Set<PortletCategory> empty = Collections.emptySet();
        loadMarketplaceEntriesFor(person, empty);
    }
}
Also used : IPerson(org.apereo.portal.security.IPerson) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 32 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PortletDelegationDispatcherImpl method doAction.

@Override
public DelegationActionResponse doAction(ActionRequest actionRequest, ActionResponse actionResponse, DelegationRequest delegationRequest) throws IOException {
    final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(actionRequest);
    final HttpServletResponse response = this.portalRequestUtils.getOriginalPortalResponse(actionRequest);
    //Sanity check that the dispatch is being called by the same user it was created for
    final IPerson person = this.personManager.getPerson(request);
    if (this.userId != person.getID()) {
        throw new IllegalStateException("This dispatcher was created for userId " + this.userId + " but is being executed for userId " + person.getID());
    }
    this.setupDelegateRequestInfo(request, delegationRequest);
    final IPortletWindowId portletWindowId = this.portletWindow.getPortletWindowId();
    try {
        //TODO canRender permission checks!
        this.portletRenderer.doAction(portletWindowId, request, response);
    } catch (RuntimeException e) {
        this.logger.error("Failed to execute action on delegate", e);
        throw e;
    }
    //Get the portal URL builders for this request and check if a redirect was sent
    final IPortalActionUrlBuilder portalActionUrlBuilder = this.portalUrlProvider.getPortalActionUrlBuilder(request);
    final String redirectLocation = portalActionUrlBuilder.getRedirectLocation();
    if (redirectLocation != null) {
        final String renderUrlParamName = portalActionUrlBuilder.getRenderUrlParamName();
        //clear out the redirect from the delegate, leave it up to the parent if the redirect should happen
        portalActionUrlBuilder.setRedirectLocation(null, null);
        return new DelegationActionResponse(this.getDelegateState(), redirectLocation, renderUrlParamName);
    }
    //No redirect so get the portlet's url builder and copy the state-changing data into the delegate response
    final IPortletUrlBuilder portletUrlBuilder = portalActionUrlBuilder.getPortletUrlBuilder(portletWindowId);
    final WindowState windowState = portletUrlBuilder.getWindowState();
    final PortletMode portletMode = portletUrlBuilder.getPortletMode();
    final Map<String, String[]> parameters = portletUrlBuilder.getParameters();
    return new DelegationActionResponse(this.getDelegateState(), portletMode, windowState, parameters);
}
Also used : WindowState(javax.portlet.WindowState) IPortletUrlBuilder(org.apereo.portal.url.IPortletUrlBuilder) HttpServletResponse(javax.servlet.http.HttpServletResponse) IPortalActionUrlBuilder(org.apereo.portal.url.IPortalActionUrlBuilder) DelegationActionResponse(org.apereo.portal.api.portlet.DelegationActionResponse) PortletMode(javax.portlet.PortletMode) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 33 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PortletDelegationLocatorImpl method createRequestDispatcher.

/* (non-Javadoc)
     * @see org.apereo.portal.api.portlet.PortletDelegationLocator#createRequestDispatcher(org.apereo.portal.portlet.om.IPortletDefinitionId)
     */
@Override
public PortletDelegationDispatcher createRequestDispatcher(PortletRequest portletRequest, IPortletDefinitionId delegatePortletDefinitionId) {
    final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
    final String windowID = portletRequest.getWindowID();
    final IPortletWindowId parentPortletWindowId = this.portletWindowRegistry.getPortletWindowId(request, windowID);
    final IPortletEntity delegatePortletEntity = this.portletEntityRegistry.getOrCreateDelegatePortletEntity(request, parentPortletWindowId, delegatePortletDefinitionId);
    final IPortletEntityId delegatePortletEntityId = delegatePortletEntity.getPortletEntityId();
    final IPortletWindow delegatePortletWindow = this.portletWindowRegistry.createDelegatePortletWindow(request, delegatePortletEntityId, parentPortletWindowId);
    final IPerson person = this.personManager.getPerson(request);
    final int userId = person.getID();
    return new PortletDelegationDispatcherImpl(delegatePortletWindow, userId, portalRequestUtils, personManager, portletRenderer, portalUrlProvider, portletDelegationManager);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 34 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class PortletDelegationDispatcherImpl method doRender.

@Override
public DelegationResponse doRender(RenderRequest renderRequest, RenderResponse renderResponse, DelegationRequest delegationRequest, PortletOutputHandler portletOutputHandler) throws IOException {
    final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(renderRequest);
    final HttpServletResponse response = this.portalRequestUtils.getOriginalPortalResponse(renderRequest);
    //Sanity check that the dispatch is being called by the same user it was created for
    final IPerson person = this.personManager.getPerson(request);
    if (this.userId != person.getID()) {
        throw new IllegalStateException("This dispatcher was created for userId " + this.userId + " but is being executed for userId " + person.getID());
    }
    this.setupDelegateRequestInfo(request, delegationRequest);
    try {
        //TODO canRender permission checks!
        this.portletRenderer.doRenderMarkup(this.portletWindow.getPortletWindowId(), request, response, portletOutputHandler);
    } catch (RuntimeException e) {
        this.logger.error("Failed to render delegate", e);
        throw e;
    } finally {
        portletOutputHandler.flushBuffer();
    }
    return new DelegationResponse(this.getDelegateState());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) DelegationResponse(org.apereo.portal.api.portlet.DelegationResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 35 with IPerson

use of org.apereo.portal.security.IPerson in project uPortal by Jasig.

the class ChannelListController method getPortletRegistry.

/**
     * Updated version of this API. Supports an optional 'categoryId' parameter. If provided, this
     * URL will return the portlet registry beginning with the specified category, including all
     * descendants, and <em>excluding</em> uncategorized portlets. If no 'categoryId' is provided,
     * this method returns the portlet registry beginning with 'All Categories' (the root) and
     * <em>including</em> uncategorized portlets. Access is based on the SUBSCRIBE permission.
     *
     * @since 4.3
     */
@RequestMapping(value = "/v4-3/dlm/portletRegistry.json", method = RequestMethod.GET)
public ModelAndView getPortletRegistry(WebRequest webRequest, HttpServletRequest request, @RequestParam(value = "categoryId", required = false) String categoryId) {
    final PortletCategory rootCategory = categoryId != null ? portletCategoryRegistry.getPortletCategory(categoryId) : portletCategoryRegistry.getTopLevelPortletCategory();
    final boolean includeUncategorized = categoryId != null ? // Don't provide uncategorized portlets
    false : // if a specific category was requested
    true;
    final IPerson user = personManager.getPerson(request);
    final Map<String, SortedSet<?>> registry = getRegistry43(webRequest, user, rootCategory, includeUncategorized);
    return new ModelAndView("jsonView", "registry", registry);
}
Also used : IPerson(org.apereo.portal.security.IPerson) ModelAndView(org.springframework.web.servlet.ModelAndView) SortedSet(java.util.SortedSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IPerson (org.apereo.portal.security.IPerson)140 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)28 HttpServletRequest (javax.servlet.http.HttpServletRequest)26 IUserInstance (org.apereo.portal.user.IUserInstance)25 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)21 ModelAndView (org.springframework.web.servlet.ModelAndView)20 HashMap (java.util.HashMap)19 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)17 EntityIdentifier (org.apereo.portal.EntityIdentifier)13 PortalException (org.apereo.portal.PortalException)13 HttpSession (javax.servlet.http.HttpSession)12 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)12 PersonImpl (org.apereo.portal.security.provider.PersonImpl)12 IPersonAttributes (org.jasig.services.persondir.IPersonAttributes)12 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)11 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)11 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)8 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)8 ISecurityContext (org.apereo.portal.security.ISecurityContext)8