Examples of UserHandler


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

            }
           
            String portalPrefix = "/"+service.getPortalName();

      // TODO Change to KeyManager usage
      UserHandler handler = RequestState.getState().getHandler();
      HashMap map = new HashMap();
      map.put("portalname", service.getPortalName());
      map.put("user", handler.getUserId());
      map.put("role", handler.getContext().getContextInfo().get("role"));

      // load coplet base data
      map.put("profile", "copletbasedata");
      map.put("objectmap", null);
      Object[] result = this.getProfile(map, portalPrefix+"/CopletBaseData", service);
View Full Code Here

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

        String attribute = null;
        try {
            service = (PortalService) this.manager.lookup(PortalService.ROLE);

      // TODO Change to KeyManager usage
      UserHandler handler = RequestState.getState().getHandler();
      attribute = SimpleProfileManager.class.getName()+"/"+service.getPortalName()+"/CopletInstanceData-user-"+handler.getUserId();

/*       TODO Must be changed for dynamic coplet creation.          
       if (null == coplets) {
                coplets = new HashMap();
View Full Code Here

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

        this.xmlConsumer.startDocument();
        RequestState state = RequestState.getState();
        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

    throws ProcessingException {
        AuthenticationContext 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();
                }
            }
        }
        return context;
    }
View Full Code Here

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

            exceptionMsg = local.getMessage();
        }

        // test if authentication was successful
        boolean isValid = false;
        UserHandler handler = null;
        if (doc != null) {
            isValid = this.isValidAuthenticationFragment( doc );

            if ( isValid ) {
                if (this.getLogger().isInfoEnabled() ) {
                    this.getLogger().info("Authenticator: User authenticated using handler '" + configuration.getName()+"'");
                }
               
                handler = new UserHandler(configuration);
               
                AuthenticationContext 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.init(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;
                        }
                    }
View Full Code Here

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

                                CopletFactory copletFactory,
                                LayoutFactory layoutFactory,
                                ServiceSelector adapterSelector)
    throws Exception {
        final RequestState state = this.getRequestState();
        final UserHandler handler = state.getHandler();
        final ApplicationConfiguration ac = state.getApplicationConfiguration();       
        if ( ac == null ) {
            throw new ProcessingException("Configuration for portal not found in application configuration.");
        }
        final Configuration appConf = ac.getConfiguration("portal");
View Full Code Here

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

            if (layoutKey == null) {
                layoutKey = service.getDefaultLayoutKey();
            }

            final RequestState state = this.getRequestState();
            final UserHandler handler = state.getHandler();

            final HashMap parameters = new HashMap();
            parameters.put("type", "user");
            parameters.put("config", state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
            parameters.put("handler", handler);
View Full Code Here

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

            if ( layoutKey == null ) {
                layoutKey = service.getDefaultLayoutKey();
            }

            final RequestState state = this.getRequestState();
            final UserHandler handler = state.getHandler();

            final HashMap parameters = new HashMap();
            parameters.put("type", "user");
            parameters.put("config", state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
            parameters.put("handler", handler);
View Full Code Here

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

        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);
                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
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.