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

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()+"'");
                }
               
                AuthenticationContext authContext = new AuthenticationContext(this.context);
                handler = new UserHandler(configuration, authContext);

                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(authContext) {
                    // 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
                    authContext.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


        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

        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

        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 ) {
            List applicationContexts = handler.getApplicationContexts();
            if ( applicationContexts != null ) {
                ContextManager contextManager = null;

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

    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

        try {
          map.put("portalname", service.getPortalName());
         
          // TODO Change to KeyManager usage
          RequestState state = this.getRequestState();
          UserHandler handler = state.getHandler();
          keyMap.put("user", handler.getUserId());
          keyMap.put("role", handler.getContext().getContextInfo().get("role"));
          keyMap.put("config", state.getApplicationConfiguration().getConfiguration("portal"));
         
          // load coplet base data
          map.put("profile", "copletbasedata");
          map.put("objectmap", null);
View Full Code Here

      map.put("portalname", service.getPortalName());
      map.put("type", "user");
       
      // TODO Change to KeyManager usage
            RequestState state = this.getRequestState();
      UserHandler handler = state.getHandler();
      HashMap key = new HashMap();
      key.put("user", handler.getUserId());
      key.put("role", handler.getContext().getContextInfo().get("role"));
      key.put("config", state.getApplicationConfiguration().getConfiguration("portal"));
 
      // save coplet instance data
      map.put("profile", "copletinstancedata");
      Object profile = ((Object[])service.getAttribute(portalPrefix+"/CopletInstanceData"))[0];
View Full Code Here

                                CopletFactory copletFactory,
                                LayoutFactory layoutFactory,
                                ComponentSelector adapterSelector)
    throws Exception {
        final RequestState state = this.getRequestState();
        final UserHandler handler = state.getHandler();
        final Configuration config = state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles");

        HashMap parameters = new HashMap();
        parameters.put("config", config);
        parameters.put("handler", handler);
View Full Code Here

    try {
      adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
      service = (PortalService) this.manager.lookup(PortalService.ROLE);
           
            RequestState state = this.getRequestState();
            UserHandler handler = state.getHandler();

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

        // 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 SequencedHashMap();
        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

TOP

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

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.