|
42 | 42 | import org.springframework.security.core.context.SecurityContext;
|
43 | 43 | import org.springframework.security.core.context.SecurityContextHolder;
|
44 | 44 | import org.springframework.security.web.AuthenticationEntryPoint;
|
45 |
| -import org.springframework.security.web.authentication.logout.CompositeLogoutHandler; |
46 | 45 | import org.springframework.security.web.authentication.logout.LogoutHandler;
|
47 | 46 | import org.springframework.util.Assert;
|
48 | 47 | import org.springframework.util.CollectionUtils;
|
@@ -82,7 +81,7 @@ final class HttpServlet3RequestFactory implements HttpServletRequestFactory {
|
82 | 81 | private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
|
83 | 82 | private AuthenticationEntryPoint authenticationEntryPoint;
|
84 | 83 | private AuthenticationManager authenticationManager;
|
85 |
| - private LogoutHandler logoutHandler; |
| 84 | + private List<LogoutHandler> logoutHandlers; |
86 | 85 |
|
87 | 86 | HttpServlet3RequestFactory(String rolePrefix) {
|
88 | 87 | this.rolePrefix = rolePrefix;
|
@@ -146,7 +145,7 @@ public void setAuthenticationManager(AuthenticationManager authenticationManager
|
146 | 145 | * {@link HttpServletRequest#logout()}.
|
147 | 146 | */
|
148 | 147 | public void setLogoutHandlers(List<LogoutHandler> logoutHandlers) {
|
149 |
| - this.logoutHandler = CollectionUtils.isEmpty(logoutHandlers) ? null : new CompositeLogoutHandler(logoutHandlers); |
| 148 | + this.logoutHandlers = logoutHandlers; |
150 | 149 | }
|
151 | 150 |
|
152 | 151 | /**
|
@@ -246,16 +245,18 @@ public void login(String username, String password) throws ServletException {
|
246 | 245 |
|
247 | 246 | @Override
|
248 | 247 | public void logout() throws ServletException {
|
249 |
| - LogoutHandler handler = HttpServlet3RequestFactory.this.logoutHandler; |
250 |
| - if (handler == null) { |
| 248 | + List<LogoutHandler> handlers = HttpServlet3RequestFactory.this.logoutHandlers; |
| 249 | + if (CollectionUtils.isEmpty(handlers)) { |
251 | 250 | HttpServlet3RequestFactory.this.logger.debug(
|
252 | 251 | "logoutHandlers is null, so allowing original HttpServletRequest to handle logout");
|
253 | 252 | super.logout();
|
254 | 253 | return;
|
255 | 254 | }
|
256 | 255 | Authentication authentication = SecurityContextHolder.getContext()
|
257 | 256 | .getAuthentication();
|
258 |
| - handler.logout(this, this.response, authentication); |
| 257 | + for (LogoutHandler handler : handlers) { |
| 258 | + handler.logout(this, this.response, authentication); |
| 259 | + } |
259 | 260 | }
|
260 | 261 |
|
261 | 262 | private boolean isAuthenticated() {
|
|
0 commit comments