LogoutBuilder->LogoutSpec

Issue: gh-4822
This commit is contained in:
Rob Winch 2017-11-13 16:00:10 -06:00
parent 7619556066
commit 9956de8f29
2 changed files with 10 additions and 10 deletions

View File

@ -109,7 +109,7 @@ public class ServerHttpSecurity {
private FormLoginSpec formLogin; private FormLoginSpec formLogin;
private LogoutBuilder logout = new LogoutBuilder(); private LogoutSpec logout = new LogoutSpec();
private ReactiveAuthenticationManager authenticationManager; private ReactiveAuthenticationManager authenticationManager;
@ -196,9 +196,9 @@ public class ServerHttpSecurity {
return this.authorizeExchange; return this.authorizeExchange;
} }
public LogoutBuilder logout() { public LogoutSpec logout() {
if (this.logout == null) { if (this.logout == null) {
this.logout = new LogoutBuilder(); this.logout = new LogoutSpec();
} }
return this.logout; return this.logout;
} }
@ -732,26 +732,26 @@ public class ServerHttpSecurity {
* @author Shazin Sadakath * @author Shazin Sadakath
* @since 5.0 * @since 5.0
*/ */
public final class LogoutBuilder { public final class LogoutSpec {
private LogoutWebFilter logoutWebFilter = new LogoutWebFilter(); private LogoutWebFilter logoutWebFilter = new LogoutWebFilter();
public LogoutBuilder logoutHandler(ServerLogoutHandler serverLogoutHandler) { public LogoutSpec logoutHandler(ServerLogoutHandler serverLogoutHandler) {
this.logoutWebFilter.setServerLogoutHandler(serverLogoutHandler); this.logoutWebFilter.setServerLogoutHandler(serverLogoutHandler);
return this; return this;
} }
public LogoutBuilder logoutUrl(String logoutUrl) { public LogoutSpec logoutUrl(String logoutUrl) {
Assert.notNull(logoutUrl, "logoutUrl must not be null"); Assert.notNull(logoutUrl, "logoutUrl must not be null");
ServerWebExchangeMatcher requiresLogout = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, logoutUrl); ServerWebExchangeMatcher requiresLogout = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, logoutUrl);
return requiresLogout(requiresLogout); return requiresLogout(requiresLogout);
} }
public LogoutBuilder requiresLogout(ServerWebExchangeMatcher requiresLogout) { public LogoutSpec requiresLogout(ServerWebExchangeMatcher requiresLogout) {
this.logoutWebFilter.setRequiresLogout(requiresLogout); this.logoutWebFilter.setRequiresLogout(requiresLogout);
return this; return this;
} }
public LogoutBuilder logoutSuccessHandler(ServerLogoutSuccessHandler handler) { public LogoutSpec logoutSuccessHandler(ServerLogoutSuccessHandler handler) {
this.logoutWebFilter.setServerLogoutSuccessHandler(handler); this.logoutWebFilter.setServerLogoutSuccessHandler(handler);
return this; return this;
} }
@ -769,7 +769,7 @@ public class ServerHttpSecurity {
http.addFilterAt(this.logoutWebFilter, SecurityWebFiltersOrder.LOGOUT); http.addFilterAt(this.logoutWebFilter, SecurityWebFiltersOrder.LOGOUT);
} }
private LogoutBuilder() {} private LogoutSpec() {}
} }
private static class OrderedWebFilter implements WebFilter, Ordered { private static class OrderedWebFilter implements WebFilter, Ordered {

View File

@ -29,7 +29,7 @@ import org.springframework.security.test.web.reactive.server.WebTestClientBuilde
* @author Shazin Sadakath * @author Shazin Sadakath
* @since 5.0 * @since 5.0
*/ */
public class LogoutBuilderTests { public class LogoutSpecTests {
private ServerHttpSecurity http = ServerHttpSecurityConfigurationBuilder.httpWithDefaultAuthentication(); private ServerHttpSecurity http = ServerHttpSecurityConfigurationBuilder.httpWithDefaultAuthentication();