craigmcc 00/12/16 17:05:40
Modified: catalina/src/share/org/apache/catalina HttpResponse.java
catalina/src/share/org/apache/catalina/authenticator
SingleSignOn.java
catalina/src/share/org/apache/catalina/connector
HttpResponseBase.java HttpResponseWrapper.java
catalina/src/share/org/apache/catalina/connector/http
HttpProcessor.java
Log:
Correct a regression that was caused by a bug fix for multiple session ID
cookies. The first session ID cookie was getting recognized, but any
other cookies set on the same "Cookie" header were getting ignored.
Among other things, this broke support for single sign on.
Revision Changes Path
1.3 +14 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/HttpResponse.java
Index: HttpResponse.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/HttpResponse.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpResponse.java 2000/10/18 19:20:35 1.2
+++ HttpResponse.java 2000/12/17 01:05:38 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/HttpResponse.java,v
1.2 2000/10/18 19:20:35 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/18 19:20:35 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/HttpResponse.java,v
1.3 2000/12/17 01:05:38 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/12/17 01:05:38 $
*
* ====================================================================
*
@@ -65,13 +65,16 @@
package org.apache.catalina;
+import javax.servlet.http.Cookie;
+
+
/**
* An <b>HttpResponse</b> is the Catalina-internal facade for an
* <code>HttpServletResponse</code> that is to be produced,
* based on the processing of a corresponding <code>HttpRequest</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/18 19:20:35 $
+ * @version $Revision: 1.3 $ $Date: 2000/12/17 01:05:38 $
*/
public interface HttpResponse
@@ -79,6 +82,13 @@
// --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return an array of all cookies set for this response, or
+ * a zero-length array if no cookies have been set.
+ */
+ public Cookie[] getCookies();
/**
1.3 +44 -8
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/authenticator/SingleSignOn.java
Index: SingleSignOn.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/authenticator/SingleSignOn.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingleSignOn.java 2000/10/18 18:15:51 1.2
+++ SingleSignOn.java 2000/12/17 01:05:39 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/authenticator/SingleSignOn.java,v
1.2 2000/10/18 18:15:51 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/10/18 18:15:51 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/authenticator/SingleSignOn.java,v
1.3 2000/12/17 01:05:39 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/12/17 01:05:39 $
*
* ====================================================================
*
@@ -99,7 +99,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/10/18 18:15:51 $
+ * @version $Revision: 1.3 $ $Date: 2000/12/17 01:05:39 $
*/
public class SingleSignOn
@@ -136,6 +136,31 @@
StringManager.getManager(Constants.Package);
+ // ------------------------------------------------------------- Properties
+
+
+ /**
+ * Return the debugging detail level.
+ */
+ public int getDebug() {
+
+ return (this.debug);
+
+ }
+
+
+ /**
+ * Set the debugging detail level.
+ *
+ * @param debug The new debugging detail level
+ */
+ public void setDebug(int debug) {
+
+ this.debug = debug;
+
+ }
+
+
// ---------------------------------------------------------- Valve Methods
@@ -171,14 +196,19 @@
// Has a valid user already been authenticated?
HttpServletRequest hreq =
(HttpServletRequest) request.getRequest();
+ if (debug >= 1)
+ log("Process request for '" + hreq.getRequestURI() + "'");
if (hreq.getUserPrincipal() != null) {
+ if (debug >= 1)
+ log(" Principal '" + hreq.getUserPrincipal().getName() +
+ "' has already been authenticated");
invokeNext(request, response);
return;
}
// Check for the single sign on cookie
if (debug >= 1)
- log("Checking for SSO cookie");
+ log(" Checking for SSO cookie");
Cookie cookie = null;
Cookie cookies[] = hreq.getCookies();
if (cookies == null)
@@ -190,20 +220,26 @@
}
}
if (cookie == null) {
+ if (debug >= 1)
+ log(" SSO cookie is not present");
invokeNext(request, response);
return;
}
// Look up the cached Principal associated with this cookie value
if (debug >= 1)
- log("Checking for cached principal");
+ log(" Checking for cached principal");
SingleSignOnEntry entry = lookup(cookie.getValue());
if (entry != null) {
if (debug >= 1)
- log("Found cached principal '" +
- entry.principal.getName() + "'");
+ log(" Found cached principal '" +
+ entry.principal.getName() + "' with auth type '" +
+ entry.authType + "'");
((HttpRequest) request).setAuthType(entry.authType);
((HttpRequest) request).setUserPrincipal(entry.principal);
+ } else {
+ if (debug >= 1)
+ log(" No cached principal found");
}
// Invoke the next Valve in our pipeline
1.22 +17 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java
Index: HttpResponseBase.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- HttpResponseBase.java 2000/12/16 19:46:15 1.21
+++ HttpResponseBase.java 2000/12/17 01:05:39 1.22
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
1.21 2000/12/16 19:46:15 craigmcc Exp $
- * $Revision: 1.21 $
- * $Date: 2000/12/16 19:46:15 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
1.22 2000/12/17 01:05:39 craigmcc Exp $
+ * $Revision: 1.22 $
+ * $Date: 2000/12/17 01:05:39 $
*
* ====================================================================
*
@@ -96,7 +96,7 @@
* methods need to be implemented.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.21 $ $Date: 2000/12/16 19:46:15 $
+ * @version $Revision: 1.22 $ $Date: 2000/12/17 01:05:39 $
*/
public class HttpResponseBase
@@ -202,6 +202,19 @@
// Flush the headers and finish this response
sendHeaders();
super.finishResponse();
+
+ }
+
+
+ /**
+ * Return an array of all cookies set for this response, or
+ * a zero-length array if no cookies have been set.
+ */
+ public Cookie[] getCookies() {
+
+ synchronized (cookies) {
+ return ((Cookie[]) cookies.toArray(new Cookie[cookies.size()]));
+ }
}
1.2 +17 -3
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseWrapper.java
Index: HttpResponseWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseWrapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpResponseWrapper.java 2000/08/11 22:40:19 1.1
+++ HttpResponseWrapper.java 2000/12/17 01:05:39 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseWrapper.java,v
1.1 2000/08/11 22:40:19 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2000/08/11 22:40:19 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseWrapper.java,v
1.2 2000/12/17 01:05:39 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/12/17 01:05:39 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
* functionality that they require.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/08/11 22:40:19 $
+ * @version $Revision: 1.2 $ $Date: 2000/12/17 01:05:39 $
*/
public abstract class HttpResponseWrapper
@@ -158,6 +158,20 @@
public int getStatus() {
return (((HttpResponse) response).getStatus());
+
+ }
+
+
+ /**
+ * Reset this response, and specify the values for the HTTP status code
+ * and corresponding message.
+ *
+ * @exception IllegalStateException if this response has already been
+ * committed
+ */
+ public void reset(int status, String message) {
+
+ ((HttpResponse) response).reset(status, message);
}
1.18 +18 -14
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java
Index: HttpProcessor.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- HttpProcessor.java 2000/12/16 19:01:24 1.17
+++ HttpProcessor.java 2000/12/17 01:05:40 1.18
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.17 2000/12/16 19:01:24 remm Exp $
- * $Revision: 1.17 $
- * $Date: 2000/12/16 19:01:24 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.18 2000/12/17 01:05:40 craigmcc Exp $
+ * $Revision: 1.18 $
+ * $Date: 2000/12/17 01:05:40 $
*
* ====================================================================
*
@@ -107,7 +107,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.17 $ $Date: 2000/12/16 19:01:24 $
+ * @version $Revision: 1.18 $ $Date: 2000/12/17 01:05:40 $
*/
final class HttpProcessor
@@ -549,18 +549,22 @@
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals
(Globals.SESSION_COOKIE_NAME)) {
-
// Override anything requested in the URL
- request.setRequestedSessionId(cookies[i].getValue());
- request.setRequestedSessionCookie(true);
- request.setRequestedSessionURL(false);
- if (debug >= 1)
- log(" Requested cookie session id is " +
- ((HttpServletRequest) request.getRequest())
- .getRequestedSessionId());
- break; // Accept only the first session id value
-
+ if (!request.isRequestedSessionIdFromCookie()) {
+ // Accept only the first session id cookie
+ request.setRequestedSessionId
+ (cookies[i].getValue());
+ request.setRequestedSessionCookie(true);
+ request.setRequestedSessionURL(false);
+ if (debug >= 1)
+ log(" Requested cookie session id is " +
+ ((HttpServletRequest) request.getRequest())
+ .getRequestedSessionId());
+ }
}
+ if (debug >= 1)
+ log(" Adding cookie " + cookies[i].getName() + "=" +
+ cookies[i].getValue());
request.addCookie(cookies[i]);
}
} else if (header.equals(DefaultHeaders.CONTENT_LENGTH_NAME)) {