List of usage examples for javax.servlet ServletContext setSessionTrackingModes
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes);
From source file:org.utb.project.ServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { WebApplicationContext webApplicationContext = getWebContext(); servletContext.setSessionTrackingModes(new HashSet<SessionTrackingMode>() { {//from ww w .j a v a2 s.c o m add(SessionTrackingMode.COOKIE); } }); servletContext.addListener(new ContextLoaderListener(webApplicationContext)); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("ProyectoSoftware", new DispatcherServlet(webApplicationContext)); dispatcher.setAsyncSupported(true); dispatcher.setLoadOnStartup(0); dispatcher.addMapping("/*"); }
From source file:org.unidle.config.DispatcherServletInitializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext.setSessionTrackingModes(EnumSet.of(COOKIE)); final DelegatingFilterProxy wroFilter = servletContext.createFilter(DelegatingFilterProxy.class); wroFilter.setTargetFilterLifecycle(true); wroFilter.setBeanName("wroFilter"); servletContext.addFilter("wroFilter", wroFilter).addMappingForUrlPatterns(null, false, "/resources/*"); }
From source file:fr.univlorraine.mondossierweb.Initializer.java
/** * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) */// w ww. j a v a 2 s. c o m @Override public void onStartup(ServletContext servletContext) throws ServletException { addContextParametersToSystemProperties(servletContext); /* Configure les sessions */ Set<SessionTrackingMode> sessionTrackingModes = new HashSet<SessionTrackingMode>(); sessionTrackingModes.add(SessionTrackingMode.COOKIE); servletContext.setSessionTrackingModes(sessionTrackingModes); servletContext.addListener(new HttpSessionListener() { @Override public void sessionCreated(HttpSessionEvent httpSessionEvent) { // sans nouvelle requte, on garde la session active 4 minutes httpSessionEvent.getSession().setMaxInactiveInterval(240); } @Override public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { } }); /* Gestion des sessions dans Atmosphere (Push Vaadin) */ servletContext.addListener(SessionSupport.class); /* Configure Spring */ AnnotationConfigWebApplicationContext springContext = new AnnotationConfigWebApplicationContext(); if (!Boolean.valueOf(servletContext.getInitParameter(Constants.SERVLET_PARAMETER_PRODUCTION_MODE))) { springContext.getEnvironment().setActiveProfiles(DEBUG_PROFILE); } springContext.register(SpringConfig.class); servletContext.addListener(new ContextLoaderListener(springContext)); servletContext.addListener(new RequestContextListener()); /* Filtre Spring Security */ FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class); springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*"); /* Filtre passant l'utilisateur courant Logback */ FilterRegistration.Dynamic userMdcServletFilter = servletContext.addFilter("userMdcServletFilter", UserMdcServletFilter.class); userMdcServletFilter.addMappingForUrlPatterns(null, false, "/*"); /* Filtre Spring Mobile permettant de dtecter le device */ FilterRegistration.Dynamic springMobileServletFilter = servletContext .addFilter("deviceResolverRequestFilter", DeviceResolverRequestFilter.class); springMobileServletFilter.addMappingForUrlPatterns(null, false, "/*"); /* Servlet Spring-Vaadin */ //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", JMeterServlet.class); //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", SpringVaadinServlet.class); ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", fr.univlorraine.mondossierweb.utils.MdwSpringVaadinServlet.class); springVaadinServlet.setLoadOnStartup(1); springVaadinServlet.addMapping("/*"); /* Dfini le bean UI */ //springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwUIProvider"); /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */ springVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT"); /* Dfini la frquence du heartbeat en secondes (cf. https://vaadin.com/book/vaadin7/-/page/application.lifecycle.html#application.lifecycle.ui-expiration) */ springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL, String.valueOf(30)); /* Configure le Push */ springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE, Boolean.valueOf(servletContext.getInitParameter("enablePush")) ? PushMode.AUTOMATIC.name() : PushMode.DISABLED.name()); /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */ springVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3, String.valueOf(true)); /* Active le support des requtes asynchrones */ springVaadinServlet.setAsyncSupported(true); /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */ springVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS, RecoverSecurityContextAtmosphereInterceptor.class.getName()); /* Spring-Vaadin Touchkit Servlet */ ServletRegistration.Dynamic springTouchkitVaadinServlet = servletContext.addServlet("springTouchkitVaadin", MDWTouchkitServlet.class); //springTouchkitVaadinServlet.setLoadOnStartup(1); springTouchkitVaadinServlet.addMapping("/m/*"); /* Dfini le bean UI */ //springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwTouchkitUIProvider"); /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */ springTouchkitVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT"); springTouchkitVaadinServlet.setInitParameter(Constants.PARAMETER_WIDGETSET, "fr.univlorraine.mondossierweb.AppWidgetset"); /* Configure le Push */ springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE, PushMode.DISABLED.name()); /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */ springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3, String.valueOf(true)); /* Active le support des requtes asynchrones */ springTouchkitVaadinServlet.setAsyncSupported(true); /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */ springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS, RecoverSecurityContextAtmosphereInterceptor.class.getName()); }
From source file:io.lavagna.config.DispatcherServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); // initialize cookie if (StringUtils.isNotEmpty(System.getProperty(CookieNames.PROPERTY_NAME))) { CookieNames.updatePrefix(System.getProperty(CookieNames.PROPERTY_NAME)); }/* w w w .ja v a2 s. c om*/ // //definition order = execution order, the first executed filter is HSTSFilter addFilter(servletContext, "HSTSFilter", HSTSFilter.class, "/*"); addFilter(servletContext, "CSFRFilter", CSFRFilter.class, "/*"); addFilter(servletContext, "RememberMeFilter", RememberMeFilter.class, "/*"); addFilter(servletContext, "AnonymousUserFilter", AnonymousUserFilter.class, "/*"); addFilter(servletContext, "SecurityFilter", SecurityFilter.class, "/*"); addFilter(servletContext, "ETagFilter", ShallowEtagHeaderFilter.class, "*.js", "*.css", // "/", "/project/*", "/admin/*", "/me/", // "*.html", "*.woff", "*.eot", "*.svg", "*.ttf"); addFilter(servletContext, "GzipFilter", GzipFilter.class, "*.js", "*.css", // "/", "/project/*", "/admin/*", "/me/", // "/api/self", "/api/board/*", "/api/project/*"); servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE)); servletContext.getSessionCookieConfig().setHttpOnly(true); servletContext.getSessionCookieConfig().setName(CookieNames.getSessionCookieName()); }
From source file:org.codelibs.fess.helper.ViewHelper.java
@PostConstruct public void init() { final FessConfig fessConfig = ComponentUtil.getFessConfig(); escapedHighlightPre = LaFunctions.h(originalHighlightTagPre); escapedHighlightPost = LaFunctions.h(originalHighlightTagPost); highlightTagPre = fessConfig.getQueryHighlightTagPre(); highlightTagPost = fessConfig.getQueryHighlightTagPost(); highlightedFields = fessConfig.getQueryHighlightContentDescriptionFieldsAsArray(); fessConfig.getQueryHighlightTerminalChars().codePoints().forEach(hihglightTerminalCharSet::add); try {/*from ww w .j av a 2 s. c om*/ final ServletContext servletContext = ComponentUtil.getComponent(ServletContext.class); servletContext.setSessionTrackingModes(fessConfig.getSessionTrackingModesAsSet().stream() .map(SessionTrackingMode::valueOf).collect(Collectors.toSet())); } catch (final Throwable e) { logger.warn("Failed to set SessionTrackingMode.", e); } }