@Test public void notAuthenticatedWorkflow() throws IOException, ServletException { final HttpSession session = mock(HttpSession.class); final HttpServletRequest req = mock(HttpServletRequest.class); when(req.getSession(false)).thenReturn(session); final ServletResponse resp = mock(ServletResponse.class); final FilterChain chain = mock(FilterChain.class); final ISecurityContext securityContext = mock(ISecurityContext.class); when(securityContext.isAuthenticated()).thenReturn(false); final IPerson person = mock(IPerson.class); when(person.getSecurityContext()).thenReturn(securityContext); when(person.getAttribute(IPerson.USERNAME)).thenReturn("jsmith"); final IPersonManager personManager = mock(IPersonManager.class); when(personManager.getPerson(req)).thenReturn(person); final IMaxInactiveStrategy maxInactiveStrategy = mock(IMaxInactiveStrategy.class); final MaxInactiveFilter filter = new MaxInactiveFilter(); ReflectionTestUtils.setField(filter, "personManager", personManager); ReflectionTestUtils.setField(filter, "maxInactiveStrategy", maxInactiveStrategy); filter.doFilter(req, resp, chain); verify(securityContext, times(1)).isAuthenticated(); verify(person, times(1)).getSecurityContext(); verify(person, times(1)).getAttribute(IPerson.USERNAME); verify(personManager, times(1)).getPerson(req); verifyZeroInteractions(maxInactiveStrategy); verifyZeroInteractions(resp); verifyZeroInteractions(session); verify(chain, only()).doFilter(req, resp); }
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { log.debug("Entering MaxInactiveFilter"); final HttpServletRequest request = (HttpServletRequest) req; checkMaxInactive(request); log.debug("Continuing on to other filters from MaxInactiveFilter"); filterChain.doFilter(req, resp); }
MaxInactiveFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { log.debug("Entering MaxInactiveFilter"); final HttpServletRequest request = (HttpServletRequest) req; checkMaxInactive(request); log.debug("Continuing on to other filters from MaxInactiveFilter"); filterChain.doFilter(req, resp); } }
MaxInactiveFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { log.debug("Entering MaxInactiveFilter"); final HttpServletRequest request = (HttpServletRequest) req; checkMaxInactive(request); log.debug("Continuing on to other filters from MaxInactiveFilter"); filterChain.doFilter(req, resp); }  }
MaxInactiveFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { log.debug("Entering MaxInactiveFilter"); final HttpServletRequest request = (HttpServletRequest) req; checkMaxInactive(request); log.debug("Continuing on to other filters from MaxInactiveFilter"); filterChain.doFilter(req, resp); }  @Override void init(FilterConfig filterConfig); @Override void destroy(); @Override void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain); }
MaxInactiveFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { log.debug("Entering MaxInactiveFilter"); final HttpServletRequest request = (HttpServletRequest) req; checkMaxInactive(request); log.debug("Continuing on to other filters from MaxInactiveFilter"); filterChain.doFilter(req, resp); }  @Override void init(FilterConfig filterConfig); @Override void destroy(); @Override void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain); static final String SESSION_MAX_INACTIVE_SET_ATTR; static final int REFRESH_MINUTES; }