keith       2002/10/28 11:05:43

  Modified:    src/share/org/apache/tomcat/modules/server
                        Http10Interceptor.java
  Log:
  This cast is sort of expensive, so avoid it if possible.
  
  Revision  Changes    Path
  1.35      +36 -20    
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Http10Interceptor.java    12 Apr 2002 17:44:38 -0000      1.34
  +++ Http10Interceptor.java    28 Oct 2002 19:05:40 -0000      1.35
  @@ -226,7 +226,12 @@
            catch (IOException e) { /* ignore */ }
           }
       }
  - 
  +
  +    /** Internal constants for getInfo */ 
  +    private static final int GET_OTHER = 0;
  +    private static final int GET_CIPHER_SUITE = 1;
  +    private static final int GET_PEER_CERTIFICATE_CHAIN = 2;
  +
        /**
          getInfo calls for SSL data
    
  @@ -238,28 +243,39 @@
          // attributes hand;ed here are HTTP. If you change that
          // you MUST change the test for sslSupport==null --EKR
    
  -       HttpRequest httpReq;
  +       if (key != null) {
  +         int infoRequested = GET_OTHER;
  +         if(key.equals("javax.servlet.request.cipher_suite"))
  +           infoRequested = GET_CIPHER_SUITE;
  +         else if(key.equals("javax.servlet.request.X509Certificate"))
  +           infoRequested = GET_PEER_CERTIFICATE_CHAIN;
  +
  +         if(infoRequested != GET_OTHER) {
  +           HttpRequest httpReq;
   
  -       
  -       try {
  -     httpReq=(HttpRequest)request;
  -       } catch (ClassCastException e){
  -     return null;
  -       }
  +           try {
  +             httpReq=(HttpRequest)request;
  +           } catch (ClassCastException e){
  +             return null;
  +           }
    
  -       if(key!=null && httpReq!=null && httpReq.sslSupport!=null){
  -       try {
  -           if(key.equals("javax.servlet.request.cipher_suite"))
  -               return httpReq.sslSupport.getCipherSuite();
  -           if(key.equals("javax.servlet.request.X509Certificate"))
  -               return httpReq.sslSupport.getPeerCertificateChain();
  -       } catch (Exception e){
  -           log("Exception getting SSL attribute " + key,e,Log.WARNING);
  -           return null;
  -       }
  -       }
  +           if (httpReq!=null && httpReq.sslSupport!=null){
  +             try {
  +               switch (infoRequested) {
  +                 case GET_CIPHER_SUITE:
  +                   return httpReq.sslSupport.getCipherSuite();
  +                 case GET_PEER_CERTIFICATE_CHAIN:
  +                   return httpReq.sslSupport.getPeerCertificateChain();
  +               }
  +             } catch (Exception e){
  +               log("Exception getting SSL attribute " + key,e,Log.WARNING);
  +               return null;
  +             }
  +           } // if req != null
  +         } // if asking for ssl attribute
  +       } // if key != null
          return super.getInfo(ctx,request,id,key);
  -     }
  +     } // getInfo
   }
   
   class HttpRequest extends Request {
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>

Reply via email to