@Test public void testLogout() { final HttpServletRequest request = context .mock(HttpServletRequest.class); final HttpServletResponse response = context .mock(HttpServletResponse.class); final Authentication auth = context.mock(Authentication.class); final UserDetails userDetails = context.mock(UserDetails.class); final PersistentLoginRepository loginRepo = context .mock(PersistentLoginRepository.class); final UserDetailsService userDetailsService = context .mock(UserDetailsService.class); context.checking(new Expectations() { { oneOf(auth).getName(); will(returnValue("foo")); oneOf(request).getContextPath(); will(returnValue("")); oneOf(response).addCookie(with(any(Cookie.class))); oneOf(auth).getPrincipal(); will(returnValue(userDetails)); oneOf(userDetails).getUsername(); will(returnValue("username")); oneOf(loginRepo).removePersistentLogin("username"); } }); PersistentLoginService svc = new PersistentLoginService("key", userDetailsService, loginRepo); svc.logout(request, response, auth); context.assertIsSatisfied(); }
public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName())); } cancelCookie(request, response); loginRepository.removePersistentLogin(((UserDetails) authentication .getPrincipal()).getUsername()); }
PersistentLoginService extends TokenBasedRememberMeServices { public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName())); } cancelCookie(request, response); loginRepository.removePersistentLogin(((UserDetails) authentication .getPrincipal()).getUsername()); } }
PersistentLoginService extends TokenBasedRememberMeServices { public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName())); } cancelCookie(request, response); loginRepository.removePersistentLogin(((UserDetails) authentication .getPrincipal()).getUsername()); } PersistentLoginService(final String key,
            final UserDetailsService userDetailsService,
            final PersistentLoginRepository persistentLoginRepository); }
PersistentLoginService extends TokenBasedRememberMeServices { public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName())); } cancelCookie(request, response); loginRepository.removePersistentLogin(((UserDetails) authentication .getPrincipal()).getUsername()); } PersistentLoginService(final String key,
            final UserDetailsService userDetailsService,
            final PersistentLoginRepository persistentLoginRepository); UserDetails processAutoLoginCookie(final String[] cookieTokens,
            final HttpServletRequest request, final HttpServletResponse response); void onLoginSuccess(final HttpServletRequest request,
            final HttpServletResponse response,
            final Authentication successfulAuthentication); void logout(final HttpServletRequest request,
            final HttpServletResponse response, final Authentication authentication); }
PersistentLoginService extends TokenBasedRememberMeServices { public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Logout of user " + (authentication == null ? "Unknown" : authentication.getName())); } cancelCookie(request, response); loginRepository.removePersistentLogin(((UserDetails) authentication .getPrincipal()).getUsername()); } PersistentLoginService(final String key,
            final UserDetailsService userDetailsService,
            final PersistentLoginRepository persistentLoginRepository); UserDetails processAutoLoginCookie(final String[] cookieTokens,
            final HttpServletRequest request, final HttpServletResponse response); void onLoginSuccess(final HttpServletRequest request,
            final HttpServletResponse response,
            final Authentication successfulAuthentication); void logout(final HttpServletRequest request,
            final HttpServletResponse response, final Authentication authentication);  }