Access to cookie config with accessor method (#5526)

With this minimal change one can provide different cookie configs for the same SessionHandler
without coping the whole method into the inherited class.

Signed-off-by: Dejan Pecar <dejan.pecar@abacus.ch>
This commit is contained in:
dejpec 2020-11-25 14:24:29 +01:00 committed by GitHub
parent 497a908895
commit 22c6b8fced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -640,7 +640,8 @@ public class SessionHandler extends ScopedHandler
{
if (isUsingCookies())
{
String sessionPath = (_cookieConfig.getPath() == null) ? contextPath : _cookieConfig.getPath();
SessionCookieConfig cookieConfig = getSessionCookieConfig();
String sessionPath = (cookieConfig.getPath() == null) ? contextPath : cookieConfig.getPath();
sessionPath = (StringUtil.isEmpty(sessionPath)) ? "/" : sessionPath;
String id = getExtendedId(session);
HttpCookie cookie = null;
@ -648,14 +649,14 @@ public class SessionHandler extends ScopedHandler
cookie = new HttpCookie(
getSessionCookieName(_cookieConfig),
id,
_cookieConfig.getDomain(),
cookieConfig.getDomain(),
sessionPath,
_cookieConfig.getMaxAge(),
_cookieConfig.isHttpOnly(),
_cookieConfig.isSecure() || (isSecureRequestOnly() && requestIsSecure),
HttpCookie.getCommentWithoutAttributes(_cookieConfig.getComment()),
cookieConfig.getMaxAge(),
cookieConfig.isHttpOnly(),
cookieConfig.isSecure() || (isSecureRequestOnly() && requestIsSecure),
HttpCookie.getCommentWithoutAttributes(cookieConfig.getComment()),
0,
HttpCookie.getSameSiteFromComment(_cookieConfig.getComment()));
HttpCookie.getSameSiteFromComment(cookieConfig.getComment()));
return cookie;
}