tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core StandardContext.java
Date Sun, 16 Apr 2000 05:13:39 GMT
craigmcc    00/04/15 22:13:38

  Modified:    proposals/catalina/src/share/org/apache/tomcat Context.java
                        HttpRequest.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        HttpRequestBase.java RequestBase.java
               proposals/catalina/src/share/org/apache/tomcat/connector/http
                        Constants.java HttpProcessor.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        StandardContext.java
  Log:
  Finish fleshing out the functionality of HttpRequestImpl and all of its
  base classes and interfaces.  The request related objects should now be
  functional and ready for use.
  
  Revision  Changes    Path
  1.6       +31 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Context.java	2000/02/13 01:43:43	1.5
  +++ Context.java	2000/04/16 05:13:35	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
1.5 2000/02/13 01:43:43 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/02/13 01:43:43 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
1.6 2000/04/16 05:13:35 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/16 05:13:35 $
    *
    * ====================================================================
    *
  @@ -90,7 +90,7 @@
    * <p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/02/13 01:43:43 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/16 05:13:35 $
    */
   
   public interface Context extends Container {
  @@ -226,6 +226,15 @@
   
   
       /**
  +     * Add a security role reference for this web application.
  +     *
  +     * @param role Security role used in the application
  +     * @param link Actual security role to check for
  +     */
  +    public void addRoleMapping(String role, String link);
  +
  +
  +    /**
        * Add a new security role for this web application.
        *
        * @param role New security role
  @@ -386,6 +395,16 @@
   
   
       /**
  +     * For the given security role (as used by an application), return the
  +     * corresponding role name (as defined by the underlying Realm) if there
  +     * is one.  Otherwise, return the specified role unchanged.
  +     *
  +     * @param role Security role to map
  +     */
  +    public String findRoleMapping(String role);
  +
  +
  +    /**
        * Return <code>true</code> if the specified security role is defined
        * for this application; otherwise return <code>false</code>.
        *
  @@ -534,6 +553,14 @@
        * @param name Name of the resource reference to remove
        */
       public void removeResource(String name);
  +
  +
  +    /**
  +     * Remove any security role reference for the specified name
  +     *
  +     * @param role Security role (as used in the application) to remove
  +     */
  +    public void removeRoleMapping(String role);
   
   
       /**
  
  
  
  1.2       +84 -7     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/HttpRequest.java
  
  Index: HttpRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/HttpRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpRequest.java	2000/04/14 18:55:26	1.1
  +++ HttpRequest.java	2000/04/16 05:13:35	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/HttpRequest.java,v
1.1 2000/04/14 18:55:26 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/04/14 18:55:26 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/HttpRequest.java,v
1.2 2000/04/16 05:13:35 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/16 05:13:35 $
    *
    * ====================================================================
    *
  @@ -76,7 +76,7 @@
    * produce the corresponding <code>HttpResponse</code>.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/04/14 18:55:26 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/16 05:13:35 $
    */
   
   public interface HttpRequest extends Request {
  @@ -122,6 +122,16 @@
   
   
       /**
  +     * Set the context path for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The context path
  +     */
  +    public void setContextPath(String path);
  +
  +
  +    /**
        * Set the HTTP request method used for this Request.
        *
        * @param method The request method
  @@ -129,14 +139,81 @@
       public void setMethod(String method);
   
   
  +    /**
  +     * Set the query string for this Request.  This will normally be called
  +     * by the HTTP Connector, when it parses the request headers.
  +     *
  +     * @param query The query string
  +     */
  +    public void setQueryString(String query);
  +
  +
  +    /**
  +     * Set the path information for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The path information
  +     */
  +    public void setPathInfo(String path);
  +
  +
  +    /**
  +     * Set a flag indicating whether or not the requested session ID for this
  +     * request came in through a cookie.  This is normally called by the
  +     * HTTP Connector, when it parses the request headers.
  +     *
  +     * @param flag The new flag
  +     */
  +    public void setRequestedSessionCookie(boolean flag);
  +
  +
       /**
  -     * Set the unparsed request URI for this Request.  This value cannot be
  -     * parsed until <code>setContext()</code> has been called.  <b>FIXME</b>:
  -     * how and when is parsing initiated?
  +     * Set the requested session ID for this request.  This is normally called
  +     * by the HTTP Connector, when it parses the request headers.
        *
  +     * @param id The new session id
  +     */
  +    public void setRequestedSessionId(String id);
  +
  +
  +    /**
  +     * Set a flag indicating whether or not the requested session ID for this
  +     * request came in through a URL.  This is normally called by the
  +     * HTTP Connector, when it parses the request headers.
  +     *
  +     * @param flag The new flag
  +     */
  +    public void setRequestedSessionURL(boolean flag);
  +
  +
  +    /**
  +     * Set the unparsed request URI for this Request.  This will normally be
  +     * called by the HTTP Connector, when it parses the request headers.
  +     *
        * @param uri The request URI
        */
       public void setRequestURI(String uri);
  +
  +
  +    /**
  +     * Set the flag indicating whether this Request was received on a secure
  +     * communications link or not.  This will normally be called by the HTTP
  +     * Connector, when it parses the request headers.
  +     *
  +     * @param secure The new secure flag
  +     */
  +    public void setSecure(boolean secure);
  +
  +
  +    /**
  +     * Set the servlet path for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The servlet path
  +     */
  +    public void setServletPath(String path);
   
   
       /**
  
  
  
  1.3       +308 -28   jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java
  
  Index: HttpRequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpRequestBase.java	2000/04/15 23:36:15	1.2
  +++ HttpRequestBase.java	2000/04/16 05:13:36	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
1.2 2000/04/15 23:36:15 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/04/15 23:36:15 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/HttpRequestBase.java,v
1.3 2000/04/16 05:13:36 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/16 05:13:36 $
    *
    * ====================================================================
    *
  @@ -65,7 +65,11 @@
   package org.apache.tomcat.connector;
   
   
  +import java.io.IOException;
   import java.security.Principal;
  +import java.text.ParseException;
  +import java.text.SimpleDateFormat;
  +import java.util.Date;
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Vector;
  @@ -73,6 +77,9 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpSession;
   import org.apache.tomcat.HttpRequest;
  +import org.apache.tomcat.Manager;
  +import org.apache.tomcat.Realm;
  +import org.apache.tomcat.Session;
   
   
   /**
  @@ -82,7 +89,7 @@
    * be implemented, which are marked abstract in this class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/04/15 23:36:15 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/16 05:13:36 $
    */
   
   public abstract class HttpRequestBase
  @@ -100,12 +107,28 @@
   
   
       /**
  +     * The context path for this request.
  +     */
  +    protected String contextPath = null;
  +
  +
  +    /**
        * The set of cookies associated with this Request.
        */
       protected Vector cookies = new Vector();
   
   
       /**
  +     * The set of SimpleDateFormat formats to use in getDateHeader().
  +     */
  +    protected static SimpleDateFormat formats[] = {
  +	new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"),
  +	new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz"),
  +	new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy")
  +    };
  +
  +
  +    /**
        * The HTTP headers associated with this Request, keyed by name.
        */
       protected Hashtable headers = new Hashtable();
  @@ -125,12 +148,60 @@
   
   
       /**
  +     * The path information for this request.
  +     */
  +    protected String pathInfo = null;
  +
  +
  +    /**
  +     * The query string for this request.
  +     */
  +    protected String queryString = null;
  +
  +
  +    /**
  +     * Was the requested session ID received in a cookie?
  +     */
  +    protected boolean requestedSessionCookie = false;
  +
  +
  +    /**
  +     * The requested session ID (if any) for this request.
  +     */
  +    protected String requestedSessionId = null;
  +
  +
  +    /**
  +     * Was the requested session ID received in a URL?
  +     */
  +    protected boolean requestedSessionURL = false;
  +
  +
  +    /**
        * The request URI associated with this request.
  +     */
  +    protected String requestURI = null;
  +
  +
  +    /**
  +     * Was this request received on a secure channel?
        */
  -    protected String requestUri = null;
  +    protected boolean secure = false;
   
   
       /**
  +     * The servlet path for this request.
  +     */
  +    protected String servletPath = null;
  +
  +
  +    /**
  +     * The currently active session for this request.
  +     */
  +    protected Session session = null;
  +
  +
  +    /**
        * The Principal who has been authenticated for this Request.
        */
       protected Principal userPrincipal;
  @@ -187,9 +258,20 @@
   
   	super.recycle();
   	authType = null;
  +	contextPath = null;
   	cookies.removeAllElements();
   	headers.clear();
   	method = null;
  +	pathInfo = null;
  +	queryString = null;
  +	requestedSessionCookie = false;
  +	requestedSessionId = null;
  +	requestedSessionURL = false;
  +	requestURI = null;
  +	secure = false;
  +	servletPath = null;
  +	session = null;
  +	userPrincipal = null;
   
       }
   
  @@ -209,6 +291,20 @@
   
   
       /**
  +     * Set the context path for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The context path
  +     */
  +    public void setContextPath(String path) {
  +
  +	this.contextPath = path;
  +
  +    }
  +
  +
  +    /**
        * Set the HTTP request method used for this Request.
        *
        * @param method The request method
  @@ -220,21 +316,116 @@
       }
   
   
  +    /**
  +     * Set the path information for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The path information
  +     */
  +    public void setPathInfo(String path) {
  +
  +	this.pathInfo = path;
  +
  +    }
  +
  +
  +    /**
  +     * Set the query string for this Request.  This will normally be called
  +     * by the HTTP Connector, when it parses the request headers.
  +     *
  +     * @param query The query string
  +     */
  +    public void setQueryString(String query) {
  +
  +	this.queryString = query;
  +
  +    }
  +
  +
       /**
  -     * Set the unparsed request URI for this Request.  This value cannot be
  -     * parsed until <code>setContext()</code> has been called.  <b>FIXME</b>:
  -     * how and when is parsing initiated?
  +     * Set a flag indicating whether or not the requested session ID for this
  +     * request came in through a cookie.  This is normally called by the
  +     * HTTP Connector, when it parses the request headers.
        *
  +     * @param flag The new flag
  +     */
  +    public void setRequestedSessionCookie(boolean flag) {
  +
  +	this.requestedSessionCookie = flag;
  +
  +    }
  +
  +
  +    /**
  +     * Set the requested session ID for this request.  This is normally called
  +     * by the HTTP Connector, when it parses the request headers.
  +     *
  +     * @param id The new session id
  +     */
  +    public void setRequestedSessionId(String id) {
  +
  +	this.requestedSessionId = id;
  +
  +    }
  +
  +
  +    /**
  +     * Set a flag indicating whether or not the requested session ID for this
  +     * request came in through a URL.  This is normally called by the
  +     * HTTP Connector, when it parses the request headers.
  +     *
  +     * @param flag The new flag
  +     */
  +    public void setRequestedSessionURL(boolean flag) {
  +
  +	this.requestedSessionURL = flag;
  +
  +    }
  +
  +
  +    /**
  +     * Set the unparsed request URI for this Request.  This will normally
  +     * be called by the HTTP Connector, when it parses the request headers.
  +     *
        * @param uri The request URI
        */
       public void setRequestURI(String uri) {
  +
  +	this.requestURI = uri;
  +
  +    }
  +
  +
  +    /**
  +     * Set the flag indicating whether this Request was received on a secure
  +     * communications link or not.  This will normally be called by the HTTP
  +     * Connector, when it parses the request headers.
  +     *
  +     * @param secure The new secure flag
  +     */
  +    public void setSecure(boolean secure) {
   
  -	this.requestUri = uri;
  +	this.secure = secure;
   
       }
   
   
       /**
  +     * Set the servlet path for this Request.  This will normally be called
  +     * when the associated Context is mapping the Request to a particular
  +     * Wrapper.
  +     *
  +     * @param path The servlet path
  +     */
  +    public void setServletPath(String path) {
  +
  +	this.servletPath = path;
  +
  +    }
  +
  +
  +    /**
        * Set the Principal who has been authenticated for this Request.  This
        * value is also used to calculate the value to be returned by the
        * <code>getRemoteUser()</code> method.
  @@ -248,6 +439,19 @@
       }
   
   
  +    // ------------------------------------------------- ServletRequest Methods
  +
  +
  +    /**
  +     * Was this request received on a secure connection?
  +     */
  +    public boolean isSecure() {
  +
  +	return (secure);
  +
  +    }
  +
  +
       // --------------------------------------------- HttpServletRequest Methods
   
   
  @@ -256,7 +460,7 @@
        */
       public String getAuthType() {
   
  -	return (this.authType);
  +	return (authType);
   
       }
   
  @@ -267,7 +471,7 @@
        */
       public String getContextPath() {
   
  -	return (null);	// FIXME: getContextPath()
  +	return (contextPath);
   
       }
   
  @@ -298,7 +502,24 @@
        */
       public long getDateHeader(String name) {
   
  -	return (-1);	// FIXME: getDateHeader()
  +	String value = getHeader(name);
  +	if (value == null)
  +	    return (-1L);
  +
  +	// Work around a bug in SimpleDateFormat in pre-JDK1.2b4
  +	// (Bug Parade bug #4106807)
  +	value += " ";
  +
  +	// Attempt to convert the date header in a variety of formats
  +	for (int i = 0; i < formats.length; i++) {
  +	    try {
  +		Date date = formats[i].parse(value);
  +		return (date.getTime());
  +	    } catch (ParseException e) {
  +		;
  +	    }
  +	}
  +	throw new IllegalArgumentException(value);
   
       }
   
  @@ -358,7 +579,11 @@
        */
       public int getIntHeader(String name) {
   
  -	return (-1);	// FIXME: getIntHeader()
  +	String value = getHeader(name);
  +	if (value == null)
  +	    return (-1);
  +	else
  +	    return (Integer.parseInt(value));
   
       }
   
  @@ -368,7 +593,7 @@
        */
       public String getMethod() {
   
  -	return (this.method);
  +	return (method);
   
       }
   
  @@ -378,7 +603,7 @@
        */
       public String getPathInfo() {
   
  -	return (null);	// FIXME: getPathInfo()
  +	return (pathInfo);
   
       }
   
  @@ -389,7 +614,10 @@
        */
       public String getPathTranslated() {
   
  -	return (null);	// FIXME: getPathTranslated()
  +	if (pathInfo == null)
  +	    return (null);
  +	else
  +	    return (context.getServletContext().getRealPath(pathInfo));
   
       }
   
  @@ -399,7 +627,7 @@
        */
       public String getQueryString() {
   
  -	return (null);	// FIXME: getQueryString()
  +	return (queryString);
   
       }
   
  @@ -423,7 +651,7 @@
        */
       public String getRequestedSessionId() {
   
  -	return (null);	// FIXME: getRequestedSessionId()
  +	return (requestedSessionId);
   
       }
   
  @@ -433,7 +661,7 @@
        */
       public String getRequestURI() {
   
  -	return (this.requestUri);
  +	return (requestURI);
   
       }
   
  @@ -444,7 +672,7 @@
        */
       public String getServletPath() {
   
  -	return (null);	// FIXME: getServletPath()
  +	return (servletPath);
   
       }
   
  @@ -455,7 +683,7 @@
        */
       public HttpSession getSession() {
   
  -	return (null);	// FIXME: getSession()
  +	return (getSession(true));
   
       }
   
  @@ -467,9 +695,27 @@
        * @param create Create a new session if one does not exist
        */
       public HttpSession getSession(boolean create) {
  +
  +	// Is the current session (if any) still valid?
  +	if (session != null) {
  +	    try {
  +		session.getSession().getCreationTime();
  +	    } catch (IllegalStateException e) {
  +		session = null;
  +	    }
  +	}
   
  -	return (null);	// FIXME: getSession(create)
  +	// Return the current session if there is one
  +	if (session != null)
  +	    return (session.getSession());
   
  +	// Create a new session if requested
  +	if (!create)
  +	    return (null);
  +	Manager manager = context.getManager();
  +	session = manager.createSession();
  +	return (session.getSession());
  +
       }
   
   
  @@ -479,7 +725,10 @@
        */
       public boolean isRequestedSessionIdFromCookie() {
   
  -	return (false);	// FIXME: isRequestedSessionIdFromCookie()
  +	if (requestedSessionId != null)
  +	    return (requestedSessionCookie);
  +	else
  +	    return (false);
   
       }
   
  @@ -490,7 +739,10 @@
        */
       public boolean isRequestedSessionIdFromURL() {
   
  -	return (false);	// FIXME: isRequestedSessionIdFromURL()
  +	if (requestedSessionId != null)
  +	    return (requestedSessionURL);
  +	else
  +	    return (false);
   
       }
   
  @@ -515,21 +767,49 @@
        */
       public boolean isRequestedSessionIdValid() {
   
  -	return (false);	// FIXME: isRequestedSessionIdValid()
  +	if (requestedSessionId == null)
  +	    return (false);
  +	Manager manager = context.getManager();
  +	if (manager == null)
  +	    return (false);
  +	Session session = null;
  +	try {
  +	    session = manager.findSession(requestedSessionId);
  +	} catch (IOException e) {
  +	    session = null;
  +	}
  +	if (session != null) {
  +	    try {
  +		session.getSession().getCreationTime();
  +		return (true);
  +	    } catch (IllegalStateException e) {
  +		;
  +	    }
  +	}
  +	return (false);
   
       }
   
   
       /**
        * Return <code>true</code> if the authenticated user principal
  -     * possesses the specified role name.  FIXME - Respect translations
  -     * in the web application deployment descriptor!
  +     * possesses the specified role name.
        *
        * @param role Role name to be validated
        */
       public boolean isUserInRole(String role) {
  +
  +	// Respect role name translations in the deployment descriptor
  +	String realRole = context.findRoleMapping(role);
  +
  +	// Determine whether the current user has this role
  +	if (userPrincipal == null)
  +	    return (false);
  +	Realm realm = context.getRealm();
  +	if (realm == null)
  +	    return (false);
   
  -	return (false);	// FIXME: isUserInRole()
  +	return (realm.hasRole(userPrincipal, realRole));
   
       }
   
  
  
  
  1.5       +14 -8     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java
  
  Index: RequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestBase.java	2000/04/15 23:36:15	1.4
  +++ RequestBase.java	2000/04/16 05:13:36	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.4 2000/04/15 23:36:15 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/04/15 23:36:15 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestBase.java,v
1.5 2000/04/16 05:13:36 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/16 05:13:36 $
    *
    * ====================================================================
    *
  @@ -94,7 +94,7 @@
    * abstract in this class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/04/15 23:36:15 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/16 05:13:36 $
    */
   
   public abstract class RequestBase
  @@ -672,8 +672,9 @@
   		(sm.getString("requestBase.getReader.ise"));
   
   	if (reader == null) {
  -	    InputStreamReader isr =	// FIXME: encoding choice?
  -		new InputStreamReader(createInputStream());
  +	    InputStreamReader isr =
  +		new InputStreamReader(createInputStream(),
  +				      getCharacterEncoding());
   	    reader = new BufferedReader(isr);
   	}
   	return (reader);
  @@ -696,8 +697,13 @@
   	ServletContext servletContext = context.getServletContext();
   	if (servletContext == null)
   	    return (null);
  -	else
  -	    return (servletContext.getRealPath(path));
  +	else {
  +	    try {
  +		return (servletContext.getRealPath(path));
  +	    } catch (IllegalArgumentException e) {
  +		return (null);
  +	    }
  +	}
   
       }
   
  
  
  
  1.3       +6 -4      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/Constants.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Constants.java	2000/04/15 05:39:14	1.2
  +++ Constants.java	2000/04/16 05:13:37	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/Constants.java,v
1.2 2000/04/15 05:39:14 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/04/15 05:39:14 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/Constants.java,v
1.3 2000/04/16 05:13:37 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/16 05:13:37 $
    *
    * ====================================================================
    *
  @@ -73,6 +73,8 @@
   
       public static final String Package = "org.apache.tomcat.connector.http";
       public static final String ServerInfo =
  -	"Catalina/0.1";
  +	"Tomcat (Catalina)/0.1";
  +    public static final String SessionCookie = "JSESSIONID";
  +    public static final String SessionParameter = "jsessionid";
   
   }
  
  
  
  1.5       +38 -9     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HttpProcessor.java	2000/04/15 23:36:16	1.4
  +++ HttpProcessor.java	2000/04/16 05:13:37	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v
1.4 2000/04/15 23:36:16 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/04/15 23:36:16 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/http/HttpProcessor.java,v
1.5 2000/04/16 05:13:37 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/16 05:13:37 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * the request.  When the processor is completed, it will recycle itself.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/04/15 23:36:16 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/16 05:13:37 $
    */
   
   final class HttpProcessor
  @@ -305,11 +305,19 @@
   
   	    // Set the corresponding request headers
   	    if (match.equals("authorization")) {
  -		;	// FIXME -- do not want to include with regular headers
  +		// Do not really want to include this but it needs visibility
  +		request.addHeader(name, value);
   	    } else if (match.equals("cookie")) {
   		Cookie cookies[] = RequestUtil.parseCookieHeader(value);
  -		for (int i = 0; i < cookies.length; i++)
  -		    request.addCookie(cookies[i]);
  +		for (int i = 0; i < cookies.length; i++) {
  +		    if (cookies[i].getName().equals(Constants.SessionCookie)) {
  +			// Override anything requested in the URL
  +			request.setRequestedSessionId(cookies[i].getValue());
  +			request.setRequestedSessionCookie(true);
  +			request.setRequestedSessionURL(false);
  +		    } else
  +			request.addCookie(cookies[i]);
  +		}
   	    } else if (match.equals("content-length")) {
   		int n = -1;
   		try {
  @@ -320,7 +328,7 @@
   		}
   		request.setContentLength(n);
   	    } else if (match.equals("content-type")) {
  -		request.setContentType(value);	// FIXME -- encoding?
  +		request.setContentType(value);
   	    } else if (match.equals("host")) {
   		int n = value.indexOf(":");
   		if (n < 0)
  @@ -388,11 +396,32 @@
   		(sm.getString("httpProcessor.parseRequest.uri"));
   	}
   
  +	// Parse any requested session ID out of the request URI
  +	String match = ";" + Constants.SessionParameter + "=";
  +	int i = uri.indexOf(match);
  +	if (i >= 0) {
  +	    StringBuffer sb = new StringBuffer(uri.substring(0, i));
  +	    String rest = uri.substring(i + match.length());
  +	    int j = rest.indexOf(";");	// Another parameter
  +	    int k = rest.indexOf("?");	// Query string
  +	    int l = rest.length();
  +	    if ((j >= 0) && (j < l))
  +		l = j;
  +	    if ((k >= 0) && (k < l))
  +		l = k;
  +	    request.setRequestedSessionId(rest.substring(0, l));
  +	    request.setRequestedSessionURL(true);
  +	    request.setRequestedSessionCookie(false);
  +	    sb.append(rest.substring(l));
  +	    uri = sb.toString();
  +	}
  +
   	// Set the corresponding request properties
   	((HttpRequest) request).setMethod(method);
   	request.setProtocol(protocol);
   	((HttpRequest) request).setRequestURI(uri);
  -	request.setScheme("http");
  +	request.setSecure(false);	// No SSL support
  +	request.setScheme("http");	// No SSL support
   
       }
   
  
  
  
  1.8       +56 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardContext.java	2000/02/13 01:43:45	1.7
  +++ StandardContext.java	2000/04/16 05:13:38	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.7 2000/02/13 01:43:45 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/02/13 01:43:45 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.8 2000/04/16 05:13:38 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/04/16 05:13:38 $
    *
    * ====================================================================
    *
  @@ -90,7 +90,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/02/13 01:43:45 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/16 05:13:38 $
    */
   
   public final class StandardContext
  @@ -185,6 +185,13 @@
   
   
       /**
  +     * The security role mappings for this application, keyed by role
  +     * name (as used within the application).
  +     */
  +    private Hashtable roleMappings = new Hashtable();
  +
  +
  +    /**
        * The security roles for this application, keyed by role name.
        */
       private Hashtable securityRoles = new Hashtable();
  @@ -458,6 +465,20 @@
   
   
       /**
  +     * Add a security role reference for this web application.
  +     *
  +     * @param role Security role used in the application
  +     * @param link Actual security role to check for
  +     */
  +    public void addRoleMapping(String role, String link) {
  +
  +	roleMappings.put(role, link);
  +	fireContainerEvent("addRoleMapping", role);
  +
  +    }
  +
  +
  +    /**
        * Add a new security role for this web application.
        *
        * @param role New security role
  @@ -742,6 +763,24 @@
   
   
       /**
  +     * For the given security role (as used by an application), return the
  +     * corresponding role name (as defined by the underlying Realm) if there
  +     * is one.  Otherwise, return the specified role unchanged.
  +     *
  +     * @param role Security role to map
  +     */
  +    public String findRoleMapping(String role) {
  +
  +	String realRole = (String) roleMappings.get(role);
  +	if (realRole != null)
  +	    return (realRole);
  +	else
  +	    return (role);
  +
  +    }
  +
  +
  +    /**
        * Return <code>true</code> if the specified security role is defined
        * for this application; otherwise return <code>false</code>.
        *
  @@ -1011,6 +1050,19 @@
   
   	resources.remove(name);
   	fireContainerEvent("removeResource", name);
  +
  +    }
  +
  +
  +    /**
  +     * Remove any security role reference for the specified name
  +     *
  +     * @param role Security role (as used in the application) to remove
  +     */
  +    public void removeRoleMapping(String role) {
  +
  +	roleMappings.remove(role);
  +	fireContainerEvent("removeRoleMapping", role);
   
       }
   
  
  
  

Mime
View raw message