cziegeler    02/05/29 08:58:22

  Modified:    src/java/org/apache/cocoon/webapps/authentication
                        AuthenticationConstants.java
               src/java/org/apache/cocoon/webapps/authentication/components
                        AuthenticationManager.java HandlerManager.java
  Log:
  Minor updates to authentication manager
  
  Revision  Changes    Path
  1.2       +1 -4      
xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/AuthenticationConstants.java
  
  Index: AuthenticationConstants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/AuthenticationConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AuthenticationConstants.java      17 Apr 2002 10:04:52 -0000      1.1
  +++ AuthenticationConstants.java      29 May 2002 15:58:21 -0000      1.2
  @@ -55,7 +55,7 @@
    * framework.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: AuthenticationConstants.java,v 1.1 2002/04/17 10:04:52 
cziegeler Exp $
  + * @version CVS $Id: AuthenticationConstants.java,v 1.2 2002/05/29 15:58:21 
cziegeler Exp $
   */
   public interface AuthenticationConstants {
   
  @@ -65,9 +65,6 @@
   
       /** The name of the session attribute storing the context */
       String SESSION_ATTRIBUTE_CONTEXT_NAME = 
"org.apache.cocoon.webapps.authentication.SessionContext";
  -
  -    /** The name of the session attribute storing the handler configuration */
  -    String SESSION_ATTRIBUTE_HANDLERS = 
"org.apache.cocoon.webapps.authentication.Handlers";
   
       /** The name of the authentication context. */
       String SESSION_CONTEXT_NAME = "authentication";
  
  
  
  1.8       +6 -10     
xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java
  
  Index: AuthenticationManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AuthenticationManager.java        29 May 2002 15:38:09 -0000      1.7
  +++ AuthenticationManager.java        29 May 2002 15:58:21 -0000      1.8
  @@ -98,7 +98,7 @@
    *  This is the basis authentication component.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: AuthenticationManager.java,v 1.7 2002/05/29 15:38:09 cziegeler 
Exp $
  + * @version CVS $Id: AuthenticationManager.java,v 1.8 2002/05/29 15:58:21 cziegeler 
Exp $
   */
   public final class AuthenticationManager
   extends AbstractSessionComponent
  @@ -326,10 +326,10 @@
       throws ProcessingException {
           final Request req = ObjectModelHelper.getRequest( this.objectModel );
           final Session session = req.getSession();
  -        Map myHandlers = 
(Map)session.getAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_HANDLERS);
  +        Map myHandlers = 
(Map)session.getAttribute(HandlerManager.SESSION_ATTRIBUTE_HANDLERS);
           if (myHandlers == null) {
               this.userHandlers = this.configuredHandlers;
  -            
session.setAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_HANDLERS, 
this.userHandlers);
  +            session.setAttribute(HandlerManager.SESSION_ATTRIBUTE_HANDLERS, 
this.userHandlers);
               this.configuredHandlers = null;
               this.configureHandlers(this.configuration);
           }
  @@ -371,7 +371,7 @@
       }
   
       /**
  -     * Create a new context
  +     * Return the current handler
        */
       public Handler getHandler() {
           return this.handler;
  @@ -733,7 +733,7 @@
           final Request req = ObjectModelHelper.getRequest( this.objectModel );
           final Session session = req.getSession(false);
           if ( null != session ) {
  -            this.userHandlers = 
(Map)session.getAttribute(AuthenticationConstants.SESSION_ATTRIBUTE_HANDLERS);
  +            this.userHandlers = 
(Map)session.getAttribute(HandlerManager.SESSION_ATTRIBUTE_HANDLERS);
           }
   
           // set the configuration for the handler
  @@ -749,11 +749,7 @@
               this.application = null;
   
               if (this.handlerName != null) {
  -                if ( null != this.userHandlers) {
  -                    this.handler = (Handler)this.userHandlers.get(this.handlerName);
  -                } else {
  -                    this.handler = 
(Handler)this.configuredHandlers.get(this.handlerName);
  -                }
  +                this.handler = this.getHandler(this.handlerName);
   
                   if (this.handler == null) {
                       throw new ProcessingException("Handler not found: " + 
this.handlerName);
  
  
  
  1.4       +50 -1     
xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java
  
  Index: HandlerManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HandlerManager.java       29 May 2002 15:38:09 -0000      1.3
  +++ HandlerManager.java       29 May 2002 15:58:21 -0000      1.4
  @@ -54,7 +54,9 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.cocoon.webapps.authentication.AuthenticationConstants;
   import java.util.*;
   
   
  @@ -62,10 +64,13 @@
    *  This is a utility class managing the authentication handlers
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: HandlerManager.java,v 1.3 2002/05/29 15:38:09 cziegeler Exp $
  + * @version CVS $Id: HandlerManager.java,v 1.4 2002/05/29 15:58:21 cziegeler Exp $
   */
   public final class HandlerManager {
   
  +    /** The name of the session attribute storing the handler configuration */
  +    public final static String SESSION_ATTRIBUTE_HANDLERS = 
"org.apache.cocoon.webapps.authentication.Handlers";
  +
       public HandlerManager() {}
   
       /** All configured configurations */
  @@ -77,6 +82,9 @@
       /** The available handlers for the current request */
       protected Map availableHandlers = new HashMap(4);
   
  +    /** The handlers of the current user */
  +    protected Map userHandlers;
  +
       /**
        * Add new configurations to the pool
        */
  @@ -149,6 +157,7 @@
        */
       public void clearAvailableHandlers() {
           this.availableHandlers.clear();
  +        this.userHandlers = null;
       }
   
       /**
  @@ -173,4 +182,44 @@
           }
       }
   
  +    /**
  +     * Get the handler of the current user
  +     */
  +    public Handler getHandler(String handlerName,
  +                              Request request) {
  +        if ( null == this.userHandlers) {
  +            final Session session = request.getSession(false);
  +            if ( null != session) {
  +                this.userHandlers = 
(Map)session.getAttribute(SESSION_ATTRIBUTE_HANDLERS);
  +            }
  +        }
  +        Handler handler = null;
  +        if ( null != this.userHandlers) {
  +            handler = (Handler)this.userHandlers.get(handlerName);
  +        }
  +        if ( null == handler ) {
  +            handler = (Handler)this.availableHandlers.get(handlerName);
  +        }
  +        return handler;
  +    }
  +
  +    /**
  +     * Create a handler copy for the user and return it!
  +     */
  +    public Handler storeUserHandler(Handler handler,
  +                                    Request request) {
  +        final Session session = request.getSession();
  +        if ( null == this.userHandlers) {
  +            this.userHandlers = 
(Map)session.getAttribute(SESSION_ATTRIBUTE_HANDLERS);
  +        }
  +        if ( null == this.userHandlers ) {
  +            this.userHandlers = new HashMap(3);
  +        }
  +        // FIXME (CZ) - clone handler
  +        this.userHandlers.put(handler.getName(), handler);
  +        // value did change, update attributes
  +        session.setAttribute(SESSION_ATTRIBUTE_HANDLERS, this.userHandlers);
  +
  +        return handler;
  +    }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to