You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2004/07/07 18:39:47 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator FormAuthenticator.java DigestAuthenticator.java BasicAuthenticator.java SSLAuthenticator.java AuthenticatorBase.java
remm 2004/07/07 09:39:46
Modified: catalina/src/share/org/apache/catalina/authenticator
FormAuthenticator.java DigestAuthenticator.java
BasicAuthenticator.java SSLAuthenticator.java
AuthenticatorBase.java
Log:
- Restore the ability to easily access the internal session. Otherwise, internal components would have to use the
manager, which is far less efficient and more complex.
- Use that in the authenticators.
Revision Changes Path
1.13 +9 -9 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/FormAuthenticator.java
Index: FormAuthenticator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/FormAuthenticator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- FormAuthenticator.java 24 Jun 2004 15:28:28 -0000 1.12
+++ FormAuthenticator.java 7 Jul 2004 16:39:46 -0000 1.13
@@ -112,7 +112,7 @@
principal.getName() + "'");
// Associate the session with any existing SSO session
if (ssoId != null)
- associate(ssoId, getSession(request, true));
+ associate(ssoId, request.getSessionInternal(true));
return (true);
}
@@ -133,7 +133,7 @@
// Have we authenticated this user before but have caching disabled?
if (!cache) {
- session = getSession(request, true);
+ session = request.getSessionInternal(true);
if (log.isDebugEnabled())
log.debug("Checking for reauthenticate in session " + session);
String username =
@@ -162,7 +162,7 @@
// Is this the re-submit of the original request URI after successful
// authentication? If so, forward the *original* request instead.
if (matchRequest(request)) {
- session = getSession(request, true);
+ session = request.getSessionInternal(true);
if (log.isDebugEnabled())
log.debug("Restore request from session '" + session.getId()
+ "'");
@@ -198,7 +198,7 @@
// No -- Save this request and redirect to the form login page
if (!loginAction) {
- session = getSession(request, true);
+ session = request.getSessionInternal(true);
if (log.isDebugEnabled())
log.debug("Save request in session '" + session.getId() + "'");
saveRequest(request, session);
@@ -206,7 +206,7 @@
context.getServletContext().getRequestDispatcher
(config.getLoginPage());
try {
- disp.forward(request, response);
+ disp.forward(request.getRequest(), response.getResponse());
response.finishResponse();
} catch (Throwable t) {
log.warn("Unexpected error forwarding to login page", t);
@@ -227,7 +227,7 @@
context.getServletContext().getRequestDispatcher
(config.getErrorPage());
try {
- disp.forward(request, response);
+ disp.forward(request.getRequest(), response.getResponse());
} catch (Throwable t) {
log.warn("Unexpected error forwarding to error page", t);
}
@@ -238,7 +238,7 @@
log.debug("Authentication of '" + username + "' was successful");
if (session == null)
- session = getSession(request, false);
+ session = request.getSessionInternal(false);
if (session == null) {
if (container.getLogger().isDebugEnabled())
container.getLogger().debug("User took so long to log on the session expired");
@@ -283,7 +283,7 @@
protected boolean matchRequest(Request request) {
// Has a session been created?
- Session session = getSession(request, false);
+ Session session = request.getSessionInternal(false);
if (session == null)
return (false);
1.9 +2 -2 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/DigestAuthenticator.java
Index: DigestAuthenticator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/DigestAuthenticator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DigestAuthenticator.java 24 Jun 2004 15:28:28 -0000 1.8
+++ DigestAuthenticator.java 7 Jul 2004 16:39:46 -0000 1.9
@@ -182,7 +182,7 @@
// to get coordinated session invalidation at logout
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (ssoId != null)
- associate(ssoId, getSession(request, true));
+ associate(ssoId, request.getSessionInternal(true));
return (true);
}
1.9 +2 -2 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/BasicAuthenticator.java
Index: BasicAuthenticator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/BasicAuthenticator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BasicAuthenticator.java 24 Jun 2004 15:28:28 -0000 1.8
+++ BasicAuthenticator.java 7 Jul 2004 16:39:46 -0000 1.9
@@ -99,7 +99,7 @@
log.debug("Already authenticated '" + principal.getName() + "'");
// Associate the session with any existing SSO session
if (ssoId != null)
- associate(ssoId, getSession(request, true));
+ associate(ssoId, request.getSessionInternal(true));
return (true);
}
1.16 +2 -2 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/SSLAuthenticator.java
Index: SSLAuthenticator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/SSLAuthenticator.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SSLAuthenticator.java 24 Jun 2004 15:28:28 -0000 1.15
+++ SSLAuthenticator.java 7 Jul 2004 16:39:46 -0000 1.16
@@ -94,7 +94,7 @@
// to get coordinated session invalidation at logout
String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
if (ssoId != null)
- associate(ssoId, getSession(request, true));
+ associate(ssoId, request.getSessionInternal(true));
return (true);
}
1.23 +5 -47 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/AuthenticatorBase.java
Index: AuthenticatorBase.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/authenticator/AuthenticatorBase.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- AuthenticatorBase.java 24 Jun 2004 15:28:28 -0000 1.22
+++ AuthenticatorBase.java 7 Jul 2004 16:39:46 -0000 1.23
@@ -29,7 +29,6 @@
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpSession;
import org.apache.catalina.Authenticator;
import org.apache.catalina.Container;
@@ -37,7 +36,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Manager;
import org.apache.catalina.Pipeline;
import org.apache.catalina.Realm;
import org.apache.catalina.Session;
@@ -369,7 +367,7 @@
if (cache) {
Principal principal = request.getUserPrincipal();
if (principal == null) {
- Session session = getSession(request);
+ Session session = request.getSessionInternal();
if (session != null) {
principal = session.getPrincipal();
if (principal != null) {
@@ -611,46 +609,6 @@
/**
- * Return the internal Session that is associated with this HttpRequest,
- * or <code>null</code> if there is no such Session.
- *
- * @param request The HttpRequest we are processing
- */
- protected Session getSession(Request request) {
-
- return (getSession(request, false));
-
- }
-
-
- /**
- * Return the internal Session that is associated with this HttpRequest,
- * possibly creating a new one if necessary, or <code>null</code> if
- * there is no such session and we did not create one.
- *
- * @param request The HttpRequest we are processing
- * @param create Should we create a session if needed?
- */
- protected Session getSession(Request request, boolean create) {
-
- HttpSession hses = request.getSession(create);
- if (hses == null)
- return (null);
- Manager manager = context.getManager();
- if (manager == null)
- return (null);
- else {
- try {
- return (manager.findSession(hses.getId()));
- } catch (IOException e) {
- return (null);
- }
- }
-
- }
-
-
- /**
* Attempts reauthentication to the <code>Realm</code> using
* the credentials included in argument <code>entry</code>.
*
@@ -674,7 +632,7 @@
}
if (reauthenticated) {
- associate(ssoId, getSession(request, true));
+ associate(ssoId, request.getSessionInternal(true));
if (log.isDebugEnabled()) {
log.debug(" Reauthenticated cached principal '" +
@@ -712,7 +670,7 @@
request.setAuthType(authType);
request.setUserPrincipal(principal);
- Session session = getSession(request, false);
+ Session session = request.getSessionInternal(false);
// Cache the authentication information in our session, if any
if (cache) {
if (session != null) {
@@ -761,7 +719,7 @@
// above for this request and the user never revisits the context, the
// SSO entry will never be cleared if we don't associate the session
if (session == null)
- session = getSession(request, true);
+ session = request.getSessionInternal(true);
sso.associate(ssoId, session);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org