@Test public void shouldSetSessionTimeoutAndStore() throws ServletException, IOException { MotechUser user = new MotechUser(); user.setUserName("testUser"); user.setFailureLoginCounter(3); when(authentication.getName()).thenReturn("testUser"); when(motechUsersDao.findByUserName("testUser")).thenReturn(user); when(request.getSession()).thenReturn(session); when(settingService.getSessionTimeout()).thenReturn(500); motechLoginSuccessHandler.onAuthenticationSuccess(request, response, authentication); verify(session).setMaxInactiveInterval(500); verify(sessionHandler).addSession(session); }
@Override @Transactional public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { super.onAuthenticationSuccess(request, response, authentication); LOGGER.info("User {} logged in", authentication.getName()); LOGGER.debug("Authorities for {}: {}", authentication.getName(), authentication.getAuthorities()); MotechUser motechUser = motechUsersDao.findByUserName(authentication.getName()); motechUser.setFailureLoginCounter(0); motechUsersDao.update(motechUser); HttpSession session = request.getSession(); session.setMaxInactiveInterval(settingService.getSessionTimeout()); sessionHandler.addSession(session); }
MotechLoginSuccessHandler extends MotechLoginSuccessJSONHandler { @Override @Transactional public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { super.onAuthenticationSuccess(request, response, authentication); LOGGER.info("User {} logged in", authentication.getName()); LOGGER.debug("Authorities for {}: {}", authentication.getName(), authentication.getAuthorities()); MotechUser motechUser = motechUsersDao.findByUserName(authentication.getName()); motechUser.setFailureLoginCounter(0); motechUsersDao.update(motechUser); HttpSession session = request.getSession(); session.setMaxInactiveInterval(settingService.getSessionTimeout()); sessionHandler.addSession(session); } }
MotechLoginSuccessHandler extends MotechLoginSuccessJSONHandler { @Override @Transactional public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { super.onAuthenticationSuccess(request, response, authentication); LOGGER.info("User {} logged in", authentication.getName()); LOGGER.debug("Authorities for {}: {}", authentication.getName(), authentication.getAuthorities()); MotechUser motechUser = motechUsersDao.findByUserName(authentication.getName()); motechUser.setFailureLoginCounter(0); motechUsersDao.update(motechUser); HttpSession session = request.getSession(); session.setMaxInactiveInterval(settingService.getSessionTimeout()); sessionHandler.addSession(session); }  }
MotechLoginSuccessHandler extends MotechLoginSuccessJSONHandler { @Override @Transactional public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { super.onAuthenticationSuccess(request, response, authentication); LOGGER.info("User {} logged in", authentication.getName()); LOGGER.debug("Authorities for {}: {}", authentication.getName(), authentication.getAuthorities()); MotechUser motechUser = motechUsersDao.findByUserName(authentication.getName()); motechUser.setFailureLoginCounter(0); motechUsersDao.update(motechUser); HttpSession session = request.getSession(); session.setMaxInactiveInterval(settingService.getSessionTimeout()); sessionHandler.addSession(session); }  @Override @Transactional void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
                                        Authentication authentication); }
MotechLoginSuccessHandler extends MotechLoginSuccessJSONHandler { @Override @Transactional public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { super.onAuthenticationSuccess(request, response, authentication); LOGGER.info("User {} logged in", authentication.getName()); LOGGER.debug("Authorities for {}: {}", authentication.getName(), authentication.getAuthorities()); MotechUser motechUser = motechUsersDao.findByUserName(authentication.getName()); motechUser.setFailureLoginCounter(0); motechUsersDao.update(motechUser); HttpSession session = request.getSession(); session.setMaxInactiveInterval(settingService.getSessionTimeout()); sessionHandler.addSession(session); }  @Override @Transactional void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
                                        Authentication authentication);  }