class AuthorizationFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        final AuthorizationWrapper authorizationWrapper = new AuthorizationWrapper((HttpServletRequest) request);
        if (!authorizationWrapper.checkAuthorizationHeaders()) {
            LOGGER.error("Authorization headers check failed!");

            final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
            httpServletResponse.setStatus(Status.UNAUTHORIZED.getStatusCode());
            HeaderIdHelper.writeMessageToResponse(request, httpServletResponse,
                JsonHandler.createObjectNode().put("Error", "Authorization headers check failed!"));
        } else {
            chain.doFilter(request, response);
        }
    }

}