remm        2004/01/10 09:23:39

  Modified:    catalina/src/share/org/apache/catalina/realm RealmBase.java
  Log:
  - findMethod wasn't called on the right collection.
  - The algorithm ignored extension mapped constraints as long as a widcard
    or exact mapped constraint was found. This doesn't seem right (I did quickly
    read the relevant portions of the spec).
  - Next, I'll try to optimize the algorithm (allocating a collection on each request
    is not good, we should add a matched contraints array on the request).
  
  Revision  Changes    Path
  1.24      +16 -11    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java
  
  Index: RealmBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- RealmBase.java    26 Dec 2003 17:33:44 -0000      1.23
  +++ RealmBase.java    10 Jan 2004 17:23:39 -0000      1.24
  @@ -457,10 +457,7 @@
   
           // Check each defined security constraint
           HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  -        String uri = request.getDecodedRequestURI();
  -        String contextPath = hreq.getContextPath();
  -        if (contextPath.length() > 0)
  -            uri = uri.substring(contextPath.length());
  +        String uri = request.getRequestPathMB().toString();
           
           String method = hreq.getMethod();
           int i;
  @@ -486,10 +483,12 @@
                       }
                   }
               }
  -        }        
  +        }
  +        /*
           if(found) {
               return resultsToArray(results);
           }
  +        */
           int longest = -1;
   
           for (i = 0; i < constraints.length; i++) {
  @@ -535,9 +534,11 @@
                   }
               }
           }
  +        /*
           if(found) {
               return  resultsToArray(results);
           }
  +        */
           for (i = 0; i < constraints.length; i++) {
               SecurityCollection [] collection = constraints[i].findCollections();
               
  @@ -546,6 +547,7 @@
                       "' against " + method + " " + uri + " --> " +
                       constraints[i].included(uri, method));
               boolean matched = false;
  +            int pos = -1;
               for(int j=0; j < collection.length; j++){
                   String [] patterns = collection[j].findPatterns();
                   for(int k=0; k < patterns.length && !matched; k++) {
  @@ -558,6 +560,7 @@
                              uri.length()-dot == pattern.length()-1) {
                               if(pattern.regionMatches(1,uri,dot,uri.length()-dot)) {
                                   matched = true;
  +                                pos = j;
                               }
                           }
                       }
  @@ -565,17 +568,19 @@
               }
               if(matched) {
                   found = true;
  -                if(collection[i].findMethod(method)) {
  +                if(collection[pos].findMethod(method)) {
                       if(results == null) {
                           results = new ArrayList();
  -                    }                    
  +                    }
                       results.add(constraints[i]);
                   }
               }
           }
  +        /*
           if(found) {
               return resultsToArray(results);
           }
  +        */
           for (i = 0; i < constraints.length; i++) {
               SecurityCollection [] collection = constraints[i].findCollections();
               
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to