avoided race in FormAuth by not sending redirect until after session attribute set

This commit is contained in:
Greg Wilkins 2012-08-20 22:28:03 +10:00
parent e0276a8f65
commit c1a454c278
1 changed files with 11 additions and 10 deletions

View File

@ -216,7 +216,6 @@ public class FormAuthenticator extends LoginAuthenticator
synchronized(session)
{
nuri = (String) session.getAttribute(__J_URI);
}
if (nuri == null || nuri.length() == 0)
{
@ -224,11 +223,13 @@ public class FormAuthenticator extends LoginAuthenticator
if (nuri.length() == 0)
nuri = URIUtil.SLASH;
}
response.setContentLength(0);
response.sendRedirect(response.encodeRedirectURL(nuri));
Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
}
response.setContentLength(0);
response.sendRedirect(response.encodeRedirectURL(nuri));
return new FormAuthentication(getAuthMethod(),user);
}