@Override public SessionCookieConfig getSessionCookieConfig() { return proxy.getSessionCookieConfig(); }
@Test public void verify_cookie_tracking_mode() throws Exception { ServletContext context = mock(ServletContext.class); UaaSessionCookieConfig config = new UaaSessionCookieConfig(); SessionCookieConfig cookie = mock(SessionCookieConfig.class); when(context.getSessionCookieConfig()).thenReturn(cookie); config.setServletContext(context); ArgumentCaptor<Set<SessionTrackingMode>> tracking = ArgumentCaptor.forClass(Set.class); verify(context).setSessionTrackingModes(tracking.capture()); assertThat(tracking.getValue(), containsInAnyOrder(SessionTrackingMode.COOKIE)); } }
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (this.session.getTrackingModes() != null) { servletContext .setSessionTrackingModes(unwrap(this.session.getTrackingModes())); } configureSessionCookie(servletContext.getSessionCookieConfig()); }
@Test public void testSetServletContext() throws Exception { ServletContext context = mock(ServletContext.class); UaaSessionCookieConfig config = new UaaSessionCookieConfig(); SessionCookieConfig cookie = mock(SessionCookieConfig.class); when(context.getSessionCookieConfig()).thenReturn(cookie); doThrow(new IllegalStateException()).when(cookie).setHttpOnly(anyBoolean()); config.setServletContext(context); verify(cookie, never()).setSecure(anyBoolean()); }
SessionCookieConfig config = servletContext.getSessionCookieConfig(); if (hasText(getComment())) { logger.debug(String.format("Configuring session cookie - Comment: %s", getComment()));
SessionCookieConfig sessionCookieConfig = null; try { sessionCookieConfig = this.servletContext.getSessionCookieConfig();
@Override public SessionCookieConfig getSessionCookieConfig() { return delegatee.getSessionCookieConfig(); }
@Override public SessionCookieConfig getSessionCookieConfig() { return this.context.getSessionCookieConfig(); }
@Override public SessionCookieConfig getSessionCookieConfig() { return this.context.getSessionCookieConfig(); }
@Override public SessionCookieConfig getSessionCookieConfig() { return this.context.getSessionCookieConfig(); }
@Override public SessionCookieConfig getSessionCookieConfig() { return delegatee.getSessionCookieConfig(); }
servletContext.getSessionCookieConfig().setHttpOnly(true);
public void contextInitialized(ServletContextEvent servletContextEvent) { ServletContext servletContext = servletContextEvent.getServletContext(); SessionCookieConfig scc = servletContext.getSessionCookieConfig(); scc.setSecure(true); }
@Override public SessionCookieConfig getSessionCookieConfig() { return get().getSessionCookieConfig(); }
@Bean public ServletContextInitializer servletContextInitializer() { //otherwise the two localhost instances override each other session return servletContext -> servletContext.getSessionCookieConfig().setName("mujinaIdpSessionId"); }
public SessionCookieConfig getSessionCookieConfig() { return get().getSessionCookieConfig(); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); checkSessionCookieConfig(config.getServletContext().getSessionCookieConfig()); }
@Bean public ServletContextInitializer servletContextInitializer() { return new ServletContextInitializer() { @Override public void onStartup(ServletContext servletContext) throws ServletException { servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE)); SessionCookieConfig sessionCookieConfig=servletContext.getSessionCookieConfig(); sessionCookieConfig.setHttpOnly(true); } }; }
/** * Gets the name of the cookie where the session id is stored. * * @param application * The current we application holding the {@link javax.servlet.ServletContext}. * * @return The name set in {@link javax.servlet.SessionCookieConfig} or the default value 'JSESSIONID' if not set */ public String getSessionIdCookieName(WebApplication application) { String jsessionCookieName = application.getServletContext().getSessionCookieConfig().getName(); return jsessionCookieName == null ? DEFAULT_SESSIONID_COOKIE_NAME : jsessionCookieName; }
static String dumpContext(String event, ServletContext context) { Map<String,Object> messages=new TreeMap<String,Object>(); addMetadataMessages(context, messages); addEfectiveSessionTrackingModeMessages(messages, context.getEffectiveSessionTrackingModes()); addAttributeMessages(context, messages); addInitParameterMessages(context, messages); addSessionCookieConfigMessages(messages, context.getSessionCookieConfig()); addServletRegistrationMessages(messages, context.getServletRegistrations()); return assembleMessages(event, messages); }