remm        02/01/17 04:17:16

  Modified:    catalina/src/share/org/apache/catalina/connector/warp Tag:
                        tomcat_40_branch Constants.java
                        WarpConfigurationHandler.java WarpConnector.java
                        WarpRequest.java WarpRequestHandler.java
  Added:       catalina/src/share/org/apache/catalina/connector/warp Tag:
                        tomcat_40_branch WarpCertificates.java
                        WarpSSLData.java
  Log:
  - Upgrade to latest WARP Java code.
    Please let me know if something is wrong.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.1   +44 -0     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/Constants.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- Constants.java    17 Sep 2001 05:10:54 -0000      1.5
  +++ Constants.java    17 Jan 2002 12:17:15 -0000      1.5.2.1
  @@ -363,4 +363,48 @@
        * No payload.<br>
        */
       public static final int TYPE_CBK_DONE=0x42;
  +
  +    /**
  +     * ASK_SSL: The WARP server (Tomcat) asks the WARP client to
  +     * transfer the basic SSL information (cypher, keysize and session).
  +     * <br>
  +     * No payload.<br>
  +     */
  +    public static final int TYPE_ASK_SSL=0x43;
  +
  +    /**
  +     * ASK_SSL_CLIENT: The WARP server (Tomcat) asks the WARP server to
  +     * transfer the client certificate.
  +     * (just the first element of the chain and the webserver should request
  +     * for it to the browser if possible).
  +     * <br>
  +     * No payload.<br>
  +     */
  +    public static final int TYPE_ASK_SSL_CLIENT=0x44;
  +
  +    /**
  +     * REP_SSL_CERT: The client certificate (remote peer).
  +     * <br>
  +     * Payload description:<br>
  +     * [string] The client certificate. (PEM format).
  +     */
  +    public static final int TYPE_REP_SSL_CERT=0x52;
  + 
  +    /**
  +     * REP_SSL: SSL information between 
  +     * <br>
  +     * Payload description:<br>
  +     * [string] The cipher_suite.
  +     * [string] The ssl session. (That is not in the spec's).
  +     * [ushort] size of the algorithm (56-128).
  +     */
  +    public static final int TYPE_REP_SSL=0x53;
  + 
  +    /**
  +     * REP_SSL_NO: Request SSL information is not available.
  +     * <br>
  +     * No payload.<br>
  +     */
  +    public static final int TYPE_REP_SSL_NO=0x5F;
   }
  +
  
  
  
  1.6.2.1   +8 -4      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConfigurationHandler.java
  
  Index: WarpConfigurationHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConfigurationHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- WarpConfigurationHandler.java     17 Sep 2001 05:10:54 -0000      1.6
  +++ WarpConfigurationHandler.java     17 Jan 2002 12:17:15 -0000      1.6.2.1
  @@ -258,7 +258,8 @@
   
           Container container=connection.getConnector().getContainer();
   
  -        Host host=(Host)container.findChild(hostName);
  +        // the hostName should be in lowewr case (setName makes a toLowerCase).
  +        Host host=(Host)container.findChild(hostName.toLowerCase());
           if (host==null) {
               WarpHost whost=new WarpHost();
               whost.setName(hostName);
  @@ -286,10 +287,13 @@
                   logger.debug("No application for \""+applPath+"\"");
   
               Deployer deployer=(Deployer)host;
  -            File file=new File(host.getAppBase()+File.separator+applName);
  +            File file=new File(applName);
               if (!file.isAbsolute()) {
  -                file=new File(System.getProperty("catalina.base"),
  -                              host.getAppBase()+File.separator+applName);
  +                file=new File(host.getAppBase()+File.separator+applName);
  +                if (!file.isAbsolute()) {
  +                         file=new File(System.getProperty("catalina.base"),
  +                                  host.getAppBase()+File.separator+applName);
  +                }
               }
   
               if (!file.exists()) {
  
  
  
  1.16.2.5  +11 -2     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConnector.java
  
  Index: WarpConnector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpConnector.java,v
  retrieving revision 1.16.2.4
  retrieving revision 1.16.2.5
  diff -u -r1.16.2.4 -r1.16.2.5
  --- WarpConnector.java        30 Oct 2001 22:21:32 -0000      1.16.2.4
  +++ WarpConnector.java        17 Jan 2002 12:17:15 -0000      1.16.2.5
  @@ -449,6 +449,14 @@
       }
   
       /**
  +     * Get the lifecycle listeners associated with this lifecycle. If this 
  +     * Lifecycle has no listeners registered, a zero-length array is returned.
  +     */
  +    public LifecycleListener[] findLifecycleListeners() {
  +        return null; // FIXME: lifecycle.findLifecycleListeners();
  +    }
  +
  +    /**
        * Remove a <code>LifecycleEvent</code> listener from this
        * <code>Connector</code>.
        *
  @@ -479,8 +487,9 @@
                   InetAddress addr=InetAddress.getByName(this.getAddress());
                   this.server=fact.createSocket(port,accc,addr);
               }
  -        } catch (IOException e) {
  -            throw new LifecycleException("Error creating server socket",e);
  +        } catch (Exception e) {
  +            throw new LifecycleException("Error creating server socket ("+
  +                e.getClass().getName()+")",e);
           }
       }
   
  
  
  
  1.8.2.1   +88 -1     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpRequest.java
  
  Index: WarpRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpRequest.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- WarpRequest.java  9 Aug 2001 20:08:58 -0000       1.8
  +++ WarpRequest.java  17 Jan 2002 12:17:16 -0000      1.8.2.1
  @@ -77,6 +77,52 @@
           this.setStream(this.localstream);
       }
   
  +    /** Process the SSL attributes */
  +    public Object getAttribute(String name) {
  +
  +        /* Use cached values */
  +        Object object = super.getAttribute(name);
  +     if (object != null)
  +            return object;
  +
  +     /* Fill the cache and return value if possible */
  +        if (!localstream.request.isSecure()) return null;
  +
  +        /* Client Certificate */
  +        if (name.equals("javax.servlet.request.X509Certificate")) {
  +            WarpCertificates cert = null;
  +            try {
  +                cert = new WarpCertificates(localstream.getX509Certificates());
  +            } catch (IOException e) {
  +                return null;
  +            }
  +            super.setAttribute("javax.servlet.request.X509Certificate",
  +                cert.getCertificates());
  +        }
  +
  +        /* other ssl parameters */
  +        if (name.equals("javax.servlet.request.cipher_suite") ||
  +            name.equals("javax.servlet.request.key_size") ||
  +            name.equals("javax.servlet.request.ssl_session")) {
  +            WarpSSLData ssldata = null;
  +            try {
  +                ssldata = localstream.getSSL();
  +            } catch (IOException e) {
  +                return null;
  +            }
  +            if (ssldata == null) return null;
  +
  +            super.setAttribute("javax.servlet.request.cipher_suite",
  +                ssldata.ciph);
  +            if (ssldata.size!=0)
  +                super.setAttribute("javax.servlet.request.key_size",
  +                    new Integer (ssldata.size));
  +            super.setAttribute("javax.servlet.request.ssl_session",
  +                ssldata.sess);
  +        }
  +        return(super.getAttribute(name));
  +    }
  +
       public void setHost(Host host) {
           this.host=host;
       }
  @@ -128,6 +174,7 @@
               this.packet=new WarpPacket();
               this.packet.setType(Constants.TYPE_CBK_DATA);
           }
  +
           
           public int read()
           throws IOException {
  @@ -139,7 +186,7 @@
                   throw new IOException("Invalid WARP packet type for body");
   
               if (this.packet.pointer<this.packet.size)
  -                return((int)this.packet.buffer[this.packet.pointer++]);
  +                return(((int)this.packet.buffer[this.packet.pointer++])&0x0ff);
   
               this.packet.reset();
               this.packet.setType(Constants.TYPE_CBK_READ);
  @@ -150,6 +197,46 @@
               this.request.getConnection().recv(packet);
               return(this.read());
           }
  +
  +        public String getX509Certificates()
  +        throws IOException {
  +            if (closed) throw new IOException("Stream closed");
  +            this.packet.reset();
  +            this.packet.setType(Constants.TYPE_ASK_SSL_CLIENT);
  +            this.request.getConnection().send(packet);
  +            packet.reset();
  +
  +            this.request.getConnection().recv(packet);
  +            if (closed) throw new IOException("Stream closed");
  +            if (packet.getType()==Constants.TYPE_REP_SSL_NO) return(null);
  +            if (packet.getType()!=Constants.TYPE_REP_SSL_CERT)
  +               throw new IOException("Invalid WARP packet type for CC");
  +            return(this.packet.readString());
  +        }
  +
  +        /** Read the data from the SSL environment. */
  +        public WarpSSLData getSSL()
  +        throws IOException {
  +          
  +            if (closed) throw new IOException("Stream closed");
  +            this.packet.reset();
  +            this.packet.setType(Constants.TYPE_ASK_SSL);
  +            this.request.getConnection().send(packet);
  +            packet.reset();
  +
  +            this.request.getConnection().recv(packet);
  +            if (closed) throw new IOException("Stream closed");
  +            if (packet.getType()==Constants.TYPE_REP_SSL_NO) return(null);
  +            if (packet.getType()!=Constants.TYPE_REP_SSL)
  +               throw new IOException("Invalid WARP packet type for SSL data");
  +            WarpSSLData ssldata  = new WarpSSLData();
  +            ssldata.ciph = this.packet.readString();
  +            ssldata.sess = this.packet.readString();
  +            ssldata.size = this.packet.readInteger();
  +            return(ssldata);
  +        }
  +
  +
           
           public void close()
           throws IOException {
  
  
  
  1.13.2.1  +2 -0      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpRequestHandler.java
  
  Index: WarpRequestHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/WarpRequestHandler.java,v
  retrieving revision 1.13
  retrieving revision 1.13.2.1
  diff -u -r1.13 -r1.13.2.1
  --- WarpRequestHandler.java   17 Sep 2001 23:12:01 -0000      1.13
  +++ WarpRequestHandler.java   17 Jan 2002 12:17:16 -0000      1.13.2.1
  @@ -159,6 +159,8 @@
                       if (Constants.DEBUG)
                           logger.debug("Request scheme="+schm);
                       request.setScheme(schm);
  +                    if (schm.equals("https"))
  +                       request.setSecure(true);
                       break;
                   }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +96 -0     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/Attic/WarpCertificates.java
  
  
  
  
  1.1.2.1   +77 -0     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/warp/Attic/WarpSSLData.java
  
  
  
  

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

Reply via email to