You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2002/08/15 16:51:27 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/acting LogoutAction.java

cziegeler    2002/08/15 07:51:27

  Modified:    src/java/org/apache/cocoon/webapps/authentication/components
                        AuthenticationManager.java HandlerManager.java
               src/java/org/apache/cocoon/webapps/authentication
                        AuthenticationConstants.java
               src/java/org/apache/cocoon/webapps/session/components
                        SessionManager.java
               src/java/org/apache/cocoon/webapps/authentication/acting
                        LogoutAction.java
  Log:
  Finished missing logout mode.
  
  Revision  Changes    Path
  1.13      +15 -7     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AuthenticationManager.java	13 Aug 2002 15:29:10 -0000	1.12
  +++ AuthenticationManager.java	15 Aug 2002 14:51:27 -0000	1.13
  @@ -949,14 +949,16 @@
       }
   
       /**
  -     * Logout from the given handler
  -     * Terminate session if required
  +     * Logout from the given handler and eventually terminate session.
  +     * @param logoutHandlerName The authentication handler
  +     * @param mode              This mode defines how the termination of 
  +     *                           the session is handled.
        */
       public void logout(String  logoutHandlerName,
  -                       String  mode)
  +                        int     mode)
       throws ProcessingException {
           // synchronized via context
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("BEGIN logout handler=" + logoutHandlerName +
                                      ", mode="+mode);
           }
  @@ -993,11 +995,17 @@
               }
           }
   
  -        if ( mode != null && mode.equalsIgnoreCase("terminateSession") ) {
  +        if ( mode == AuthenticationConstants.LOGOUT_MODE_IMMEDIATELY ) {
               this.getSessionManager().terminateSession(true);
  +        } else if (!this.handlerManager.hasUserHandler( this.request )) {
  +            if (mode == AuthenticationConstants.LOGOUT_MODE_IF_UNUSED) {
  +                this.getSessionManager().terminateSession(false);
  +            } else {
  +                this.getSessionManager().terminateSession(true);
  +            }
           }
   
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("END logout");
           }
       }
  
  
  
  1.8       +17 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- HandlerManager.java	12 Jul 2002 11:25:58 -0000	1.7
  +++ HandlerManager.java	15 Aug 2002 14:51:27 -0000	1.8
  @@ -257,4 +257,20 @@
           }
           return false;
       }
  +    
  +    /**
  +     * Check, if any handler is available
  +     */
  +    public boolean hasUserHandler(Request request) {
  +        if ( null == this.userHandlers) {
  +            final Session session = request.getSession(false);
  +            if ( null != session) {
  +                this.userHandlers = (Map)session.getAttribute(SESSION_ATTRIBUTE_HANDLERS);
  +            }
  +        }
  +        if ( null != this.userHandlers) {
  +            return !this.userHandlers.isEmpty();
  +        }
  +        return false;
  +    }
   }
  
  
  
  1.4       +10 -1     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AuthenticationConstants.java	5 Jul 2002 07:16:33 -0000	1.3
  +++ AuthenticationConstants.java	15 Aug 2002 14:51:27 -0000	1.4
  @@ -69,6 +69,15 @@
       /** The name of the authentication context. */
       String SESSION_CONTEXT_NAME = "authentication";
   
  +    /** Logout mode: session is terminated immediately */
  +    int LOGOUT_MODE_IMMEDIATELY = 0;
  +    
  +    /** Logout mode: session is terminated if not used anymore (by the 
  +     * session or the authentication framework */
  +    int LOGOUT_MODE_IF_UNUSED= 1;
  +
  +    /** Logout mode: session is terminated immediately */
  +    int LOGOUT_MODE_IF_NOT_AUTHENTICATED = 2;
   }
   
   
  
  
  
  1.7       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/webapps/session/components/SessionManager.java
  
  Index: SessionManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/session/components/SessionManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SessionManager.java	31 Jul 2002 13:13:31 -0000	1.6
  +++ SessionManager.java	15 Aug 2002 14:51:27 -0000	1.7
  @@ -367,7 +367,7 @@
        *  data is deleted.
        *  @param force If this is set to true the session is terminated, if
        *                   it is set to false, the session is only terminated
  -     *                   if now session context is available.
  +     *                   if no session context is available.
        */
       public void terminateSession(boolean force) {
           // synchronized
  
  
  
  1.2       +12 -2     xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/acting/LogoutAction.java
  
  Index: LogoutAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/acting/LogoutAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogoutAction.java	17 Apr 2002 10:04:52 -0000	1.1
  +++ LogoutAction.java	15 Aug 2002 14:51:27 -0000	1.2
  @@ -98,7 +98,17 @@
           if ( null == handlerName )
               throw new ProcessingException("LogoutAction requires at least the handler parameter.");
   
  -        final String mode = par.getParameter("mode", "normal");
  +        int mode;
  +        final String modeString = par.getParameter("mode", "if-not-authenticated");
  +        if ( modeString.equals("if-not-authenticated") ) {
  +            mode = AuthenticationConstants.LOGOUT_MODE_IF_NOT_AUTHENTICATED;
  +        } else if ( modeString.equalsIgnoreCase("if-unused") ) {
  +            mode = AuthenticationConstants.LOGOUT_MODE_IF_UNUSED;
  +        } else if ( modeString.equalsIgnoreCase("immediately") ) {
  +            mode = AuthenticationConstants.LOGOUT_MODE_IMMEDIATELY;
  +        } else {
  +           throw new ProcessingException("Unknown mode " + modeString);
  +        }
   
           // authenticate
           AuthenticationManager manager = null;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org