=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-api-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -30,7 +30,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -16,7 +16,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + encoding-filter === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/servlet/filter/ExcludableShallowEtagHeaderFilter.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/servlet/filter/ExcludableShallowEtagHeaderFilter.java 2015-10-06 14:48:17 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/servlet/filter/ExcludableShallowEtagHeaderFilter.java 2015-10-06 15:57:15 +0000 @@ -32,39 +32,70 @@ import java.util.regex.Pattern; import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.filter.ShallowEtagHeaderFilter; /** - * Subclass of Spring ShallowEtagHeaderFilter which ignores specific URL patterns. + * Subclass of {@link org.springframework.web.filter.ShallowEtagHeaderFilter} which allows exclusion of URIs matching a regex. + * + * The regex is given as the init-param named 'excludeUriRegex' in the filter configuration. + * + * Example configuration: + * {@code + * + * ShallowEtagHeaderFilter + * org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + * + * excludeUriRegex + * /api/dataValues|/api/dataValues/files + * + * + * } + * + * The example exactly matches and excludes any request to the '/api/dataValues' and '/api/dataValues/files' from the filter. * * @author Lars Helge Overland + * @author Halvdan Hoem Grelland */ public class ExcludableShallowEtagHeaderFilter extends ShallowEtagHeaderFilter { - private static final String EXCLUDE_REGEX = "/api/dataValueSets|/api/dataValues|/api/fileResources"; - + private static final String EXCLUDE_URI_REGEX_NAME = "excludeUriRegex"; + + private Pattern pattern = null; + + @Override + protected void initFilterBean() + throws ServletException + { + FilterConfig filterConfig = getFilterConfig(); + + String excludeRegex = filterConfig != null ? filterConfig.getInitParameter( EXCLUDE_URI_REGEX_NAME ) : ""; + + if ( StringUtils.isNotBlank( excludeRegex ) ) + { + pattern = Pattern.compile( excludeRegex ); + } + } + @Override protected void doFilterInternal( HttpServletRequest request, HttpServletResponse response, FilterChain filterChain ) throws ServletException, IOException { String uri = request.getRequestURI(); - - if ( Pattern.matches( EXCLUDE_REGEX, uri ) ) + + if ( pattern != null && pattern.matcher( uri ).matches() ) { - // Proceed without invoking this filter - - filterChain.doFilter( request, response ); + filterChain.doFilter( request, response ); // Proceed without invoking this filter } else { - // Do invoke this filter - - super.doFilterInternal( request, response, filterChain ); + super.doFilterInternal( request, response, filterChain ); // Invoke this filter } } } === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-light/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -24,7 +24,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-ohie/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-ohie/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -20,7 +20,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + hiddenHttpMethodFilter === modified file 'dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -26,7 +26,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + hiddenHttpMethodFilter === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-sms/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-sms/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-sms/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/WEB-INF/web.xml 2015-10-06 12:20:26 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/WEB-INF/web.xml 2015-10-06 15:57:15 +0000 @@ -28,7 +28,11 @@ shallowEtagHeaderFilter - org.springframework.web.filter.ShallowEtagHeaderFilter + org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilter + + excludeUriRegex + /api/dataValueSets|/api/dataValues|/api/dataValues/files|/api/fileResources + springSecurityFilterChain