HADOOP-11677. Add cookie flags for logs and static contexts. Contributed by nijel.

This commit is contained in:
Haohui Mai 2015-11-22 19:52:13 -08:00
parent 579f9030da
commit 16bcf66c1b
2 changed files with 20 additions and 0 deletions

View File

@ -836,6 +836,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-11149. Increase the timeout of TestZKFailoverController.
(Steve Loughran via wheat9)
HADOOP-11677. Add cookie flags for logs and static contexts.
(nijel via wheat9)
Release 2.7.3 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -86,6 +86,7 @@ import org.mortbay.jetty.servlet.AbstractSessionManager;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.DefaultServlet;
import org.mortbay.jetty.servlet.FilterHolder;
import org.mortbay.jetty.servlet.SessionHandler;
import org.mortbay.jetty.servlet.FilterMapping;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
@ -553,6 +554,14 @@ public final class HttpServer2 implements FilterContainer {
"org.mortbay.jetty.servlet.Default.aliases", "true");
}
logContext.setDisplayName("logs");
SessionHandler handler = new SessionHandler();
SessionManager sm = handler.getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager) sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
logContext.setSessionHandler(handler);
setContextAttributes(logContext, conf);
addNoCacheFilter(webAppContext);
defaultContexts.put(logContext, true);
@ -562,6 +571,14 @@ public final class HttpServer2 implements FilterContainer {
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
SessionHandler handler = new SessionHandler();
SessionManager sm = handler.getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager) sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
staticContext.setSessionHandler(handler);
setContextAttributes(staticContext, conf);
defaultContexts.put(staticContext, true);
}