@Test public void testDoFilterUserManagerNull() throws IOException, ServletException { userManager = null; when(httpSession.getAttribute("userManager")).thenReturn(userManager); loginFilter.doFilter(httpServletRequest, httpServletResponse, filterChain); verify(httpServletResponse).sendRedirect( CONTEXT_PATH + LoginFilter.LOGIN_PAGE); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; UserManager userManager = (UserManager) httpServletRequest .getSession().getAttribute("userManager"); if (userManager != null) { if (userManager.isLoggedIn()) { LOGGER.debug("user is logged in"); filterChain.doFilter(servletRequest, servletResponse); } else { LOGGER.debug("user is not logged in"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } else { LOGGER.debug("userManager not found"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } }
LoginFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; UserManager userManager = (UserManager) httpServletRequest .getSession().getAttribute("userManager"); if (userManager != null) { if (userManager.isLoggedIn()) { LOGGER.debug("user is logged in"); filterChain.doFilter(servletRequest, servletResponse); } else { LOGGER.debug("user is not logged in"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } else { LOGGER.debug("userManager not found"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } }
LoginFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; UserManager userManager = (UserManager) httpServletRequest .getSession().getAttribute("userManager"); if (userManager != null) { if (userManager.isLoggedIn()) { LOGGER.debug("user is logged in"); filterChain.doFilter(servletRequest, servletResponse); } else { LOGGER.debug("user is not logged in"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } else { LOGGER.debug("userManager not found"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } }  }
LoginFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; UserManager userManager = (UserManager) httpServletRequest .getSession().getAttribute("userManager"); if (userManager != null) { if (userManager.isLoggedIn()) { LOGGER.debug("user is logged in"); filterChain.doFilter(servletRequest, servletResponse); } else { LOGGER.debug("user is not logged in"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } else { LOGGER.debug("userManager not found"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } }  @Override void doFilter(ServletRequest servletRequest,
            ServletResponse servletResponse, FilterChain filterChain); @Override void init(FilterConfig arg0); @Override void destroy(); }
LoginFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; UserManager userManager = (UserManager) httpServletRequest .getSession().getAttribute("userManager"); if (userManager != null) { if (userManager.isLoggedIn()) { LOGGER.debug("user is logged in"); filterChain.doFilter(servletRequest, servletResponse); } else { LOGGER.debug("user is not logged in"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } } else { LOGGER.debug("userManager not found"); httpServletResponse.sendRedirect(httpServletRequest .getContextPath() + LOGIN_PAGE); } }  @Override void doFilter(ServletRequest servletRequest,
            ServletResponse servletResponse, FilterChain filterChain); @Override void init(FilterConfig arg0); @Override void destroy(); static final String LOGIN_PAGE; }