Search in sources :

Example 6 with ServletFilter

use of org.sonar.api.web.ServletFilter in project sonarqube by SonarSource.

the class MasterServletFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
    HttpServletRequest hsr = (HttpServletRequest) request;
    if (filters.length == 0) {
        chain.doFilter(hsr, response);
    } else {
        String path = hsr.getRequestURI().replaceFirst(hsr.getContextPath(), "");
        GodFilterChain godChain = new GodFilterChain(chain);
        for (ServletFilter filter : filters) {
            if (filter.doGetPattern().matches(path)) {
                godChain.addFilter(filter);
            }
        }
        godChain.doFilter(hsr, response);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletFilter(org.sonar.api.web.ServletFilter)

Aggregations

ServletFilter (org.sonar.api.web.ServletFilter)6 Test (org.junit.Test)4 FilterConfig (javax.servlet.FilterConfig)2 MasterServletFilter (org.sonar.server.platform.web.MasterServletFilter)2 RegisterServletFilters (org.sonar.server.platform.web.RegisterServletFilters)2 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1