billbarker    02/04/08 21:33:53

  Modified:    coyote/src/java/org/apache/coyote/tomcat3
                        CoyoteInterceptor2.java
  Log:
  Do a correct check if the request is for a SSL attribute.
  
  The lookup is way too expensive to do it when it isn't needed.
  
  Revision  Changes    Path
  1.5       +20 -10    
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteInterceptor2.java
  
  Index: CoyoteInterceptor2.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/CoyoteInterceptor2.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CoyoteInterceptor2.java   9 Apr 2002 04:23:04 -0000       1.4
  +++ CoyoteInterceptor2.java   9 Apr 2002 04:33:53 -0000       1.5
  @@ -221,20 +221,30 @@
           }
           
           if(key!=null && httpReq!=null ){
  -         org.apache.coyote.Request cReq = httpReq.getCoyoteRequest();
  -         Object info = cReq.getAttribute(key);
  -         if( info != null)
  -             return info;
  +            org.apache.coyote.Request cReq = httpReq.getCoyoteRequest();
  +            Object info = cReq.getAttribute(key);
  +            if( info != null)
  +                return info;
               // XXX Should use MsgContext, pass the attribute we need.
               // This will extract both 
  -         // XXX the startsWith is a hack, but it is supposed to be reserved.
  -         if(key.startsWith("javax.servlet.request.")) {
  -             cReq.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
  -                         httpReq.getCoyoteRequest() );
  -             return cReq.getAttribute(key);
  -         }
  +            if(isSSLAttribute(key)) {
  +                cReq.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
  +                            httpReq.getCoyoteRequest() );
  +                return cReq.getAttribute(key);
  +            }
           }
           return super.getInfo(ctx,request,id,key);
  +    }
  +
  +    /**
  +     * Check if a string is a reserved SSL attribute key.
  +     */
  +    public static boolean isSSLAttribute(String key) {
  +        if(key == null)
  +            return false;
  +        return key.equals("javax.servlet.request.cipher_suite") ||
  +            key.equals("javax.servlet.request.X509Certificate") ||
  +            key.equals("javax.servlet.request.key_size");
       }
   }
   
  
  
  

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

Reply via email to