content: package org.dhorse.rest.component;
  
  import java.io.IOException;
  
  import javax.servlet.Filter;
  import javax.servlet.FilterChain;
  import javax.servlet.FilterConfig;
  import javax.servlet.ServletException;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.stereotype.Component;
  
  /**
   * 为了支持CAS登录，增加跨域请求参数，该功能好像无效
   */
  @Component
  public class SecondOrigionRequestFilter implements Filter {
  
  	@Override
  	public void init(FilterConfig filterConfig) throws ServletException {
  	}
  
  	@Override
  	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
  			throws IOException, ServletException {
  		HttpServletResponse httpResponse = (HttpServletResponse) response;
  		httpResponse.setHeader("Access-Control-Allow-Origin", "*");
  		httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
  		httpResponse.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE");
  		httpResponse.setHeader("Access-Control-Max-Age", "3600");
  		chain.doFilter(request, response);
  	}
  
  	@Override
  	public void destroy() {
  	}
  }
  