costin      01/04/10 00:01:12

  Modified:    src/share/org/apache/tomcat/modules/aaa
                        AccessInterceptor.java
               src/share/org/apache/tomcat/modules/generators
                        StaticInterceptor.java
  Log:
  Second part of the URL-based session + authentication.
  
  If the original URI is a directory, the form login will be displayed,
  then after submitting the user/pass the redirect to ../dir/;jsessionid=...
  will work fine, but then StaticInterceptor will do another redirect
  to dir/index.jsp ( without session ).
  
  Now StaticInterceptor is fixed ( that should solve other cases as well ).
  
  Of course, as previously form-based login + apache is a difficult case
  ( unless you redirect everything to tomcat - but then what's the point
  of having apache ).
  
  Revision  Changes    Path
  1.10      +3 -1      
jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/AccessInterceptor.java
  
  Index: AccessInterceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/AccessInterceptor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AccessInterceptor.java    2001/04/10 06:26:15     1.9
  +++ AccessInterceptor.java    2001/04/10 07:01:11     1.10
  @@ -459,6 +459,7 @@
        ServerSession session=req.getSession( false );
        // we didn't had a session
        boolean noSession= ( session==null );
  +     if( debug>0 ) log( "Form handler called with no session ");
   
        String page=ctx.getFormLoginPage();
        String errorPage=ctx.getFormErrorPage();
  @@ -476,6 +477,7 @@
            session.removeAttribute( "j_password");
            req.setAttribute("javax.servlet.error.message",
                             errorPage );
  +         if( debug>0) log( "Redirecting to " + errorPage );
            contextM.handleStatus( req, res, 302 ); // redirect
            return;
        }
  @@ -496,7 +498,7 @@
                              originalLocation);
        if( debug > 0 )
            log("Redirect1: " + page  + " originalUri=" +
  -             req.requestURI().toString());
  +             originalLocation );
   
        req.setAttribute("javax.servlet.error.message",
                         page );
  
  
  
  1.11      +15 -0     
jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java
  
  Index: StaticInterceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StaticInterceptor.java    2001/03/24 21:33:53     1.10
  +++ StaticInterceptor.java    2001/04/10 07:01:12     1.11
  @@ -170,6 +170,7 @@
        // consistent with Apache
        if( welcomeFile==null && ! requestURI.endsWith("/") ) {
            String redirectURI= requestURI + "/";
  +         redirectURI=fixURLRewriting( req, redirectURI );
            req.setAttribute("javax.servlet.error.message",
                             redirectURI);
            if( debug > 0) log( "Redirect " + redirectURI );
  @@ -194,6 +195,8 @@
        // request, but that's not a specified behavior
        String redirectURI=null;
        redirectURI=concatPath( requestURI, welcomeFile);
  +     redirectURI=fixURLRewriting( req, redirectURI );
  +
        req.setAttribute("javax.servlet.error.message",
                         redirectURI);
        if( debug > 0) log( "Redirect " + redirectURI );
  @@ -204,6 +207,18 @@
        return 0;
       }
   
  +    // Fix for URL rewriting 
  +    private String fixURLRewriting(Request req, String redirectURI ) {
  +     ServerSession session=req.getSession( false );
  +     if( session != null &&
  +         Request.SESSIONID_FROM_URL.equals(req.getSessionIdSource()))  {
  +         String id=";jsessionid="+req.getSessionId() ;
  +         redirectURI += id ;
  +     }
  +     return redirectURI;
  +    }
  +
  +    
       private static String concatPath( String s1, String s2 ) {
        if( s1.endsWith( "/" ) ) {
            if( s2.startsWith( "/" ))
  
  
  

Reply via email to