(주)누리웨어

화상연동/Web,APP 구축및서비스/LMS/평생교육/학점은행/기업교육/연수관리/설문구축/

XSS Filter 사용시 제외 Url 적용 하기

WEB-INF > web.xml

<!– XSS filter –>
<filter>
<filter-name>XSS</filter-name>
<filter-class>com.nuriware.filter.XssFilter</filter-class>
<init-param>
<param-name>excludePatterns</param-name>
<param-value>/servlet/*</param-value><!– 제외 url pattern –>
</init-param>
</filter>

XssFilter.java

public class XssFilter implements Filter {

private String excludePatterns;

public void init(FilterConfig filterConfig) throws ServletException {
this.excludePatterns = filterConfig.getInitParameter(“excludePatterns”);
}

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
String url = ((HttpServletRequest) request).getRequestURI().toString();
if (matchExcludePatterns(url)) {
chain.doFilter(new XssRequestWrapper((HttpServletRequest) request), response);
return;
}
}

public void destroy() {

}

public boolean matchExcludePatterns(String url) {
if(url == null) {
return false;
}
if(this.excludePatterns.equals(url)) {
return false;
}

return true;
}

}

 

 

댓글 남기기