Examples of UserHandler


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

        // TODO Change to KeyManager usage
        final String type = (String)parameters.get("type");
        final Configuration config = (Configuration) parameters.get("config");
        final String profileType = (String)parameters.get("profiletype");
        final String postFix = (load ? "load" : "save");
        final UserHandler handler = (UserHandler)parameters.get("handler");
       
        String uri = null;
        if (type == null) {
            uri = config.getChild(profileType + "-" + postFix).getAttribute("uri");
        } else if (type.equals("global")) {
            uri = config.getChild(profileType + "-global-" + postFix).getAttribute("uri");
        } else if (type.equals("role")) {
            uri = config.getChild(profileType + "-role-" + postFix).getAttribute("uri");
        } else if (type.equals("user")) {
            uri = config.getChild(profileType + "-user-" + postFix).getAttribute("uri");
        }

        Map key = new LinkedMap();
        key.put("baseuri", uri);
        key.put("separator", "?");
        key.put("portal", service.getPortalName());
        key.put("layout", layoutKey);
        if ( type != null ) {
            key.put("type", type);
            if ( "role".equals(type) || "user".equals(type)) {
                key.put("role", handler.getContext().getContextInfo().get("role"));
            }
            if ( "user".equals(type) ) {
                key.put("user", handler.getUserId());
            }
        }
        return key;
    }
View Full Code Here

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

            } finally {
                this.manager.release( authManager );
            }
           
            if ( null != state ) {
                UserHandler handler = state.getHandler();
                if ( handler != null ) {
                    context = handler.getContext();
                }
            }
        }
        return context;
    }
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to authenticate: " + handlerName);
        }
        // are we already logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        if ( handler != null ) {
            throw new ProcessingException("User is already authenticated using handler: " + handlerName);
        }
       
        Authenticator authenticator = this.lookupAuthenticator( config );
        try {
            Authenticator.AuthenticationResult result = authenticator.authenticate( config, parameters );
            if ( result != null && result.valid ) {
                AuthenticationContext authContext = new AuthenticationContext(this.context, this.xpathProcessor, this.resolver);
                handler = new UserHandler(config, authContext);
                // store the authentication data in the context
                authContext.init(result.result);
            } else if ( result != null ) {
                // now set the failure information in the temporary context
                ContextManager contextManager = null;
                try {
                    contextManager = (ContextManager) this.manager.lookup( ContextManager.ROLE );
                    SessionContext temp = contextManager.getContext( SessionConstants.TEMPORARY_CONTEXT );
                   
                    final DocumentFragment fragment = result.result.createDocumentFragment();
                    final Node root = result.result.getDocumentElement();
                    root.normalize();
                    Node child;
                    boolean appendedNode = false;
                    while (root.hasChildNodes() ) {
                        child = root.getFirstChild();
                        root.removeChild(child);
                        // Leave out empty text nodes before any other node
                        if (appendedNode
                            || child.getNodeType() != Node.TEXT_NODE
                            || child.getNodeValue().trim().length() > 0) {
                            fragment.appendChild(child);
                            appendedNode = true;
                        }
                    }
                    temp.appendXML("/", fragment);
                } catch ( ServiceException se ) {
                    throw new ProcessingException("Unable to lookup session manager.", se);
                } finally {
                    this.manager.release( contextManager );
                }
               
            }
           
        } finally {
            this.releaseAuthenticator( authenticator, config );
        }
       
        if ( handler != null ) {
            // create UserStatus
            final UserState status = this.createUserState();
       
            status.addHandler( handler );       
            this.updateUserState();
       
            // update RequestState
            RequestState state = new RequestState( handler, applicationName);
            this.setState( state );
            state.initialize( this.resolver );
           
            // And now load applications
            Iterator applications = handler.getHandlerConfiguration().getApplications().values().iterator();

            while ( applications.hasNext() ) {
                ApplicationConfiguration appHandler = (ApplicationConfiguration)applications.next();
                if ( !appHandler.getLoadOnDemand() ) {
                    handler.getContext().loadApplicationXML( appHandler, this.resolver );
                }
            }
        }
       
     return handler;
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to check: " + handlerName);
        }
        // are we already logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        final boolean authenticated = ( handler != null );
        if ( !authenticated ) {
            if (redirector != null) {
                // create parameters
                SourceParameters parameters = config.getRedirectParameters();
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to logout: " + handlerName);
        }
        // are we logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        // we don't throw an exception if we are already logged out!
        if ( handler != null ) {
           
            // Do we save something on logout?
            /*
           
            if ( config.saveOnLogout()
                 && config.getSaveResource() != null) {
                final AuthenticationContext authContext = handler.getContext();
                try {
                    // This might not work, because of the missing state
                    authContext.saveXML("/authentication",
                                    null,
                                    ContextHelper.getObjectModel(this.context),
                                    this.resolver, this.manager);
                } catch (Exception ignore) {
                    // we don't want to stop the logout process
                    // because of errors during save
                    this.getLogger().error("Exception while saving authentication information.", ignore);
                }
            }
            // save applications (if configured)
            Iterator iter = config.getApplications().values().iterator();
            while ( iter.hasNext() ) {
                ApplicationConfiguration appConfig = (ApplicationConfiguration) iter.next();
                if ( appConfig.saveOnLogout()
                     && appConfig.getSaveResource() != null ) {
                     // ???
                }
            }
            */
            // notify the authenticator
            try {
                this.lookupAuthenticator(config).logout(handler);
            } catch (Exception ignore) {
                // we really ignore any exception!
            }
           
            List applicationContexts = handler.getApplicationContexts();
            if ( applicationContexts != null ) {
                ContextManager contextManager = null;

                try {
                    contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE);
View Full Code Here

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

    public SessionContext createApplicationContext(String name,
                                                   String loadURI,
                                                   String saveURI)
    throws ProcessingException {
        RequestState state = this.getState();
        UserHandler handler = state.getHandler();
       
        SessionContext context = null;

        if ( handler != null ) {
            ContextManager contextManager = null;
            try {
                contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE);
                // create new context
                context = contextManager.createContext(name, loadURI, saveURI);
                handler.addApplicationContext( name );

            } catch (ServiceException ce) {
                throw new ProcessingException("Unable to create session context.", ce);
            } catch (IOException ioe) {
                throw new ProcessingException("Unable to create session context.", ioe);
View Full Code Here

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

        }
       
        this.xmlConsumer.startDocument();
        if ( state != null ) {
            try {
                UserHandler userhandler = state.getHandler();
               
                Configuration conf = state.getModuleConfiguration("single-role-user-management");
                if (conf == null) {
                    throw new ProcessingException("Module configuration 'single-role-user-management' for authentication user management generator not found.");
                }
                UserManagementHandler handler = new UserManagementHandler(conf,
                                                                          state.getApplicationName());
                this.showConfiguration(this.xmlConsumer, this.source, handler, userhandler.getContext());
           
            } catch (ConfigurationException ex) {
                throw new ProcessingException("ConfigurationException: " + ex, ex);
            }
        }
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to authenticate: " + handlerName);
        }
        // are we already logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        if ( handler != null ) {
            throw new ProcessingException("User is already authenticated using handler: " + handlerName);
        }
       
        // This could be made pluggable, if required
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to check: " + handlerName);
        }
        // are we already logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        final boolean authenticated = ( handler != null );
        if ( !authenticated ) {
            // create parameters
            SourceParameters parameters = config.getRedirectParameters();
            if (parameters == null) parameters = new SourceParameters();
View Full Code Here

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

        HandlerConfiguration config = this.getHandlerConfiguration( handlerName );
        if ( config == null ) {
            throw new ProcessingException("Unknown handler to logout: " + handlerName);
        }
        // are we logged in?
        UserHandler handler = this.getUserHandler( handlerName );
        // we don't throw an exception if we are already logged out!
        if ( handler != null ) {
            handler.terminate();
            UserState status = this.getUserState();
            status.removeHandler( handlerName );
            this.updateUserState();

            // handling of session termination
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.