diff --git a/pom.xml b/pom.xml index b0f07600e22e1a61a82cfa0bd55ac9d63047f647..0ec823fb9bb6fc248e3ec7a0eae5b9e601e9db60 100644 --- a/pom.xml +++ b/pom.xml @@ -404,7 +404,7 @@ <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> <webApp> - <webInfIncludeJarPattern>^$</webInfIncludeJarPattern> + <webInfIncludeJarPattern>.*/spring-[^/]*\.jar$</webInfIncludeJarPattern> </webApp> <systemProperties> <systemProperty> diff --git a/src/main/java/de/thm/arsnova/config/AppInitializer.java b/src/main/java/de/thm/arsnova/config/AppInitializer.java new file mode 100644 index 0000000000000000000000000000000000000000..ec15d8da40c52684d7db0718415345bdefec0f3e --- /dev/null +++ b/src/main/java/de/thm/arsnova/config/AppInitializer.java @@ -0,0 +1,56 @@ +package de.thm.arsnova.config; + +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.filter.DelegatingFilterProxy; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +import javax.servlet.Filter; +import javax.servlet.ServletRegistration; + +public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { + @Override + protected Class<?>[] getRootConfigClasses() { + return new Class[] { + AppConfig.class, + PersistenceConfig.class, + SecurityConfig.class + }; + } + + @Override + protected Class<?>[] getServletConfigClasses() { + return new Class[0]; + } + + @Override + protected String[] getServletMappings() { + return new String[] { + "/" + }; + } + + @Override + protected Filter[] getServletFilters() { + CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8"); + DelegatingFilterProxy corsFilter = new DelegatingFilterProxy("corsFilter"); + DelegatingFilterProxy maintenanceModeFilter = new DelegatingFilterProxy("maintenanceModeFilter"); + DelegatingFilterProxy v2ContentTypeOverrideFilter = new DelegatingFilterProxy("v2ContentTypeOverrideFilter"); + + return new Filter[] { + characterEncodingFilter, + corsFilter, + maintenanceModeFilter, + v2ContentTypeOverrideFilter + }; + } + + @Override + protected void customizeRegistration(final ServletRegistration.Dynamic registration) { + registration.setInitParameter("throwExceptionIfNoHandlerFound", "true"); + } + + @Override + protected String getServletName() { + return "arsnova"; + } +} diff --git a/src/main/java/de/thm/arsnova/config/SecurityInitializer.java b/src/main/java/de/thm/arsnova/config/SecurityInitializer.java new file mode 100644 index 0000000000000000000000000000000000000000..7fe7da8c82854c1af294dc03b96d16ae530ea5d4 --- /dev/null +++ b/src/main/java/de/thm/arsnova/config/SecurityInitializer.java @@ -0,0 +1,6 @@ +package de.thm.arsnova.config; + +import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; + +public class SecurityInitializer extends AbstractSecurityWebApplicationInitializer { +} diff --git a/src/main/java/de/thm/arsnova/web/V2ContentTypeOverrideFilter.java b/src/main/java/de/thm/arsnova/web/V2ContentTypeOverrideFilter.java index b31f747b3693c331f32a4c3a678bcf8db452a1a3..8e03109caf38ea3b33527484d1719b236c6d579e 100644 --- a/src/main/java/de/thm/arsnova/web/V2ContentTypeOverrideFilter.java +++ b/src/main/java/de/thm/arsnova/web/V2ContentTypeOverrideFilter.java @@ -35,6 +35,11 @@ public class V2ContentTypeOverrideFilter extends OncePerRequestFilter { contentTypeHeaders.add(AppConfig.API_V2_MEDIA_TYPE_VALUE); } + @Override + protected boolean shouldNotFilter(final HttpServletRequest request) { + return !request.getServletPath().startsWith("/v2/"); + } + @Override protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 12a4fd76825b2c7246efeb4ca20f6aa201661c98..0000000000000000000000000000000000000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,98 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://java.sun.com/xml/ns/javaee" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" - id="WebApp_ID" version="3.0"> - <context-param> - <param-name>contextClass</param-name> - <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> - </context-param> - <context-param> - <param-name>contextConfigLocation</param-name> - <param-value> - de.thm.arsnova.config.AppConfig - de.thm.arsnova.config.PersistenceConfig - de.thm.arsnova.config.SecurityConfig - </param-value> - </context-param> - <servlet> - <servlet-name>arsnova</servlet-name> - <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> - <init-param> - <param-name>contextClass</param-name> - <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> - </init-param> - <init-param> - <param-name>throwExceptionIfNoHandlerFound</param-name> - <param-value>true</param-value> - </init-param> - <load-on-startup>1</load-on-startup> - <async-supported>true</async-supported> - </servlet> - <servlet-mapping> - <servlet-name>arsnova</servlet-name> - <url-pattern>/</url-pattern> - </servlet-mapping> - <filter> - <filter-name>springSecurityFilterChain</filter-name> - <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> - <async-supported>true</async-supported> - </filter> - <filter-mapping> - <filter-name>springSecurityFilterChain</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - <filter> - <filter-name>characterEncodingFilter</filter-name> - <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> - <init-param> - <param-name>encoding</param-name> - <param-value>UTF-8</param-value> - </init-param> - <async-supported>true</async-supported> - </filter> - <filter-mapping> - <filter-name>characterEncodingFilter</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - <listener> - <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> - </listener> - <listener> - <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> - </listener> - - <filter> - <filter-name>corsFilter</filter-name> - <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> - <async-supported>true</async-supported> - </filter> - <filter-mapping> - <filter-name>corsFilter</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter> - <filter-name>maintenanceModeFilter</filter-name> - <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> - <async-supported>true</async-supported> - </filter> - <filter-mapping> - <filter-name>maintenanceModeFilter</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter> - <filter-name>v2ContentTypeOverrideFilter</filter-name> - <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> - <async-supported>true</async-supported> - </filter> - <filter-mapping> - <filter-name>v2ContentTypeOverrideFilter</filter-name> - <url-pattern>/v2/*</url-pattern> - </filter-mapping> - - <session-config> - <tracking-mode>COOKIE</tracking-mode> - </session-config> -</web-app>