cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication AuthenticationManager.java
Date Tue, 27 May 2003 12:19:30 GMT
cziegeler    2003/05/27 05:19:30

  Modified:    src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/user
                        UserHandler.java
               src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components
                        PortalManager.java
               src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components
                        DefaultAuthenticationManager.java
               src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication
                        AuthenticationManager.java
  Log:
  Correcting component handling
  
  Revision  Changes    Path
  1.8       +15 -72    cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/user/UserHandler.java
  
  Index: UserHandler.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/user/UserHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UserHandler.java	23 May 2003 15:04:04 -0000	1.7
  +++ UserHandler.java	27 May 2003 12:19:30 -0000	1.8
  @@ -50,22 +50,13 @@
   */
   package org.apache.cocoon.webapps.authentication.user;
   
  -import java.io.IOException;
   import java.util.ArrayList;
  -import java.util.Iterator;
   import java.util.List;
   
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
   import org.apache.cocoon.webapps.authentication.configuration.HandlerConfiguration;
   import org.apache.cocoon.webapps.authentication.context.AuthenticationContext;
  -import org.apache.cocoon.webapps.session.ContextManager;
  -import org.apache.cocoon.webapps.session.context.SessionContext;
  -import org.xml.sax.SAXException;
   
   /**
    * The authentication Handler.
  @@ -122,42 +113,6 @@
       }
   
       /**
  -     * Create Application Context.
  -     * This context is destroyed when the user logs out of the handler
  -     * FIXME - this should be moved into the Manager
  -     */
  -    public synchronized SessionContext createApplicationContext(String name,
  -                                                                  String loadURI,
  -                                                                 String saveURI)
  -    throws ProcessingException {
  -
  -        SessionContext context = null;
  -
  -        ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
  -        ContextManager contextManager = null;
  -        try {
  -            contextManager = (ContextManager)manager.lookup(ContextManager.ROLE);
  -            // create new context
  -            context = contextManager.createContext(name, loadURI, saveURI);
  -            if ( this.applicationContexts == null) {
  -                this.applicationContexts = new ArrayList(3);
  -            }
  -            this.applicationContexts.add( name );
  -
  -        } catch (ComponentException ce) {
  -            throw new ProcessingException("Unable to create session context.", ce);
  -        } catch (IOException ioe) {
  -            throw new ProcessingException("Unable to create session context.", ioe);
  -        } catch (SAXException saxe) {
  -            throw new ProcessingException("Unable to create session context.", saxe);
  -        } finally {
  -            manager.release( (Component)contextManager);
  -        }
  -
  -        return context;
  -    }
  -
  -    /**
        * Get the handler name
        */
       public String getHandlerName() {
  @@ -187,32 +142,6 @@
       }
       
       /**
  -     * Terminate the handler
  -     */
  -    public void terminate() 
  -    throws ProcessingException {
  -        ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
  -
  -        if ( this.applicationContexts != null ) {
  -            ContextManager contextManager = null;
  -
  -            try {
  -                contextManager = (ContextManager)manager.lookup(ContextManager.ROLE);
  -
  -                Iterator i = this.applicationContexts.iterator();
  -                while ( i.hasNext() ) {
  -                    final String current = (String)i.next();
  -                    contextManager.deleteContext( current );
  -                }
  -            } catch (ComponentException ce) {
  -                throw new ProcessingException("Unable to create session context.", ce);
  -            } finally {
  -                manager.release( (Component)contextManager);
  -            }
  -        }
  -    }
  -    
  -    /**
        * Get the unique user id
        */
       public String getUserId() {
  @@ -224,5 +153,19 @@
               }
           }
           return this.userID;
  +    }
  +    
  +    public void addApplicationContext(String name) {
  +        if ( this.applicationContexts == null) {
  +            this.applicationContexts = new ArrayList(3);
  +        }
  +        this.applicationContexts.add( name );
  +    }
  +    
  +    /**
  +     * Return the list or null.
  +     */
  +    public List getApplicationContexts() {
  +        return this.applicationContexts;
       }
   }
  
  
  
  1.6       +2 -2      cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManager.java
  
  Index: PortalManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PortalManager.java	23 May 2003 12:13:13 -0000	1.5
  +++ PortalManager.java	27 May 2003 12:19:30 -0000	1.6
  @@ -307,7 +307,7 @@
   
                       // create new context
                       
  -                    context = this.getRequestState().getHandler().createApplicationContext(attrName,
null, null);
  +                    context = this.getAuthenticationManager().createApplicationContext(attrName,
null, null);
   
                   }
               } // end synchronized
  
  
  
  1.12      +58 -2     cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java
  
  Index: DefaultAuthenticationManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultAuthenticationManager.java	23 May 2003 12:35:32 -0000	1.11
  +++ DefaultAuthenticationManager.java	27 May 2003 12:19:30 -0000	1.12
  @@ -51,6 +51,8 @@
   package org.apache.cocoon.webapps.authentication.components;
   
   import java.io.IOException;
  +import java.util.Iterator;
  +import java.util.List;
   import java.util.Map;
   
   import org.apache.avalon.framework.activity.Disposable;
  @@ -80,9 +82,11 @@
   import org.apache.cocoon.webapps.authentication.user.UserState;
   import org.apache.cocoon.webapps.session.ContextManager;
   import org.apache.cocoon.webapps.session.SessionManager;
  +import org.apache.cocoon.webapps.session.context.SessionContext;
   import org.apache.excalibur.source.SourceParameters;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.SourceUtil;
  +import org.xml.sax.SAXException;
   
   /**
    * This is the basis authentication component.
  @@ -305,7 +309,25 @@
           UserHandler handler = this.getUserHandler( handlerName );
           // we don't throw an exception if we are already logged out!
           if ( handler != null ) {
  -            handler.terminate();
  +            List applicationContexts = handler.getApplicationContexts();
  +            if ( applicationContexts != null ) {
  +                ContextManager contextManager = null;
  +
  +                try {
  +                    contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE);
  +
  +                    Iterator i = applicationContexts.iterator();
  +                    while ( i.hasNext() ) {
  +                        final String current = (String)i.next();
  +                        contextManager.deleteContext( current );
  +                    }
  +                } catch (ServiceException ce) {
  +                    throw new ProcessingException("Unable to create session context.",
ce);
  +                } finally {
  +                    this.manager.release( (Component)contextManager);
  +                }
  +            }
  +    
               UserState status = this.getUserState();
               status.removeHandler( handlerName );
               this.updateUserState();
  @@ -396,6 +418,40 @@
           }
       }
       
  +    /**
  +     * Create Application Context.
  +     * This context is destroyed when the user logs out of the handler
  +     */
  +    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);
  +            } catch (SAXException saxe) {
  +                throw new ProcessingException("Unable to create session context.", saxe);
  +            } finally {
  +                manager.release( (Component)contextManager);
  +            }
  +        }
  +
  +        return context;
  +    }
   
   }
   
  
  
  
  1.5       +11 -1     cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java
  
  Index: AuthenticationManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/AuthenticationManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AuthenticationManager.java	23 May 2003 12:13:15 -0000	1.4
  +++ AuthenticationManager.java	27 May 2003 12:19:30 -0000	1.5
  @@ -56,6 +56,7 @@
   import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.webapps.authentication.user.RequestState;
   import org.apache.cocoon.webapps.authentication.user.UserHandler;
  +import org.apache.cocoon.webapps.session.context.SessionContext;
   import org.apache.excalibur.source.SourceParameters;
   
   
  @@ -112,4 +113,13 @@
        * Get the current state of authentication
        */
       RequestState getState();
  +
  +    /**
  +     * Create Application Context.
  +     * This context is destroyed when the user logs out of the handler
  +     */
  +    SessionContext createApplicationContext(String name,
  +                                            String loadURI,
  +                                            String saveURI)
  +    throws ProcessingException;
   }
  
  
  

Mime
View raw message