Commit a3c5bcf8 authored by Maxim's avatar Maxim Committed by Matija Obreza
Browse files

Restore SessionListener

parent 108dca55
/*
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.server.config;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionListener implements HttpSessionListener {
private int sessionTimeout;
SessionListener(int sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}
@Override
public void sessionCreated(HttpSessionEvent se) {
se.getSession().setMaxInactiveInterval(sessionTimeout);
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
}
}
\ No newline at end of file
......@@ -42,12 +42,15 @@ import org.tuckey.web.filters.urlrewrite.gzip.GzipFilter;
public class WebAppInitializer implements WebApplicationInitializer {
private static final int SESSION_TIMEOUT = 60 * 60;
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfig.class);
servletContext.addListener(new ContextLoaderListener(rootContext));
servletContext.addListener(new org.genesys2.server.config.SessionListener(SESSION_TIMEOUT));
servletContext.addListener(new SessionListener());
// servletContext.setInitParameter("contextConfigLocation", "classpath:spring/application-context.xml");
......@@ -126,15 +129,6 @@ public class WebAppInitializer implements WebApplicationInitializer {
crossOriginFilter.addMappingForUrlPatterns(null, false, "/api");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/webapi");
// Hazelcast web filter configuration goes first!
FilterRegistration.Dynamic hazelcastWebFilter = servletContext
.addFilter("hazelcastWebFilter", new DelegatingFilterProxy("hazelcastWebFilter"));
hazelcastWebFilter.setInitParameter("targetFilterLifecycle", "true");
hazelcastWebFilter.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST), false, "/*");
servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain"))
.addMappingForUrlPatterns(null, false, "/*");
......@@ -155,6 +149,15 @@ public class WebAppInitializer implements WebApplicationInitializer {
localeURLFilter.addMappingForUrlPatterns(null, false, "/*");
// Hazelcast web filter configuration goes first!
FilterRegistration.Dynamic hazelcastWebFilter = servletContext
.addFilter("hazelcastWebFilter", new DelegatingFilterProxy("hazelcastWebFilter"));
hazelcastWebFilter.setInitParameter("targetFilterLifecycle", "true");
hazelcastWebFilter.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST), false, "/*");
// EnvVar filter configuration
// Adds variables to all requests
FilterRegistration.Dynamic envVarFilter = servletContext
......
......@@ -99,7 +99,6 @@ public class SpringCacheConfig {
final Properties properties = new Properties();
properties.setProperty("use-client", "false");
properties.setProperty("map-name", "jetty-sessions");
properties.setProperty("session-ttl-seconds", "21600");
properties.setProperty("sticky-session", "false");
properties.setProperty("cookie-name", "hz-session-id");
properties.setProperty("cookie-domain", cookieDomain);
......
......@@ -27,8 +27,4 @@
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
<session-config>
<!-- 60seconds * 60minutes * 6hours -->
<session-timeout>21600</session-timeout>
</session-config>
</web-app>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment