Package org.apache.cocoon.webapps.authentication.user

Examples of org.apache.cocoon.webapps.authentication.user.RequestState


       
            status.addHandler( handler );       
            this.updateUserState();
       
            // update RequestState
            RequestState state = new RequestState( handler, applicationName, this.resolver );
            RequestState.setState( state );
        }
       
     return (handler != null);
  }
View Full Code Here


            parameters.setSingleParameterValue("resource", resource);
            final String redirectURI = config.getRedirectURI();
            redirector.globalRedirect(false, SourceUtil.appendParameters(redirectURI, parameters));
        } else {
            // update state
            RequestState state = new RequestState( handler, applicationName, this.resolver );
            RequestState.setState( state );
        }
       
    return authenticated;
  }
View Full Code Here

        }

        // logout
        Manager authManager = null;
        try {
            RequestState state = RequestState.getState();
           
            authManager = (Manager) this.manager.lookup(Manager.ROLE);
            final String handlerName = par.getParameter("handler",
                                                         (state == null ? null : state.getHandlerName()));
            if ( null == handlerName )
                throw new ProcessingException("LogoutAction requires at least the handler parameter.");
            authManager.logout( handlerName , mode );
        } finally {
            this.manager.release( (Component)authManager );
View Full Code Here

    private String          applicationName;

    public AuthenticationContext() {
        this.name = AuthenticationConstants.SESSION_CONTEXT_NAME;

        RequestState state = RequestState.getState();
        this.handler = state.getHandler();
        this.handlerName = this.handler.getHandlerName();
        this.applicationName = state.getApplicationName();
        try {
            this.authContext = new SimpleSessionContext();
        } catch (ProcessingException pe) {
            throw new CascadingRuntimeException("Unable to create simple context.", pe);
        }
View Full Code Here

                                            SourceResolver   resolver,
                                            ComponentManager manager)
    throws ProcessingException {
        SessionContext context = null;
        if (name.equals(org.apache.cocoon.webapps.authentication.AuthenticationConstants.SESSION_CONTEXT_NAME) ) {
            RequestState state = RequestState.getState();
            if ( null != state ) {
                UserHandler handler = state.getHandler();
                if ( handler != null ) {
                    context = handler.getContext();
                }
            }
        }
View Full Code Here

        Manager authManager = null;

        try {
            authManager = (Manager) this.manager.lookup(Manager.ROLE);
            if (authManager.isAuthenticated(handlerName) ) {
                RequestState state = RequestState.getState();
                map = state.getHandler().getContext().getContextInfo();
            }
        } finally {
            this.manager.release( (Component)authManager);
        }
View Full Code Here

            // do authentication
            if ( !authManager.checkAuthentication(redirector, handlerName, applicationName) ) {
                // All events are ignored
                // the sitemap.xsl ensures that only the redirect is processed
            } else {
                RequestState state = RequestState.getState();
                map = state.getHandler().getContext().getContextInfo();
            }
        } finally {
            this.manager.release( (Component)authManager );
        }
        if (this.getLogger().isDebugEnabled() ) {
View Full Code Here

                        DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets").appendChild(coplet);
                    } else if (command.equals("save") ) {

                        SourceParameters pars = new SourceParameters();
                        pars.setSingleParameterValue("profile", "coplet-base");
                        RequestState state = this.getRequestState();
                        pars.setSingleParameterValue("application", state.getApplicationName());
                        pars.setSingleParameterValue("handler", state.getHandlerName());

                        String saveResource = (String)configuration.get(PortalConstants.CONF_COPLETBASE_SAVE_RESOURCE);

                        if (saveResource == null) {
                            throw new ProcessingException("portal: No save resource defined for type coplet-base.");
                        } else {
                           
                            SourceUtil.writeDOM(saveResource,
                                                null,
                                                pars,
                                                copletsFragment,
                                                this.resolver,
                                                "xml");

                            // now the hardest part, clean up the whole cache
                            this.cleanUpCache(null, null, configuration);
                        }
                    }
                } finally {
                    this.getTransactionManager().stopWritingTransaction(context);
                }
            }

            // general commands
            if (command != null && command.equals("cleancache") ) {
                this.cleanUpCache(null, null, configuration);
            }

            String state = this.request.getParameter(PortalManager.REQ_PARAMETER_STATE);
            if (state == null) {
                state = (String)context.getAttribute(ATTRIBUTE_ADMIN_STATE, PortalConstants.STATE_MAIN);
            }

            // now start producing xml:
            AttributesImpl attr = new AttributesImpl();
            consumer.startElement("", PortalConstants.ELEMENT_ADMINCONF, PortalConstants.ELEMENT_ADMINCONF, attr);

            context.setAttribute(ATTRIBUTE_ADMIN_STATE, state);
            consumer.startElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE, attr);
            consumer.characters(state.toCharArray(), 0, state.length());
            consumer.endElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE);

            if (state.equals(PortalConstants.STATE_MAIN) ) {

                Document rolesDF = this.getRoles();
                Node     roles   = null;
                if (rolesDF != null) roles = DOMUtil.getSingleNode(rolesDF, "roles");
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);
            }

            if (state.equals(PortalConstants.STATE_MAIN_ROLE) ) {

                Document rolesDF = this.getRoles();
                Node     roles   = null;
                if (rolesDF != null) roles = DOMUtil.getSingleNode(rolesDF, "roles");
                IncludeXMLConsumer.includeNode(roles, consumer, consumer);

                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null) {
                    this.sendStartElementEvent(consumer, "roleusers");
                    this.sendStartElementEvent(consumer, "name");
                    this.sendTextEvent(consumer, role);
                    this.sendEndElementEvent(consumer, "name");
                    Document userDF = this.getUsers(role, null);
                    Node     users = null;
                    if (userDF != null) users = DOMUtil.getSingleNode(userDF, "users");
                    IncludeXMLConsumer.includeNode(users, consumer, consumer);
                    this.sendEndElementEvent(consumer, "roleusers");
                }
            }

            if (state.equals(PortalConstants.STATE_GLOBAL)) {
                profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, true);
                Map profile = this.retrieveProfile(profileID);
                if (profile == null) {
                    this.createProfile(context, PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, true);
                    profile = this.retrieveProfile(profileID);
                }
                this.showPortal(consumer, true, context, profile, profileID);
            }

            if (state.equals(PortalConstants.STATE_ROLE) ) {
                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null) {
                    consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
                    profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, PortalManager.BUILDTYPE_VALUE_ROLE, role, null, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            if (state.equals(PortalConstants.STATE_USER) ) {
                String role = this.request.getParameter(PortalManager.REQ_PARAMETER_ROLE);
                String id   = this.request.getParameter(PortalManager.REQ_PARAMETER_ID);
                if (role == null) {
                    role = (String)context.getAttribute(ATTRIBUTE_ADMIN_ROLE);
                }
                if (id == null) {
                    id = (String)context.getAttribute(ATTRIBUTE_ADMIN_ID);
                }
                context.setAttribute(ATTRIBUTE_ADMIN_ID, id);
                context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
                if (role != null && id != null) {
                    consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
                    consumer.characters(role.toCharArray(), 0, role.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
                    consumer.startElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID, attr);
                    consumer.characters(id.toCharArray(), 0, id.length());
                    consumer.endElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID);

                    profileID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ID, role, id, true);
                    Map profile = this.retrieveProfile(profileID);
                    if (profile == null) {
                        this.createProfile(context, PortalManager.BUILDTYPE_VALUE_ID, role, id, true);
                        profile = this.retrieveProfile(profileID);
                    }
                    this.showPortal(consumer, true, context, profile, profileID);
                }
            }
            // one coplet
            if (state.equals(PortalConstants.STATE_COPLET) ) {
                if (copletsFragment != null && copletID != null) {
                    Node coplet = DOMUtil.getSingleNode(copletsFragment, "coplets-profile/coplets/coplet[@id='"+copletID+"']");
                    if (coplet != null) {
                        IncludeXMLConsumer.includeNode(coplet, consumer, consumer);
                    }
                } else {
                    state = PortalConstants.STATE_COPLETS;
                }
            }
            if (state.equals(PortalConstants.STATE_COPLETS) ) {
                consumer.startElement("", PortalConstants.ELEMENT_COPLETS, PortalConstants.ELEMENT_COPLETS, attr);

                // load the base coplets profile
                if (copletsFragment == null) {
                    SourceParameters pars = new SourceParameters();
                    RequestState reqstate = this.getRequestState();
                    pars.setSingleParameterValue("application", reqstate.getApplicationName());
                    String res = (String)configuration.get(PortalConstants.CONF_COPLETBASE_RESOURCE);
                    if (res == null) {
                        throw new ProcessingException("No configuration for portal-coplet base profile found.");
                    }
                    copletsFragment = SourceUtil.readDOM(res,
View Full Code Here

                                String id,
                                boolean adminProfile)
    throws ProcessingException {
        // No sync required
        StringBuffer key = new StringBuffer((adminProfile ? "aprofile:" : "uprofile:"));
        RequestState reqstate = this.getRequestState();
        key.append(reqstate.getHandlerName())
           .append('|')
           .append(reqstate.getApplicationName())
           .append(':')
           .append(type);

        if (type.equals(PortalManager.BUILDTYPE_VALUE_ROLE)
            || type.equals(PortalManager.BUILDTYPE_VALUE_ID)) {
View Full Code Here

        // synchronized
        if (this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("BEGIN getConfiguration");
        }
        Map result = null;
        RequestState reqstate = this.getRequestState();
        String appName = reqstate.getApplicationName();
        String handlerName = reqstate.getHandlerName();
        Session session = this.getSessionManager().getSession(false);
        if (session != null && appName != null && handlerName != null) {

            synchronized (session) {
                result = (Map)session.getAttribute(PortalConstants.ATTRIBUTE_CONFIGURATION + handlerName + ':' + appName);
                if (result == null) {

                    try {
                        Configuration config;

                        Configuration conf = reqstate.getModuleConfiguration(PortalConstants.AUTHENTICATION_MODULE_NAME);
                        if (conf == null) {
                            throw new ProcessingException("portal: Configuration for application '" + appName + "' not found.");
                        }
                        result = new HashMap(10, 2);
                        // auth-redirect (optional)
View Full Code Here

TOP

Related Classes of org.apache.cocoon.webapps.authentication.user.RequestState

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.