class CorsFilter implements Filter {

    @Override
    public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain )
            throws IOException, ServletException
    {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;

        response.setHeader( ACCESS_CONTROL_ALLOW_ORIGIN, accessControlAllowOrigin );
        if ( vary != null )
        {
            response.setHeader( VARY, vary );
        }

        Enumeration<String> requestMethodEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_METHOD );
        if ( requestMethodEnumeration != null )
        {
            while ( requestMethodEnumeration.hasMoreElements() )
            {
                String requestMethod = requestMethodEnumeration.nextElement();
                addAllowedMethodIfValid( requestMethod, response );
            }
        }

        Enumeration<String> requestHeaderEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_HEADERS );
        if ( requestHeaderEnumeration != null )
        {
            while ( requestHeaderEnumeration.hasMoreElements() )
            {
                String requestHeader = requestHeaderEnumeration.nextElement();
                addAllowedHeaderIfValid( requestHeader, response );
            }
        }

        chain.doFilter( request, response );
    }

    public  CorsFilter( LogProvider logProvider, String accessControlAllowOrigin );

}