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

            HttpServletResponse httpRes = (HttpServletResponse) response;

            HttpSession session = httpReq.getSession(true);
            String url = httpReq.getRequestURL().toString();

            if (session.getAttribute("usuariologado") == null && precisaAutenticar(url)) {
                httpRes.sendRedirect(httpReq.getContextPath() + "/faces/index.xhtml");
            } else {
                chain.doFilter(request, response);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }