tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3 CoyoteInterceptor2.java Tomcat3Adapter.java Tomcat3Request.java
Date Sun, 21 Nov 2004 02:45:04 GMT
billbarker    2004/11/20 18:45:04

  Modified:    coyote/src/java/org/apache/coyote/tomcat3
                        CoyoteInterceptor2.java Tomcat3Adapter.java
                        Tomcat3Request.java
  Log:
  Adding support for 'redirectPort'.
  
  This works the same as it does on TC 4+.  You configure it on the Connector, and your security-constraints
can just use the redirect.
  
  Revision  Changes    Path
  1.21      +28 -4     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CoyoteInterceptor2.java	5 Oct 2004 04:45:55 -0000	1.20
  +++ CoyoteInterceptor2.java	21 Nov 2004 02:45:03 -0000	1.21
  @@ -77,10 +77,13 @@
    */
   public class CoyoteInterceptor2 extends BaseInterceptor
   {
  +    public static final String REDIRECT_PORT_ATTR = 
  +	"org.apache.tomcat.request.redirectPort";
       private String processorClassName="org.apache.coyote.http11.Http11Protocol";
       Tomcat3Adapter adapter;
       ProtocolHandler proto;
       int protocolNote;
  +    int redirectPort = -1;
       
       public CoyoteInterceptor2() {
   	super();
  @@ -109,6 +112,21 @@
           setAttribute( prop, value );
       }
   
  +    /**
  +     * Set the redirect port.
  +     */
  +    public void setRedirectPort(int rp) {
  +	redirectPort = rp;
  +	setAttribute("redirectPort", new Integer(rp));
  +    }
  +
  +    /**
  +     * Get the redirect port.
  +     */
  +    public int getRedirectPort() {
  +	return redirectPort;
  +    }
  +
       /** Called when the ContextManger is started
        */
       public void engineInit(ContextManager cm) throws TomcatException {
  @@ -116,7 +134,7 @@
   
           protocolNote = cm.getNoteId(ContextManager.MODULE_NOTE,
   				    "coyote.protocol");
  -        adapter=new Tomcat3Adapter(cm);
  +        adapter=new Tomcat3Adapter(cm, this);
           try {
               Class c=Class.forName(processorClassName);
               proto=(ProtocolHandler)c.newInstance();
  @@ -204,8 +222,12 @@
               return null;
   
           Tomcat3Request httpReq=(Tomcat3Request)request;
  -        
  -        if(key!=null && httpReq!=null ){
  +
  +        if( httpReq == null || httpReq.getConnector() != this ) {
  +	    return null;
  +	}
  +
  +        if(key!=null ){
               org.apache.coyote.Request cReq = httpReq.getCoyoteRequest();
               Object info = cReq.getAttribute(key);
               if( info != null)
  @@ -222,7 +244,9 @@
   		}
   		
                   return cReq.getAttribute(key);
  -            }
  +            } else if(key.equals(REDIRECT_PORT_ATTR)) {
  +		return new Integer(redirectPort);
  +	    }
   
               return cReq.getAttribute( key );
           }
  
  
  
  1.9       +5 -1      jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Adapter.java
  
  Index: Tomcat3Adapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Adapter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Tomcat3Adapter.java	29 Aug 2004 17:14:41 -0000	1.8
  +++ Tomcat3Adapter.java	21 Nov 2004 02:45:03 -0000	1.9
  @@ -18,6 +18,7 @@
   
   import org.apache.coyote.Adapter;
   import org.apache.tomcat.core.ContextManager;
  +import org.apache.tomcat.core.BaseInterceptor;
   
   /** Adapter between Coyote and Tomcat.
    *
  @@ -29,9 +30,11 @@
    */
   public class Tomcat3Adapter implements Adapter {
       ContextManager cm;
  +    BaseInterceptor connector;
       
  -    Tomcat3Adapter(ContextManager ctxman) {
  +    Tomcat3Adapter(ContextManager ctxman, CoyoteInterceptor2 conn) {
   	cm   = ctxman;
  +	connector = conn;
       }
   
       static int containerRequestNOTE=1; // XXX Implement a NoteManager, namespaces.
  @@ -53,6 +56,7 @@
   
               reqA.setCoyoteRequest(request);
               resA.setCoyoteResponse(response);
  +	    reqA.setConnector(connector);
               request.setNote( containerRequestNOTE, reqA );
           } else {
               resA=(Tomcat3Response)reqA.getResponse();
  
  
  
  1.15      +15 -1     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Request.java
  
  Index: Tomcat3Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Request.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Tomcat3Request.java	24 Feb 2004 08:54:30 -0000	1.14
  +++ Tomcat3Request.java	21 Nov 2004 02:45:03 -0000	1.15
  @@ -21,6 +21,7 @@
   import org.apache.coyote.ActionCode;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.MessageBytes;
  +import org.apache.tomcat.core.BaseInterceptor;
   
   /** The Request to connect with Coyote.
    *  This class handles the I/O requirements and transferring the request
  @@ -32,6 +33,7 @@
   public class Tomcat3Request extends org.apache.tomcat.core.Request {
   
       org.apache.coyote.Request coyoteRequest=null;
  +    BaseInterceptor   connector = null;
   
       // For SSL attributes we need to call an ActionHook to get
       // info from the protocol handler.
  @@ -90,8 +92,20 @@
           remoteAddrMB = coyoteRequest.remoteAddr();
   	remoteHostMB = coyoteRequest.remoteHost();
   	serverNameMB = coyoteRequest.serverName();
  +    }
   
  -        
  +    /**
  +     * Set the Connector that this request services
  +     */
  +    void setConnector(BaseInterceptor conn) {
  +	connector = conn;
  +    }
  +
  +    /**
  +     * Get the Connector that this request services
  +     */
  +    BaseInterceptor getConnector() {
  +	return connector;
       }
       
       /** Read a single character from the request body.
  
  
  

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


Mime
View raw message