SEC-623: Added login success and failure hooks to RememberMeProcessingFilter. Also moved MockApplicationEventPublisher implementations to a single class.

This commit is contained in:
Luke Taylor
2008-01-07 15:06:29 +00:00
parent 814b2fc7ea
commit c5bc0fc683
5 changed files with 93 additions and 85 deletions

View File

@@ -89,6 +89,8 @@ public class RememberMeProcessingFilter extends SpringSecurityFilter implements
// Store to SecurityContextHolder
SecurityContextHolder.getContext().setAuthentication(rememberMeAuth);
onSuccessfulAuthentication(request, response, rememberMeAuth);
if (logger.isDebugEnabled()) {
logger.debug("SecurityContextHolder populated with remember-me token: '"
+ SecurityContextHolder.getContext().getAuthentication() + "'");
@@ -107,6 +109,8 @@ public class RememberMeProcessingFilter extends SpringSecurityFilter implements
}
rememberMeServices.loginFail(request, response);
onUnsuccessfulAuthentication(request, response, authenticationException);
}
}
@@ -121,6 +125,23 @@ public class RememberMeProcessingFilter extends SpringSecurityFilter implements
}
}
/**
* Called if a remember-me token is presented and successfully authenticated by the <tt>RememberMeServices</tt>
* <tt>autoLogin</tt> method and the <tt>AuthenticationManager</tt>.
*/
protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
Authentication authResult) {
}
/**
* Called if the <tt>AuthenticationManager</tt> rejects the authentication object returned from the
* <tt>RememberMeServices</tt> <tt>autoLogin</tt> method. This method will not be called when no remember-me
* token is present in the request and <tt>autoLogin</tt> returns null.
*/
protected void onUnsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
AuthenticationException failed) {
}
public RememberMeServices getRememberMeServices() {
return rememberMeServices;
}