From 4fa9b4dd15c562e63eb152118d87757549bdb8bf Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Sun, 29 Oct 2017 21:00:10 -0500 Subject: [PATCH] Add ServerHttpSecurity.exceptionHandling() Fixes gh-4750 --- .../config/web/server/ServerHttpSecurity.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java b/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java index b16577bbc6..00b165d33c 100644 --- a/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java @@ -96,6 +96,8 @@ public class ServerHttpSecurity { private CsrfBuilder csrf = new CsrfBuilder(); + private ExceptionHandlingBuilder exceptionHandling = new ExceptionHandlingBuilder(); + private HttpBasicBuilder httpBasic; private FormLoginBuilder formLogin; @@ -173,6 +175,13 @@ public class ServerHttpSecurity { return this.headers; } + public ExceptionHandlingBuilder exceptionHandling() { + if(this.exceptionHandling == null) { + this.exceptionHandling = new ExceptionHandlingBuilder(); + } + return this.exceptionHandling; + } + public AuthorizeExchangeBuilder authorizeExchange() { if(this.authorizeExchangeBuilder == null) { this.authorizeExchangeBuilder = new AuthorizeExchangeBuilder(); @@ -404,6 +413,23 @@ public class ServerHttpSecurity { private CsrfBuilder() {} } + /** + * @author Rob Winch + * @since 5.0 + */ + public class ExceptionHandlingBuilder { + public ExceptionHandlingBuilder serverAuthenticationEntryPoint(ServerAuthenticationEntryPoint authenticationEntryPoint) { + ServerHttpSecurity.this.serverAuthenticationEntryPoint = authenticationEntryPoint; + return this; + } + + public ServerHttpSecurity and() { + return ServerHttpSecurity.this; + } + + private ExceptionHandlingBuilder() {} + } + /** * @author Rob Winch * @since 5.0