Commit c6cb490e authored by Aleksandr Sharaban's avatar Aleksandr Sharaban Committed by Matija Obreza
Browse files

Migrated spring-security.xml and spring-security-oauth.xml to Java Config

parent 118d7260
......@@ -26,12 +26,20 @@ import javax.servlet.SessionTrackingMode;
import com.hazelcast.web.SessionListener;
import org.genesys2.server.servlet.filter.EnvVariablesFilter;
import org.genesys2.server.servlet.filter.LocaleURLFilter;
import org.genesys2.server.servlet.filter.NewGUIFilter;
import org.genesys2.server.servlet.filter.WebApiFilter;
import org.genesys2.spring.config.ApplicationConfig;
import org.genesys2.spring.config.SpringServletConfig;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;
import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter;
public class WebAppInitializer implements WebApplicationInitializer {
......@@ -42,6 +50,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfig.class);
servletContext.addListener(new com.hazelcast.web.SessionListener());
servletContext.addListener(new SessionListener());
servletContext.addListener(new ContextLoaderListener(rootContext));
servletContext.addListener(new org.genesys2.server.config.SessionListener(SESSION_TIMEOUT));
......@@ -90,7 +99,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
private void registerFilters(ServletContext servletContext, AnnotationConfigWebApplicationContext appContext) {
// UrlRewrite filter configuration
FilterRegistration.Dynamic urlRewriteFilter = servletContext
.addFilter("urlRewriteFilter", "org.tuckey.web.filters.urlrewrite.UrlRewriteFilter");
.addFilter("urlRewriteFilter", UrlRewriteFilter.class);
urlRewriteFilter.setInitParameter("confReloadCheckInterval", "10");
// urlRewriteFilter.setInitParameter("logLevel", "sysout:DEBUG");
......@@ -100,7 +109,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
// Encoding filter configuration
FilterRegistration.Dynamic encodingFilter = servletContext
.addFilter("encodingFilter", "org.springframework.web.filter.CharacterEncodingFilter");
.addFilter("encodingFilter", CharacterEncodingFilter.class);
encodingFilter.setInitParameter("encoding", "UTF-8");
encodingFilter.setInitParameter("forceEncoding", "true");
......@@ -119,12 +128,15 @@ public class WebAppInitializer implements WebApplicationInitializer {
crossOriginFilter.setInitParameter("chainPreflight", "false");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/oauth/token");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/api/*");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/webapi/*");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/api");
crossOriginFilter.addMappingForUrlPatterns(null, false, "/webapi");
servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain"))
.addMappingForUrlPatterns(null, false, "/*");
// Hazelcast web filter configuration
FilterRegistration.Dynamic hazelcastWebFilter = servletContext
.addFilter("hazelcastWebFilter", "org.springframework.web.filter.DelegatingFilterProxy");
.addFilter("hazelcastWebFilter", new DelegatingFilterProxy("hazelcastWebFilter"));
hazelcastWebFilter.setInitParameter("targetFilterLifecycle", "true");
......@@ -132,15 +144,15 @@ public class WebAppInitializer implements WebApplicationInitializer {
EnumSet.of(DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST), false, "/*");
// Filter chain proxy configuration
FilterRegistration.Dynamic filterChainProxy = servletContext
/* FilterRegistration.Dynamic filterChainProxy = servletContext
.addFilter("org.springframework.security.filterChainProxy",
"org.springframework.web.filter.DelegatingFilterProxy");
filterChainProxy.addMappingForUrlPatterns(null, false, "/*");
filterChainProxy.addMappingForUrlPatterns(null, false, "*//*");*/
// Locale URL filter configuration
FilterRegistration.Dynamic localeURLFilter = servletContext
.addFilter("localeURLFilter", "org.genesys2.server.servlet.filter.LocaleURLFilter");
.addFilter("localeURLFilter", LocaleURLFilter.class);
localeURLFilter.setInitParameter("exclude-paths", "/html /login-attempt");
localeURLFilter.setInitParameter("default-locale", "en");
......@@ -151,25 +163,25 @@ public class WebAppInitializer implements WebApplicationInitializer {
// EnvVar filter configuration
// Adds variables to all requests
FilterRegistration.Dynamic envVarFilter = servletContext
.addFilter("envVarFilter", "org.springframework.web.filter.DelegatingFilterProxy");
.addFilter("envVarFilter", EnvVariablesFilter.class);
envVarFilter.addMappingForUrlPatterns(null, false, "/*");
// Genesys Web API Filter configuration
FilterRegistration.Dynamic webApiFilter = servletContext
.addFilter("webApiFilter", "org.springframework.web.filter.DelegatingFilterProxy");
.addFilter("webApiFilter", WebApiFilter.class);
webApiFilter.addMappingForUrlPatterns(null, false, "/webapi/*");
// Sitemesh filter configuration
FilterRegistration.Dynamic sitemeshFilter = servletContext
.addFilter("sitemesh", "org.sitemesh.config.ConfigurableSiteMeshFilter");
.addFilter("sitemesh", ConfigurableSiteMeshFilter.class);
sitemeshFilter.addMappingForUrlPatterns(null, false, "/*");
// New GUI filter configuration
FilterRegistration.Dynamic newGUIFilter = servletContext
.addFilter("newGUIFilter", "org.genesys2.server.servlet.filter.NewGUIFilter");
.addFilter("newGUIFilter", NewGUIFilter.class);
newGUIFilter.setInitParameter("exclude-paths", "/html /login-attempt");
......
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