Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
0bb5e8c4b1
|
@ -48,6 +48,7 @@ import javax.servlet.http.HttpSessionListener;
|
|||
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.http.Syntax;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
|
@ -645,7 +646,7 @@ public class SessionHandler extends ScopedHandler
|
|||
HttpCookie cookie = null;
|
||||
|
||||
cookie = new HttpCookie(
|
||||
_cookieConfig.getName(),
|
||||
getSessionCookieName(_cookieConfig),
|
||||
id,
|
||||
_cookieConfig.getDomain(),
|
||||
sessionPath,
|
||||
|
@ -1334,6 +1335,13 @@ public class SessionHandler extends ScopedHandler
|
|||
public Session getSession();
|
||||
}
|
||||
|
||||
public static String getSessionCookieName(SessionCookieConfig config)
|
||||
{
|
||||
if (config == null || config.getName() == null)
|
||||
return __DefaultSessionCookie;
|
||||
return config.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* CookieConfig
|
||||
*
|
||||
|
@ -1423,6 +1431,10 @@ public class SessionHandler extends ScopedHandler
|
|||
{
|
||||
if (_context != null && _context.getContextHandler().isAvailable())
|
||||
throw new IllegalStateException("CookieConfig cannot be set after ServletContext is started");
|
||||
if ("".equals(name))
|
||||
throw new IllegalArgumentException("Blank cookie name");
|
||||
if (name != null)
|
||||
Syntax.requireValidRFC2616Token(name, "Bad Session cookie name");
|
||||
_sessionCookie = name;
|
||||
}
|
||||
|
||||
|
@ -1596,12 +1608,12 @@ public class SessionHandler extends ScopedHandler
|
|||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null && cookies.length > 0)
|
||||
{
|
||||
final String sessionCookie = getSessionCookieConfig().getName();
|
||||
for (int i = 0; i < cookies.length; i++)
|
||||
final String sessionCookie = getSessionCookieName(getSessionCookieConfig());
|
||||
for (Cookie cookie : cookies)
|
||||
{
|
||||
if (sessionCookie.equalsIgnoreCase(cookies[i].getName()))
|
||||
if (sessionCookie.equalsIgnoreCase(cookie.getName()))
|
||||
{
|
||||
String id = cookies[i].getValue();
|
||||
String id = cookie.getValue();
|
||||
requestedSessionIdFromCookie = true;
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Got Session ID {} from cookie {}", id, sessionCookie);
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.jetty.http.pathmap.ServletPathSpec;
|
|||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
|
@ -745,7 +746,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
case WebFragment:
|
||||
{
|
||||
//a web-fragment set the value, all web-fragments must have the same value
|
||||
if (!context.getSessionHandler().getSessionCookieConfig().getName().equals(name))
|
||||
if (!name.equals(SessionHandler.getSessionCookieName(context.getSessionHandler().getSessionCookieConfig())))
|
||||
throw new IllegalStateException("Conflicting cookie-config name " + name + " in " + descriptor.getResource());
|
||||
break;
|
||||
}
|
||||
|
@ -821,7 +822,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
case WebFragment:
|
||||
{
|
||||
//a web-fragment set the value, all web-fragments must have the same value
|
||||
if (!context.getSessionHandler().getSessionCookieConfig().getPath().equals(path))
|
||||
if (!path.equals(context.getSessionHandler().getSessionCookieConfig().getPath()))
|
||||
throw new IllegalStateException("Conflicting cookie-config path " + path + " in " + descriptor.getResource());
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue