Examples of SessionContext


Examples of org.apache.cocoon.webapps.session.context.SessionContext

        if (path == null) {
            throw new ProcessingException("SessionManager.removeContextFragment: Path is required");
        }

        // get context
        SessionContext context = this.getContext(contextName);

        // check context
        if (context == null) {
            throw new ProcessingException("SessionManager.removeContextFragment: Context '" + contextName + "' not found.");
        }

        context.removeXML(path);

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END removeContextFragment");
        }
    }
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

        if (formName == null) {
            throw new ProcessingException("SessionManager.registerInputField: Form is required");
        }

        DocumentFragment value = null;
        SessionContext context = this.getContext(contextName);
        if (context == null) {
            throw new ProcessingException("SessionManager.registerInputField: Context not found " + contextName);
        }
        Session session = this.getSession(false);
        if (session == null) {
            throw new ProcessingException("SessionManager.registerInputField: Session is required for context " + contextName);
        }

        synchronized(session) {
            Map inputFields = (Map)session.getAttribute(SessionManager.ATTRIBUTE_INPUTXML_STORAGE);
            if (inputFields == null) {
                inputFields = new HashMap(10);
                session.setAttribute(SessionManager.ATTRIBUTE_INPUTXML_STORAGE, inputFields);
            }
            inputFields.put(name, new Object[] {context, path, formName});
            value = context.getXML(path);
        }

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END registerInputField value="+value);
        }
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

                            currentKey = (String)keys.nextElement();
                            if (inputFields.containsKey(currentKey) == true) {
                                contextAndPath = (Object[])inputFields.get(currentKey);
                                inputFields.remove(currentKey);

                                SessionContext context = (SessionContext)contextAndPath[0];
                                String path            = (String)contextAndPath[1];

                                if (formName.equals(contextAndPath[2]) == true) {
                                    context.setXML(path,
                                                 this.getContextFragment(SessionConstants.REQUEST_CONTEXT, "/parameter/"+currentKey));
                                }
                            }
                        }
                    }
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

     *  The session context with the given name is returned. If the context does
     *  not exist <CODE>null</CODE> is returned.
     */
    public synchronized SessionContext getContext(String name)
    throws ProcessingException {
        SessionContext context;
        if (SessionManager.isReservedContextName(name) == true) {
            context = this.getReservedContext(name);
        } else {
            Session session = this.getSession(false);
            if (session == null) {
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

                    this.getLogger().info("Authenticator: User authenticated using handler '" + configuration.getName()+"'");
                }
               
                handler = new UserHandler(configuration);
               
                SessionContext context = handler.getContext();

                MediaManager mediaManager = null;
                String mediaType;
                try {
                    mediaManager = (MediaManager)this.manager.lookup( MediaManager.ROLE );
                    mediaType = mediaManager.getMediaType();
                } catch (ServiceException se) {
                    throw new ProcessingException("Unable to lookup media manager.", se);
                } finally {
                    this.manager.release( mediaManager );
                }
                synchronized(context) {
                    // add special nodes to the authentication block:
                    // useragent, type and media
                    Element specialElement;
                    Text    specialValue;
                    Element authNode;

                    authNode = (Element)doc.getFirstChild();

                    specialElement = doc.createElementNS(null, "type");
                    specialValue = doc.createTextNode("cocoon.authentication");
                    specialElement.appendChild(specialValue);
                    authNode.appendChild(specialElement);

                    specialElement = doc.createElementNS(null, "media");
                    specialValue = doc.createTextNode(mediaType);
                    specialElement.appendChild(specialValue);
                    authNode.appendChild(specialElement);

                    // store the authentication data in the context
                    context.setNode("/" + configuration.getName(), doc);

                    // And now load applications
                    boolean loaded = true;
                    Iterator applications = configuration.getApplications().values().iterator();

                    while ( applications.hasNext() ) {
                        ApplicationConfiguration appHandler = (ApplicationConfiguration)applications.next();
                        if ( !appHandler.getLoadOnDemand() ) {
                            handler.getContext().loadApplicationXML( appHandler, this.resolver );
                        } else {
                            loaded = false;
                        }
                    }

                } // end sync
            }
        }
       
        if ( !isValid ) {
            if (this.getLogger().isInfoEnabled() ) {
                this.getLogger().info("Authenticator: Failed authentication using handler '" +  configuration.getName()+"'");
            }
            // get the /authentication/data Node if available
            Node data = null;

            if (doc != null) {
                data = DOMUtil.getFirstNodeFromPath(doc, new String[] {"authentication","data"}, false);
            }

            // now create the following xml:
            // <failed/>
            // if data is available data is included, otherwise:
            // <data>No information</data>
            // If exception message contains info, it is included into failed
            DocumentFragment authenticationFragment = doc.createDocumentFragment();

            Element element = doc.createElementNS(null, "failed");
            authenticationFragment.appendChild(element);

            if (exceptionMsg != null) {
                Text text = doc.createTextNode(exceptionMsg);
                element.appendChild(text);
            }

            if (data == null) {
                element = doc.createElementNS(null, "data");
                authenticationFragment.appendChild(element);
                Text text = doc.createTextNode("No information");
                element.appendChild(text);
            } else {
                authenticationFragment.appendChild(doc.importNode(data, true));
            }
           
            // now set this information in the temporary context
            SessionManager sessionManager = null;
            try {
                sessionManager = (SessionManager) this.manager.lookup( SessionManager.ROLE );
                SessionContext temp = sessionManager.getContext( SessionConstants.TEMPORARY_CONTEXT );
                temp.appendXML("/", authenticationFragment);
            } catch ( ServiceException se ) {
                throw new ProcessingException("Unable to lookup session manager.", se);
            } finally {
                this.manager.release( sessionManager );
            }
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

                    }
                    // create session object if necessary, context etc and get it
                    if (this.getLogger().isDebugEnabled() == true) {
                        this.getLogger().debug("creating session");
                    }
                    SessionContext context = this.getAuthenticationSessionContext(true);
                    if (this.getLogger().isDebugEnabled() == true) {
                        this.getLogger().debug("session created");
                    }

                    myHandler = this.handlerManager.storeUserHandler(myHandler,
                                                                     this.request);

                    synchronized(context) {
                        // add special nodes to the authentication block:
                        // useragent, type and media
                        Element specialElement;
                        Text    specialValue;
                        Element authNode;

                        authNode = (Element)authenticationFragment.getFirstChild();
                        specialElement = authenticationFragment.getOwnerDocument().createElementNS(null, "useragent");
                        specialValue = authenticationFragment.getOwnerDocument().createTextNode(request.getHeader("User-Agent"));
                        specialElement.appendChild(specialValue);
                        authNode.appendChild(specialElement);

                        specialElement = authenticationFragment.getOwnerDocument().createElementNS(null, "type");
                        specialValue = authenticationFragment.getOwnerDocument().createTextNode("cocoon.authentication");
                        specialElement.appendChild(specialValue);
                        authNode.appendChild(specialElement);

                        specialElement = authenticationFragment.getOwnerDocument().createElementNS(null, "media");
                        specialValue = authenticationFragment.getOwnerDocument().createTextNode(this.mediaType);
                        specialElement.appendChild(specialValue);
                        authNode.appendChild(specialElement);

                        // store the authentication data in the context
                        context.setXML("/" + myHandler.getName(), authenticationFragment);

                        // Now create the return value for this method:
                        // <code>null</code>
                        authenticationFragment = null;
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

    throws ProcessingException {
        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN getAuthenticationSessionContext create=" + create);
        }
        SessionContext context = null;

        Session session = this.getSessionManager().getSession(create);
        if (session != null) {
            synchronized(session) {
                context = (SessionContext)session.getAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_CONTEXT_NAME);
                if (context == null && create == true) {
                    context = new SimpleSessionContext();
                    context.setup(AuthenticationConstants.SESSION_CONTEXT_NAME, null, null);
                    session.setAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_CONTEXT_NAME, context);
                }
            }
        }
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

        // synchronized via context
        if (this.getLogger().isDebugEnabled() ) {
            this.getLogger().debug("BEGIN logout handler=" + logoutHandlerName +
                                   ", mode="+mode);
        }
        SessionContext context = this.getAuthenticationSessionContext(false);

        if (context != null && logoutHandlerName != null) {

            // remove context
            context.removeXML(logoutHandlerName);
            // FIXME (CZ): The sessionContextImpl should not be null, but
            //             it is sometimes. Why?
            SessionContextImpl sessionContextImpl = (SessionContextImpl)
                        (this.getSessionManager().getContext(AuthenticationConstants.SESSION_CONTEXT_NAME));
            if (sessionContextImpl != null) {
                sessionContextImpl.cleanParametersCache(logoutHandlerName);
            } else if (this.getLogger().isWarnEnabled()) {
                this.getLogger().warn("AuthenticationManager:logout() - sessionContextImpl is null");
            }
            Handler logoutHandler = (Handler)this.getHandler(logoutHandlerName);

            final List handlerContexts = logoutHandler.getHandlerContexts();
            final Iterator iter = handlerContexts.iterator();
            while ( iter.hasNext() ) {
                final SessionContext deleteContext = (SessionContext) iter.next();
                this.getSessionManager().deleteContext( deleteContext.getName() );
            }
            logoutHandler.clearHandlerContexts();
            this.handlerManager.removeUserHandler( logoutHandler, this.request );
            if (logoutHandlerName.equals(this.handlerName)) {
                this.handlerName = null;
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

        // synchronized
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN createHandlerContext name="+name);
        }

        SessionContext context = null;

        if (this.handler != null) {

            final Session session = this.getSessionManager().getSession(false);
            synchronized(session) {
View Full Code Here

Examples of org.apache.cocoon.webapps.session.context.SessionContext

        // synchronized
        if (this.handler == null) {
            return new SourceParameters();
        }
        if (path == null) {
            SessionContext context = this.getAuthenticationSessionContext(false);
            SourceParameters pars = (SourceParameters)context.getAttribute("cachedparameters_" + this.handler.getName());
            if (pars == null) {
                 pars = this.createParameters(null, this.handlerName, path, this.applicationName);
                 context.setAttribute("cachedparameters_" + this.handler.getName(), pars);
            }
            return pars;
        }
        return this.createParameters(null, this.handlerName, path, this.applicationName);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.