@Override
    public void doFilterInternal(HttpServletRequest req, HttpServletResponse res,
                                 FilterChain chain) throws IOException, ServletException {

        if (req.getRequestURI().equals("/login")) {
            captchaContainer.add(req.getRequestedSessionId(), String.valueOf((int) Math.floor(Math.random() * 100)));
            chain.doFilter(req, res);
        } else if (!"/verify_captcha".equals(req.getRequestURI()) && SecurityContextHolder.getContext().getAuthentication() != null
                && SecurityContextHolder.getContext().getAuthentication().isAuthenticated()
                && captchaContainer.getTimeInterval(req.getRequestedSessionId()) > 1000 * 20) {
            req.getRequestDispatcher("/captcha").forward(req, res);
        } else {

            chain.doFilter(req, res);
        }
    }