Author: remy.maucherat(a)jboss.com
Date: 2009-04-09 17:16:01 -0400 (Thu, 09 Apr 2009)
New Revision: 1004
Modified:
trunk/java/org/apache/catalina/Authenticator.java
trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/Response.java
Log:
- Use response type from the Servlet API for authenticate.
Modified: trunk/java/org/apache/catalina/Authenticator.java
===================================================================
--- trunk/java/org/apache/catalina/Authenticator.java 2009-04-09 19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/Authenticator.java 2009-04-09 21:16:01 UTC (rev 1004)
@@ -24,23 +24,17 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
/**
* An <b>Authenticator</b> is a component (usually a Valve or Container)
that
- * provides some sort of authentication service. The interface itself has no
- * functional significance, but is used as a tagging mechanism so that other
- * components can detect the presence (via an "instanceof Authenticator" test)
- * of an already configured authentication service.
+ * provides some sort of authentication service.
*
* @author Craig R. McClanahan
* @version $Revision$ $Date$
*/
public interface Authenticator {
- public boolean login(Request request, Response response)
- throws IOException, ServletException;
public boolean login(Request request, HttpServletResponse response)
throws IOException, ServletException;
}
Modified: trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 2009-04-09
19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 2009-04-09
21:16:01 UTC (rev 1004)
@@ -370,7 +370,7 @@
/**
- * Login.
+ * API login.
*
* @param request Request we are processing
* @param response Response we are creating
@@ -379,30 +379,13 @@
*
* @exception IOException if an input/output error occurs
*/
- public boolean login(Request request, Response response)
+ public boolean login(Request request, HttpServletResponse response)
throws IOException, ServletException {
return authenticate(request, response, this.context.getLoginConfig());
}
/**
- * Login.
- *
- * @param request Request we are processing
- * @param response Response we are creating
- * @param config Login configuration describing how authentication
- * should be performed
- *
- * @exception IOException if an input/output error occurs
- */
- public boolean login(Request request, HttpServletResponse response)
- throws IOException, ServletException {
- // FIXME: use the wrapper
- return login(request, request.getResponse());
- }
-
-
- /**
* Enforce the security restrictions in the web application deployment
* descriptor of our associated Context.
*
@@ -595,7 +578,7 @@
* @exception IOException if an input/output error occurs
*/
protected abstract boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException;
@@ -734,7 +717,7 @@
* @param username Username used to authenticate (if any)
* @param password Password used to authenticate (if any)
*/
- protected void register(Request request, Response response,
+ protected void register(Request request, HttpServletResponse response,
Principal principal, String authType,
String username, String password) {
Modified: trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java 2009-04-09
19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java 2009-04-09
21:16:01 UTC (rev 1004)
@@ -25,14 +25,12 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.util.Base64;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
@@ -114,7 +112,7 @@
* @exception IOException if an input/output error occurs
*/
public boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException {
@@ -189,7 +187,7 @@
// Send an "unauthorized" response and an appropriate challenge
MessageBytes authenticate =
- response.getCoyoteResponse().getMimeHeaders()
+ request.getResponse().getCoyoteResponse().getMimeHeaders()
.addValue(AUTHENTICATE_BYTES, 0, AUTHENTICATE_BYTES.length);
CharChunk authenticateCC = authenticate.getCharChunk();
authenticateCC.append("Basic realm=\"");
Modified: trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java 2009-04-09
19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java 2009-04-09
21:16:01 UTC (rev 1004)
@@ -27,14 +27,11 @@
import javax.servlet.http.HttpServletResponse;
-
import org.apache.catalina.Realm;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.util.MD5Encoder;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
@@ -127,7 +124,7 @@
* @exception IOException if an input/output error occurs
*/
public boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException {
@@ -399,7 +396,7 @@
* @param nOnce nonce token
*/
protected void setAuthenticateHeader(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config,
String nOnce) {
Modified: trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java 2009-04-09
19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java 2009-04-09
21:16:01 UTC (rev 1004)
@@ -33,7 +33,6 @@
import org.apache.catalina.Realm;
import org.apache.catalina.Session;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.coyote.ActionCode;
import org.apache.tomcat.util.buf.ByteChunk;
@@ -41,7 +40,6 @@
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.MimeHeaders;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
@@ -121,7 +119,7 @@
* @exception IOException if an input/output error occurs
*/
public boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException {
@@ -221,7 +219,6 @@
uriCC.setLimit(-1);
String contextPath = request.getContextPath();
String requestURI = request.getDecodedRequestURI();
- response.setContext(request.getContext());
// Is this the action request from the login page?
boolean loginAction =
@@ -308,13 +305,12 @@
* @param config Login configuration describing how authentication
* should be performed
*/
- protected void forwardToLoginPage(Request request, Response response, LoginConfig
config) {
+ protected void forwardToLoginPage(Request request, HttpServletResponse response,
LoginConfig config) {
RequestDispatcher disp =
context.getServletContext().getRequestDispatcher
(config.getLoginPage());
try {
- disp.forward(request.getRequest(), response.getResponse());
- response.finishResponse();
+ disp.forward(request.getRequest(), response);
} catch (Throwable t) {
log.warn("Unexpected error forwarding to login page", t);
}
@@ -329,12 +325,12 @@
* @param config Login configuration describing how authentication
* should be performed
*/
- protected void forwardToErrorPage(Request request, Response response, LoginConfig
config) {
+ protected void forwardToErrorPage(Request request, HttpServletResponse response,
LoginConfig config) {
RequestDispatcher disp =
context.getServletContext().getRequestDispatcher
(config.getErrorPage());
try {
- disp.forward(request.getRequest(), response.getResponse());
+ disp.forward(request.getRequest(), response);
} catch (Throwable t) {
log.warn("Unexpected error forwarding to error page", t);
}
Modified: trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java 2009-04-09
19:25:39 UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java 2009-04-09
21:16:01 UTC (rev 1004)
@@ -21,8 +21,9 @@
import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
@@ -79,7 +80,7 @@
* @exception IOException if an input/output error occurs
*/
public boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException {
Modified: trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java 2009-04-09 19:25:39
UTC (rev 1003)
+++ trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java 2009-04-09 21:16:01
UTC (rev 1004)
@@ -25,12 +25,11 @@
import javax.servlet.http.HttpServletResponse;
-import org.apache.coyote.ActionCode;
import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
import org.apache.catalina.deploy.LoginConfig;
+import org.apache.coyote.ActionCode;
@@ -82,7 +81,7 @@
* @exception IOException if an input/output error occurs
*/
public boolean authenticate(Request request,
- Response response,
+ HttpServletResponse response,
LoginConfig config)
throws IOException {
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-09 19:25:39 UTC (rev
1003)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-09 21:16:01 UTC (rev
1004)
@@ -2928,11 +2928,7 @@
public boolean login(HttpServletResponse response) throws IOException,
ServletException {
if (context.getAuthenticator() != null) {
- if (!WRAPPED_RESPONSE_IN_LOGIN || response instanceof ResponseFacade) {
- return context.getAuthenticator().login(this, this.response);
- } else {
- return context.getAuthenticator().login(this, response);
- }
+ return context.getAuthenticator().login(this, response);
} else {
throw new
ServletException(sm.getString("coyoteRequest.noAuthenticator"));
}
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2009-04-09 19:25:39 UTC (rev
1003)
+++ trunk/java/org/apache/catalina/connector/Response.java 2009-04-09 21:16:01 UTC (rev
1004)
@@ -38,7 +38,6 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Session;
import org.apache.catalina.Wrapper;
@@ -159,26 +158,6 @@
/**
- * Return the Context within which this Request is being processed.
- */
- public Context getContext() {
- return (request.getContext());
- }
-
- /**
- * Set the Context within which this Request is being processed. This
- * must be called as soon as the appropriate Context is identified, because
- * it identifies the value to be returned by
<code>getContextPath()</code>,
- * and thus enables parsing of the request URI.
- *
- * @param context The newly associated Context
- */
- public void setContext(Context context) {
- request.setContext(context);
- }
-
-
- /**
* The associated output buffer.
*/
protected OutputBuffer outputBuffer;
@@ -857,7 +836,7 @@
return;
}
- CharsetMapper cm = getContext().getCharsetMapper();
+ CharsetMapper cm = request.getContext().getCharsetMapper();
String charset = cm.getCharset( locale );
if ( charset != null ){
coyoteResponse.setCharacterEncoding(charset);
@@ -1503,7 +1482,7 @@
if (serverPort != urlPort)
return (false);
- String contextPath = getContext().getPath();
+ String contextPath = request.getContext().getPath();
if (contextPath != null) {
String file = url.getFile();
if ((file == null) || !file.startsWith(contextPath))