Package org.jasig.portal.security

Examples of org.jasig.portal.security.IPerson


  public void testMapsParametersToAttributes() {
    ChannelRuntimeData channelRuntimeData = new ChannelRuntimeData();
    channelRuntimeData.setParameter("param_one", "value_one");
    channelRuntimeData.setParameter("param_two", "value_two");
   
    IPerson person = converter.channelRuntimeDataToPerson(channelRuntimeData);
    assertEquals("value_one", person.getAttribute("param_one"));
    assertEquals("value_two", person.getAttribute("param_two"));
   
  }
View Full Code Here


 
  public void testDoesNotMapFormActionParameterToAttribute() {
    ChannelRuntimeData channelRuntimeData = new ChannelRuntimeData();
    channelRuntimeData.setParameter(Constants.FORMACTION, "some_value");
   
    IPerson person = converter.channelRuntimeDataToPerson(channelRuntimeData);
   
    assertNull(person.getAttribute(Constants.FORMACTION));
  }
View Full Code Here

   
    /* (non-Javadoc)
     * @see org.jasig.portal.rendering.IPortalRenderingPipeline#renderState(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.jasig.portal.IUserInstance)
     */
    public void renderState(HttpServletRequest req, HttpServletResponse res, IUserInstance userInstance) throws PortalException {
        final IPerson person = userInstance.getPerson();
        final LocaleManager localeManager = userInstance.getLocaleManager();
        final IUserPreferencesManager uPreferencesManager = userInstance.getPreferencesManager();
        final ChannelManager channelManager = userInstance.getChannelManager();
        final Object renderingLock = userInstance.getRenderingLock();
       
        UPFileSpec upfs = new UPFileSpec(req);
        String rootNodeId = upfs.getMethodNodeId();
        if (rootNodeId == null) {
            rootNodeId = UPFileSpec.USER_LAYOUT_ROOT_NODE;
        }
       
        // see if a new root target has been specified
        String newRootNodeId = req.getParameter("uP_detach_target");

        // set optimistic uPElement value
        UPFileSpec uPElement = new UPFileSpec(UPFileSpec.RENDER_METHOD, rootNodeId, null, null);

        if (newRootNodeId != null) {
            // set a new root
            uPElement.setMethodNodeId(newRootNodeId);
        }
       
        channelManager.setUPElement(uPElement);

        // proccess possible portlet action
        final IPortletWindowId targetedPortletWindowId = this.portletRequestParameterManager.getTargetedPortletWindowId(req);
        if (targetedPortletWindowId != null) {
            final PortletUrl portletUrl = this.portletRequestParameterManager.getPortletRequestInfo(req, targetedPortletWindowId);
           
            if (RequestType.ACTION.equals(portletUrl.getRequestType())) {
                final IPortletEntity targetedPortletEntity = this.portletWindowRegistry.getParentPortletEntity(req, targetedPortletWindowId);
                if (targetedPortletEntity != null) {
                    final String channelSubscribeId = targetedPortletEntity.getChannelSubscribeId();
                    final boolean actionExecuted = channelManager.doChannelAction(req, res, channelSubscribeId, false);
                   
                    if (actionExecuted) {
                        // The action completed, return immediately
                        return;
                    }
   
                    // The action didn't execute, continue and try to render normally
                }
            }
        }
       
        // process possible worker dispatch
        final boolean workerDispatched = this.processWorkerDispatchIfNecessary(req, res, uPreferencesManager, channelManager);
        if (workerDispatched) {
            //If a worker was dispatched to return immediately
            return;
        }
       
        //Set a larger buffer to allow for explicit flushing
        res.setBufferSize(16 * 1024);
       
        final long startTime = System.currentTimeMillis();
        synchronized (renderingLock) {
            // This function does ALL the content gathering/presentation work.
            // The following filter sequence is processed:
            //        userLayoutXML (in UserPreferencesManager)
            //              |
            //        incorporate StructureAttributes
            //              |
            //        Structure transformation
            //              + (buffering step)
            //        ChannelRendering Buffer
            //              |
            //        ThemeAttributesIncorporation Filter
            //              |
            //        Theme Transformatio
            //              |
            //        ChannelIncorporation filter
            //              |
            //        Serializer (XHTML/WML/HTML/etc.)
            //              |
            //        JspWriter
            //

            try {

                // determine uPElement (optimistic prediction) --begin
                // We need uPElement for ChannelManager.setReqNRes() call. That call will distribute uPElement
                // to Privileged channels. We assume that Privileged channels are smart enough not to delete
                // themselves in the detach mode !

                // In general transformations will start at the userLayoutRoot node, unless
                // we are rendering something in a detach mode.
                IUserLayoutNodeDescription rElement = null;
                // see if an old detach target exists in the servlet path

                // give channels the current locale manager
                channelManager.setLocaleManager(localeManager);

                IUserLayoutManager ulm = uPreferencesManager.getUserLayoutManager();

                // determine uPElement (optimistic prediction) --end

                // set up the channel manager

                channelManager.startRenderingCycle(req, res, uPElement);

                // after this point the layout is determined

                UserPreferences userPreferences = uPreferencesManager.getUserPreferences();
                StructureStylesheetDescription ssd = uPreferencesManager.getStructureStylesheetDescription();
                ThemeStylesheetDescription tsd = uPreferencesManager.getThemeStylesheetDescription();

                // verify upElement and determine rendering root --begin
                if (newRootNodeId != null && (!newRootNodeId.equals(rootNodeId))) {
                    // see if the new detach traget is valid
                    try {
                        rElement = ulm.getNode(newRootNodeId);
                    }
                    catch (PortalException e) {
                        rElement = null;
                    }

                    if (rElement != null) {
                        // valid new root id was specified. need to redirect
                        // peterk: should we worry about forwarding
                        // parameters here ? or those passed with detach
                        // always get sacked ?
                        // Andreas: Forwarding parameters with detach
                        // are not lost anymore with the URLUtil class.

                        // Skip the uP_detach_target parameter since
                        // it has already been processed
                        String[] skipParams = new String[] { "uP_detach_target" };

                        try {
                            URLUtil.redirect(req, res, newRootNodeId, true, skipParams, CHARACTER_SET);
                        }
                        catch (PortalException pe) {
                            log.error("PortalException occurred while redirecting",
                                    pe);
                        }
                        return;
                    }
                }

                // LogService.log(LogService.DEBUG,"uP_detach_target=\""+rootNodeId+"\".");
                try {
                    rElement = ulm.getNode(rootNodeId);
                }
                catch (PortalException e) {
                    rElement = null;
                }
                // if we haven't found root node so far, set it to the userLayoutRoot
                if (rElement == null) {
                    rootNodeId = UPFileSpec.USER_LAYOUT_ROOT_NODE;
                }

                // update the render target
                uPElement.setMethodNodeId(rootNodeId);

                // inform channel manager about the new uPElement value
                channelManager.setUPElement(uPElement);
                // verify upElement and determine rendering root --begin
               
                // Increase output buffer size, buffer will be flushed before and after every <channel>
                res.setBufferSize(16 * 1024);

                // Disable page caching
                res.setHeader("pragma", "no-cache");
                res.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");
                res.setDateHeader("Expires", 0);
                // set the response mime type
                res.setContentType(tsd.getMimeType() + "; charset=" + CHARACTER_SET);
                // obtain the writer - res.getWriter() must occur after res.setContentType()
                Writer out = new BufferedWriter(res.getWriter(), 1024);
                // get a serializer appropriate for the target media
                BaseMarkupSerializer markupSerializer =
                    MEDIA_MANAGER.getSerializerByName(tsd.getSerializerName(),
                        new ChannelTitleIncorporationWiterFilter(out, channelManager, ulm));
                // set up the serializer
                markupSerializer.asContentHandler();
                // see if we can use character caching
                boolean ccaching = (CHARACTER_CACHE_ENABLED && (markupSerializer instanceof CachingSerializer));
                channelManager.setCharacterCaching(ccaching);
                // pass along the serializer name
                channelManager.setSerializerName(tsd.getSerializerName());
                // initialize ChannelIncorporationFilter
                CharacterCachingChannelIncorporationFilter cif = new CharacterCachingChannelIncorporationFilter(markupSerializer, channelManager, CACHE_ENABLED && CHARACTER_CACHE_ENABLED, req, res);

                String cacheKey = null;
                boolean output_produced = false;
                if (CACHE_ENABLED) {
                    boolean ccache_exists = false;
                    // obtain the cache key
                    cacheKey = constructCacheKey(uPreferencesManager, rootNodeId);
                    if (ccaching) {
                        // obtain character cache
                        List<CacheEntry> cacheEntries = systemCharacterCache.get(cacheKey);
                        if(cacheEntries!=null && cacheEntries.size()>0) {
                            ccache_exists = true;
                            if (log.isDebugEnabled())
                                log
                                        .debug("retreived transformation character block cache for a key \""
                                                + cacheKey + "\"");
                            // start channel threads
                            for(int i=0;i<cacheEntries.size();i++) {
                                CacheEntry ce = cacheEntries.get(i);
                                if (ce.getCacheType().equals(CacheType.CHANNEL_CONTENT)) {
                                    String channelSubscribeId = ((ChannelContentCacheEntry)ce).getChannelId();
                                    if(channelSubscribeId!=null) {
                                        try {
                                            channelManager.startChannelRendering(req, res, channelSubscribeId);
                                        } catch (PortalException e) {
                                            log.error("UserInstance::renderState() : unable to start rendering channel (subscribeId=\""+channelSubscribeId+"\", user="+person.getID()+" layoutId="+uPreferencesManager.getCurrentProfile().getLayoutId(),e);
                                        }
                                    } else {
                                        log.error("channel entry " + Integer.toString(i)
                                            + " in character cache is invalid (user=" + person.getID() + ")!");
                                    }
                                }
                            }
                            channelManager.commitToRenderingChannelSet();

View Full Code Here

        this.overwritingPersonAttributeDao.setUserAttributeOverride(uid, attributes);

        //Update the IPerson, setting the overridden attributes
        final HttpServletRequest portalRequest = this.portalRequestUtils.getOriginalPortalRequest(portletRequest);
       
        final IPerson person = this.personManager.getPerson(portalRequest);
        final Map<String, List<Object>> multivaluedAttributes = MultivaluedPersonAttributeUtils.toMultivaluedMap(attributes);
        person.setAttributes(multivaluedAttributes);
        person.setAttribute(OVERRIDDEN_ATTRIBUTES, multivaluedAttributes.keySet());
    }
View Full Code Here

        //Remove the IPerson attribute override, bit of a hack as we really just remove all overrides
        //then re-add all attributes from person directory
        final PortletRequest portletRequest = (PortletRequest)externalContext.getNativeRequest();
        final HttpServletRequest portalRequest = this.portalRequestUtils.getOriginalPortalRequest(portletRequest);
       
        final IPerson person = this.personManager.getPerson(portalRequest);

        final Set<String> overriddenAttributes = (Set<String>)person.getAttribute(OVERRIDDEN_ATTRIBUTES);
        if (overriddenAttributes != null) {
            person.setAttribute(OVERRIDDEN_ATTRIBUTES, null);
           
            for (final String attribute : overriddenAttributes) {
                person.setAttribute(attribute, null);
            }
        }
       
        final IPersonAttributes originalUserAttributes = this.getOriginalUserAttributes(uid);
        final Map<String, List<Object>> attributes = originalUserAttributes.getAttributes();
        person.setAttributes(attributes);
    }
View Full Code Here

        this.userPreferencesManager = manager;
       
       
        final String sessionId = httpSession.getId();
       
        final IPerson person = this.userPreferencesManager.getPerson();
        final String personId = Integer.toString(person.getID());
       
        final UserProfile currentProfile = this.userPreferencesManager.getCurrentProfile();
        final String layoutId = Integer.toString(currentProfile.getLayoutId());

        this.channelContext = this.getChannelJndiContext(sessionId, personId, layoutId);
       
       
        final EntityIdentifier personEntityIdentifier = person.getEntityIdentifier();
        this.authorizationPrincipal = AuthorizationService.instance().newPrincipal(personEntityIdentifier.getKey(), personEntityIdentifier.getType());
    }
View Full Code Here

            catch (PortalException pe) {
                log.warn("Failed to load IUserLayoutChannelDescription and parent IUserLayoutNodeDescription for channel with subscribe id: " + channelSubscribeId, pe);
            }

            // Tell the StatsRecorder that this channel has rendered
            final IPerson person = userPreferencesManager.getPerson();
            final UserProfile userProfile = userPreferencesManager.getCurrentProfile();
            final long renderTime = cr.getRenderTime();
            final boolean renderedFromCache = cr.isRenderedFromCache();
           
            final ChannelRenderedInLayoutPortalEvent channelRenderedEvent = new ChannelRenderedInLayoutPortalEvent(this, person, userProfile, channelDesc, parentNode, renderTime, renderedFromCache);
View Full Code Here

                if (channel == null) {
                    throw new IllegalStateException("ChannelFactory returned null on request to instantiate layout channel with id [" + sessionId + "] and description [" + channelDescription + "]");
                }

                final IPerson person = userPreferencesManager.getPerson();
               
                final ApplicationEventPublisher applicationEventPublisher = EventPublisherLocator.getApplicationEventPublisher();
                final UserProfile currentProfile = userPreferencesManager.getCurrentProfile();
               
                IUserLayoutNodeDescription parentNode = null;
View Full Code Here

            }
            catch (PortalException pe) {
                log.warn("Failed to load IUserLayoutChannelDescription and parent IUserLayoutNodeDescription for channel with subscribe id: " + channelTarget, pe);
            }

            final IPerson person = userPreferencesManager.getPerson();
           
            // Tell StatsRecorder that a user has interacted with the channel
            if (channelDesc != null) {
                final ApplicationEventPublisher applicationEventPublisher = EventPublisherLocator.getApplicationEventPublisher();
                final UserProfile currentProfile = userPreferencesManager.getCurrentProfile();
                applicationEventPublisher.publishEvent(new ChannelTargetedInLayoutPortalEvent(this, person, currentProfile, channelDesc, parentNode));
            }

           
            final Map<String, Object[]> channelParameters = channelParameterManager.getChannelParameters(request, channelTarget);
            if (channelParameters != null) {
                targetParams = new HashMap<String, Object>(channelParameters);
            }
            else {
                targetParams = null;
            }
           
            if(channelParameters != null && channelParameters.size() > 0) {
                // only do grouped rendering if there are some parameters passed
                // to the target channel.
                // detect if channel target talks to other channels
                groupedRendering = hasListeningChannels(channelTarget);
            }

            IChannel channel;
            if ((channel=channelTable.get(channelTarget)) == null) {
                try {
                    channel=instantiateChannel(request, response, channelTarget);
                } catch (Throwable e) {
          if (person.isGuest() == true)
          {
            // We get this alot when people's sessions have timed out and they get directed
            // to the guest page. Changed to WARN because there might be a need to note this
            // to diagnose problems with the guest layout.

            log.warn("unable to pass find/create an instance of a channel. Bogus Id ? ! (id='"+channelTarget+"').");
          }else{
            log.error("unable to pass find/create an instance of a channel. Bogus Id ? ! (id='"+channelTarget+"' uid='"+person.getID()+"').",e);
          }
                    channel=replaceWithErrorChannel(request, response, channelTarget, ErrorCode.SET_STATIC_DATA_EXCEPTION, e, null, false);
                }
            }
        }
View Full Code Here

        catch (PortalException pe) {
            log.warn("Failed to load IUserLayoutChannelDescription and parent IUserLayoutNodeDescription for channel with subscribe id: " + channelSubscribeId, pe);
        }
       
        // Tell the StatsRecorder that this channel has rendered
        final IPerson person = userPreferencesManager.getPerson();
        final UserProfile userProfile = userPreferencesManager.getCurrentProfile();
        final long renderTime = channelRenderer.getRenderTime();
       
        final PortletActionInLayoutPortalEvent portletActionEvent = new PortletActionInLayoutPortalEvent(this, person, userProfile, channel, parentNode, renderTime);
        EventPublisherLocator.getApplicationEventPublisher().publishEvent(portletActionEvent);
View Full Code Here

TOP

Related Classes of org.jasig.portal.security.IPerson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.