package de.ivu.elect.jee.faces;

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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * ELECT-4082
 */
public class SecurityHeaderFilter implements Filter {


  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
// nichts zu tun
  }

  @Override
  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    setSecurityHeader(servletRequest, servletResponse);
    filterChain.doFilter(servletRequest, servletResponse);
  }

  protected void setSecurityHeader(ServletRequest servletRequest, ServletResponse servletResponse) {
    HttpSecurityHeader.apply((HttpServletRequest)servletRequest, (HttpServletResponse) servletResponse);
  }

  @Override
  public void destroy() {
    // nichts zu tun
  }
}
