SEC-218: Fix authentication exception cleanup of SecurityContextHolder.
This commit is contained in:
parent
8cff715599
commit
57aee4e605
|
@ -129,6 +129,25 @@ public class RememberMeProcessingFilter implements Filter, InitializingBean,
|
||||||
// Attempt authenticaton via AuthenticationManager
|
// Attempt authenticaton via AuthenticationManager
|
||||||
try {
|
try {
|
||||||
authenticationManager.authenticate(rememberMeAuth);
|
authenticationManager.authenticate(rememberMeAuth);
|
||||||
|
|
||||||
|
// Store to SecurityContextHolder
|
||||||
|
SecurityContextHolder.getContext()
|
||||||
|
.setAuthentication(rememberMeAuth);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(
|
||||||
|
"SecurityContextHolder populated with remember-me token: '"
|
||||||
|
+ SecurityContextHolder.getContext().getAuthentication()
|
||||||
|
+ "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire event
|
||||||
|
if (this.eventPublisher != null) {
|
||||||
|
eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(
|
||||||
|
SecurityContextHolder.getContext()
|
||||||
|
.getAuthentication(),
|
||||||
|
this.getClass()));
|
||||||
|
}
|
||||||
} catch (AuthenticationException authenticationException) {
|
} catch (AuthenticationException authenticationException) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
@ -139,27 +158,8 @@ public class RememberMeProcessingFilter implements Filter, InitializingBean,
|
||||||
}
|
}
|
||||||
|
|
||||||
rememberMeServices.loginFail(httpRequest, httpResponse);
|
rememberMeServices.loginFail(httpRequest, httpResponse);
|
||||||
chain.doFilter(request, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store to SecurityContextHolder
|
|
||||||
SecurityContextHolder.getContext()
|
|
||||||
.setAuthentication(rememberMeAuth);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(
|
|
||||||
"SecurityContextHolder populated with remember-me token: '"
|
|
||||||
+ SecurityContextHolder.getContext().getAuthentication()
|
|
||||||
+ "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire event
|
|
||||||
if (this.eventPublisher != null) {
|
|
||||||
eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(
|
|
||||||
SecurityContextHolder.getContext()
|
|
||||||
.getAuthentication(),
|
|
||||||
this.getClass()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
|
|
Loading…
Reference in New Issue