diff --git a/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java b/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java index fd8f70fa21..78e19123f7 100644 --- a/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java @@ -24,8 +24,8 @@ import org.springframework.security.authorization.AuthenticatedReactiveAuthoriza import org.springframework.security.authorization.AuthorityReactiveAuthorizationManager; import org.springframework.security.authorization.AuthorizationDecision; import org.springframework.security.authorization.ReactiveAuthorizationManager; -import org.springframework.security.web.server.AuthenticationEntryPoint; -import org.springframework.security.web.server.DelegatingAuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; +import org.springframework.security.web.server.DelegatingServerAuthenticationEntryPoint; import org.springframework.security.web.server.ServerFormLoginAuthenticationConverter; import org.springframework.security.web.server.ServerHttpBasicAuthenticationConverter; import org.springframework.security.web.server.MatcherSecurityWebFilterChain; @@ -33,12 +33,12 @@ import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.security.web.server.authentication.AuthenticationEntryPointFailureHandler; import org.springframework.security.web.server.authentication.AuthenticationFailureHandler; import org.springframework.security.web.server.authentication.AuthenticationWebFilter; -import org.springframework.security.web.server.authentication.RedirectAuthenticationEntryPoint; +import org.springframework.security.web.server.authentication.RedirectServerAuthenticationEntryPoint; import org.springframework.security.web.server.authentication.RedirectAuthenticationSuccessHandler; import org.springframework.security.web.server.authentication.logout.LogoutHandler; import org.springframework.security.web.server.authentication.logout.LogoutWebFilter; import org.springframework.security.web.server.authentication.logout.SecurityContextRepositoryLogoutHandler; -import org.springframework.security.web.server.authentication.www.HttpBasicAuthenticationEntryPoint; +import org.springframework.security.web.server.authentication.www.HttpBasicServerAuthenticationEntryPoint; import org.springframework.security.web.server.authorization.AuthorizationContext; import org.springframework.security.web.server.authorization.AuthorizationWebFilter; import org.springframework.security.web.server.authorization.DelegatingReactiveAuthorizationManager; @@ -73,7 +73,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import static org.springframework.security.web.server.DelegatingAuthenticationEntryPoint.DelegateEntry; +import static org.springframework.security.web.server.DelegatingServerAuthenticationEntryPoint.DelegateEntry; /** * @author Rob Winch @@ -96,7 +96,7 @@ public class HttpSecurity { private SecurityContextRepository securityContextRepository; - private AuthenticationEntryPoint authenticationEntryPoint; + private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint; private List defaultEntryPoints = new ArrayList<>(); @@ -193,7 +193,7 @@ public class HttpSecurity { if(this.securityContextRepository != null) { this.formLogin.securityContextRepository(this.securityContextRepository); } - if(this.formLogin.authenticationEntryPoint == null) { + if(this.formLogin.serverAuthenticationEntryPoint == null) { this.webFilters.add(new OrderedWebFilter(new LoginPageGeneratingWebFilter(), SecurityWebFiltersOrder.LOGIN_PAGE_GENERATING.getOrder())); } this.formLogin.configure(this); @@ -203,10 +203,11 @@ public class HttpSecurity { } this.addFilterAt(new AuthenticationReactorContextFilter(), SecurityWebFiltersOrder.AUTHENTICATION_CONTEXT); if(this.authorizeExchangeBuilder != null) { - AuthenticationEntryPoint authenticationEntryPoint = getAuthenticationEntryPoint(); + ServerAuthenticationEntryPoint serverAuthenticationEntryPoint = getServerAuthenticationEntryPoint(); ExceptionTranslationWebFilter exceptionTranslationWebFilter = new ExceptionTranslationWebFilter(); - if(authenticationEntryPoint != null) { - exceptionTranslationWebFilter.setAuthenticationEntryPoint(authenticationEntryPoint); + if(serverAuthenticationEntryPoint != null) { + exceptionTranslationWebFilter.setServerAuthenticationEntryPoint( + serverAuthenticationEntryPoint); } this.addFilterAt(exceptionTranslationWebFilter, SecurityWebFiltersOrder.EXCEPTION_TRANSLATION); this.authorizeExchangeBuilder.configure(this); @@ -215,14 +216,14 @@ public class HttpSecurity { return new MatcherSecurityWebFilterChain(getSecurityMatcher(), this.webFilters); } - private AuthenticationEntryPoint getAuthenticationEntryPoint() { - if(this.authenticationEntryPoint != null || this.defaultEntryPoints.isEmpty()) { - return this.authenticationEntryPoint; + private ServerAuthenticationEntryPoint getServerAuthenticationEntryPoint() { + if(this.serverAuthenticationEntryPoint != null || this.defaultEntryPoints.isEmpty()) { + return this.serverAuthenticationEntryPoint; } if(this.defaultEntryPoints.size() == 1) { return this.defaultEntryPoints.get(0).getEntryPoint(); } - DelegatingAuthenticationEntryPoint result = new DelegatingAuthenticationEntryPoint(this.defaultEntryPoints); + DelegatingServerAuthenticationEntryPoint result = new DelegatingServerAuthenticationEntryPoint(this.defaultEntryPoints); result.setDefaultEntryPoint(this.defaultEntryPoints.get(this.defaultEntryPoints.size() - 1).getEntryPoint()); return result; } @@ -323,7 +324,7 @@ public class HttpSecurity { private SecurityContextRepository securityContextRepository = new ServerWebExchangeAttributeSecurityContextRepository(); - private AuthenticationEntryPoint entryPoint = new HttpBasicAuthenticationEntryPoint(); + private ServerAuthenticationEntryPoint entryPoint = new HttpBasicServerAuthenticationEntryPoint(); public HttpBasicBuilder authenticationManager(ReactiveAuthenticationManager authenticationManager) { this.authenticationManager = authenticationManager; @@ -374,7 +375,7 @@ public class HttpSecurity { private SecurityContextRepository securityContextRepository = new WebSessionSecurityContextRepository(); - private AuthenticationEntryPoint authenticationEntryPoint; + private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint; private ServerWebExchangeMatcher requiresAuthenticationMatcher; @@ -386,14 +387,14 @@ public class HttpSecurity { } public FormLoginBuilder loginPage(String loginPage) { - this.authenticationEntryPoint = new RedirectAuthenticationEntryPoint(loginPage); + this.serverAuthenticationEntryPoint = new RedirectServerAuthenticationEntryPoint(loginPage); this.requiresAuthenticationMatcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, loginPage); - this.authenticationFailureHandler = new AuthenticationEntryPointFailureHandler(new RedirectAuthenticationEntryPoint(loginPage + "?error")); + this.authenticationFailureHandler = new AuthenticationEntryPointFailureHandler(new RedirectServerAuthenticationEntryPoint(loginPage + "?error")); return this; } - public FormLoginBuilder authenticationEntryPoint(AuthenticationEntryPoint authenticationEntryPoint) { - this.authenticationEntryPoint = authenticationEntryPoint; + public FormLoginBuilder authenticationEntryPoint(ServerAuthenticationEntryPoint serverAuthenticationEntryPoint) { + this.serverAuthenticationEntryPoint = serverAuthenticationEntryPoint; return this; } @@ -422,13 +423,13 @@ public class HttpSecurity { } protected void configure(HttpSecurity http) { - if(this.authenticationEntryPoint == null) { + if(this.serverAuthenticationEntryPoint == null) { loginPage("/login"); } MediaTypeServerWebExchangeMatcher htmlMatcher = new MediaTypeServerWebExchangeMatcher( MediaType.TEXT_HTML); htmlMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL)); - HttpSecurity.this.defaultEntryPoints.add(0, new DelegateEntry(htmlMatcher, this.authenticationEntryPoint)); + HttpSecurity.this.defaultEntryPoints.add(0, new DelegateEntry(htmlMatcher, this.serverAuthenticationEntryPoint)); AuthenticationWebFilter authenticationFilter = new AuthenticationWebFilter( this.authenticationManager); authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher); diff --git a/webflux/src/main/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPoint.java b/webflux/src/main/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPoint.java similarity index 83% rename from webflux/src/main/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPoint.java rename to webflux/src/main/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPoint.java index d36646938e..da283d7a5d 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPoint.java +++ b/webflux/src/main/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPoint.java @@ -31,20 +31,21 @@ import java.util.List; * @author Rob Winch * @since 5.0 */ -public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPoint { +public class DelegatingServerAuthenticationEntryPoint + implements ServerAuthenticationEntryPoint { private final Flux entryPoints; - private AuthenticationEntryPoint defaultEntryPoint = (exchange, e) -> { + private ServerAuthenticationEntryPoint defaultEntryPoint = (exchange, e) -> { exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED); return exchange.getResponse().setComplete(); }; - public DelegatingAuthenticationEntryPoint( + public DelegatingServerAuthenticationEntryPoint( DelegateEntry... entryPoints) { this(Arrays.asList(entryPoints)); } - public DelegatingAuthenticationEntryPoint( + public DelegatingServerAuthenticationEntryPoint( List entryPoints) { this.entryPoints = Flux.fromIterable(entryPoints); } @@ -68,16 +69,16 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo * EntryPoint which is used when no RequestMatcher returned true */ public void setDefaultEntryPoint( - AuthenticationEntryPoint defaultEntryPoint) { + ServerAuthenticationEntryPoint defaultEntryPoint) { this.defaultEntryPoint = defaultEntryPoint; } public static class DelegateEntry { private final ServerWebExchangeMatcher matcher; - private final AuthenticationEntryPoint entryPoint; + private final ServerAuthenticationEntryPoint entryPoint; public DelegateEntry(ServerWebExchangeMatcher matcher, - AuthenticationEntryPoint entryPoint) { + ServerAuthenticationEntryPoint entryPoint) { this.matcher = matcher; this.entryPoint = entryPoint; } @@ -86,7 +87,7 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo return this.matcher; } - public AuthenticationEntryPoint getEntryPoint() { + public ServerAuthenticationEntryPoint getEntryPoint() { return this.entryPoint; } } diff --git a/webflux/src/main/java/org/springframework/security/web/server/AuthenticationEntryPoint.java b/webflux/src/main/java/org/springframework/security/web/server/ServerAuthenticationEntryPoint.java similarity index 95% rename from webflux/src/main/java/org/springframework/security/web/server/AuthenticationEntryPoint.java rename to webflux/src/main/java/org/springframework/security/web/server/ServerAuthenticationEntryPoint.java index f63bc4682c..4b658fa5c3 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/AuthenticationEntryPoint.java +++ b/webflux/src/main/java/org/springframework/security/web/server/ServerAuthenticationEntryPoint.java @@ -25,7 +25,7 @@ import org.springframework.web.server.ServerWebExchange; * @author Rob Winch * @since 5.0 */ -public interface AuthenticationEntryPoint { +public interface ServerAuthenticationEntryPoint { Mono commence(ServerWebExchange exchange, AuthenticationException e); } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandler.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandler.java index 95cd2cf5d5..5d5193d56e 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandler.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandler.java @@ -17,7 +17,7 @@ package org.springframework.security.web.server.authentication; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.server.AuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.security.web.server.WebFilterExchange; import org.springframework.util.Assert; import reactor.core.publisher.Mono; @@ -27,17 +27,18 @@ import reactor.core.publisher.Mono; * @since 5.0 */ public class AuthenticationEntryPointFailureHandler implements AuthenticationFailureHandler { - private final AuthenticationEntryPoint authenticationEntryPoint; + private final ServerAuthenticationEntryPoint serverAuthenticationEntryPoint; public AuthenticationEntryPointFailureHandler( - AuthenticationEntryPoint authenticationEntryPoint) { - Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null"); - this.authenticationEntryPoint = authenticationEntryPoint; + ServerAuthenticationEntryPoint serverAuthenticationEntryPoint) { + Assert.notNull(serverAuthenticationEntryPoint, "authenticationEntryPoint cannot be null"); + this.serverAuthenticationEntryPoint = serverAuthenticationEntryPoint; } @Override public Mono onAuthenticationFailure(WebFilterExchange webFilterExchange, AuthenticationException exception) { - return this.authenticationEntryPoint.commence(webFilterExchange.getExchange(), exception); + return this.serverAuthenticationEntryPoint + .commence(webFilterExchange.getExchange(), exception); } } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java index 9885d7bb5a..68b6fb1678 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java @@ -25,7 +25,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextImpl; import org.springframework.security.web.server.ServerHttpBasicAuthenticationConverter; import org.springframework.security.web.server.WebFilterExchange; -import org.springframework.security.web.server.authentication.www.HttpBasicAuthenticationEntryPoint; +import org.springframework.security.web.server.authentication.www.HttpBasicServerAuthenticationEntryPoint; import org.springframework.security.web.server.context.SecurityContextRepository; import org.springframework.security.web.server.context.SecurityContextRepositoryServerWebExchange; import org.springframework.security.web.server.context.ServerWebExchangeAttributeSecurityContextRepository; @@ -49,7 +49,7 @@ public class AuthenticationWebFilter implements WebFilter { private Function> authenticationConverter = new ServerHttpBasicAuthenticationConverter(); - private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationEntryPointFailureHandler(new HttpBasicAuthenticationEntryPoint()); + private AuthenticationFailureHandler authenticationFailureHandler = new AuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint()); private SecurityContextRepository securityContextRepository = new ServerWebExchangeAttributeSecurityContextRepository(); diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPoint.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPoint.java similarity index 88% rename from webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPoint.java rename to webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPoint.java index 52d786c517..6382a6d4a6 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPoint.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPoint.java @@ -23,7 +23,7 @@ import org.springframework.security.web.server.ServerRedirectStrategy; import reactor.core.publisher.Mono; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.server.AuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.util.Assert; import org.springframework.web.server.ServerWebExchange; @@ -33,12 +33,13 @@ import org.springframework.web.server.ServerWebExchange; * @author Rob Winch * @since 5.0 */ -public class RedirectAuthenticationEntryPoint implements AuthenticationEntryPoint { +public class RedirectServerAuthenticationEntryPoint + implements ServerAuthenticationEntryPoint { private final URI location; private ServerRedirectStrategy serverRedirectStrategy = new DefaultServerRedirectStrategy(); - public RedirectAuthenticationEntryPoint(String location) { + public RedirectServerAuthenticationEntryPoint(String location) { Assert.notNull(location, "location cannot be null"); this.location = URI.create(location); } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPoint.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPoint.java similarity index 91% rename from webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPoint.java rename to webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPoint.java index c566cb698e..af90e2170e 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPoint.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPoint.java @@ -18,7 +18,7 @@ package org.springframework.security.web.server.authentication.www; import org.springframework.http.HttpStatus; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.server.AuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.util.Assert; import org.springframework.web.server.ServerWebExchange; @@ -29,7 +29,8 @@ import reactor.core.publisher.Mono; * @author Rob Winch * @since 5.0 */ -public class HttpBasicAuthenticationEntryPoint implements AuthenticationEntryPoint { +public class HttpBasicServerAuthenticationEntryPoint + implements ServerAuthenticationEntryPoint { private static final String WWW_AUTHENTICATE = "WWW-Authenticate"; private static final String DEFAULT_REALM = "Realm"; private static String WWW_AUTHENTICATE_FORMAT = "Basic realm=\"%s\""; diff --git a/webflux/src/main/java/org/springframework/security/web/server/authorization/AuthorizationWebFilter.java b/webflux/src/main/java/org/springframework/security/web/server/authorization/AuthorizationWebFilter.java index 300cd5f7cd..eb146026bd 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authorization/AuthorizationWebFilter.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authorization/AuthorizationWebFilter.java @@ -17,9 +17,6 @@ package org.springframework.security.web.server.authorization; import org.springframework.security.authorization.ReactiveAuthorizationManager; -import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; -import org.springframework.security.web.server.AuthenticationEntryPoint; -import org.springframework.security.web.server.authentication.www.HttpBasicAuthenticationEntryPoint; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; diff --git a/webflux/src/main/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilter.java b/webflux/src/main/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilter.java index 4498f08d88..893bd8e2e0 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilter.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilter.java @@ -20,8 +20,8 @@ import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; -import org.springframework.security.web.server.AuthenticationEntryPoint; -import org.springframework.security.web.server.authentication.www.HttpBasicAuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; +import org.springframework.security.web.server.authentication.www.HttpBasicServerAuthenticationEntryPoint; import org.springframework.util.Assert; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; @@ -33,7 +33,7 @@ import org.springframework.web.server.WebFilterChain; * @since 5.0 */ public class ExceptionTranslationWebFilter implements WebFilter { - private AuthenticationEntryPoint authenticationEntryPoint = new HttpBasicAuthenticationEntryPoint(); + private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint = new HttpBasicServerAuthenticationEntryPoint(); private AccessDeniedHandler accessDeniedHandler = new HttpStatusAccessDeniedHandler(HttpStatus.FORBIDDEN); @@ -58,17 +58,17 @@ public class ExceptionTranslationWebFilter implements WebFilter { /** * Sets the authentication entry point used when authentication is required - * @param authenticationEntryPoint the authentication entry point to use. Default is - * {@link HttpBasicAuthenticationEntryPoint} + * @param serverAuthenticationEntryPoint the authentication entry point to use. Default is + * {@link HttpBasicServerAuthenticationEntryPoint} */ - public void setAuthenticationEntryPoint( - AuthenticationEntryPoint authenticationEntryPoint) { - Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null"); - this.authenticationEntryPoint = authenticationEntryPoint; + public void setServerAuthenticationEntryPoint( + ServerAuthenticationEntryPoint serverAuthenticationEntryPoint) { + Assert.notNull(serverAuthenticationEntryPoint, "authenticationEntryPoint cannot be null"); + this.serverAuthenticationEntryPoint = serverAuthenticationEntryPoint; } private Mono commenceAuthentication(ServerWebExchange exchange, AccessDeniedException denied) { - return this.authenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied)) + return this.serverAuthenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied)) .then(Mono.empty()); } } diff --git a/webflux/src/test/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPointTests.java b/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java similarity index 88% rename from webflux/src/test/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPointTests.java rename to webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java index f2940ff6b8..2458d611f8 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/DelegatingAuthenticationEntryPointTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -import static org.springframework.security.web.server.DelegatingAuthenticationEntryPoint.*; +import static org.springframework.security.web.server.DelegatingServerAuthenticationEntryPoint.*; /** * @author Rob Winch * @since 5.0 */ @RunWith(MockitoJUnitRunner.class) -public class DelegatingAuthenticationEntryPointTests { +public class DelegatingServerAuthenticationEntryPointTests { private ServerWebExchange exchange = MockServerHttpRequest.get("/").toExchange(); @Mock @@ -47,12 +47,12 @@ public class DelegatingAuthenticationEntryPointTests { @Mock private ServerWebExchangeMatcher matcher2; @Mock - private AuthenticationEntryPoint delegate1; + private ServerAuthenticationEntryPoint delegate1; @Mock - private AuthenticationEntryPoint delegate2; + private ServerAuthenticationEntryPoint delegate2; private AuthenticationException e = new AuthenticationCredentialsNotFoundException("Log In"); - private DelegatingAuthenticationEntryPoint entryPoint; + private DelegatingServerAuthenticationEntryPoint entryPoint; @Test public void commenceWhenNotMatchThenMatchThenOnlySecondDelegateInvoked() { @@ -62,7 +62,7 @@ public class DelegatingAuthenticationEntryPointTests { when(this.matcher2.matches(this.exchange)).thenReturn( ServerWebExchangeMatcher.MatchResult.match()); when(this.delegate2.commence(this.exchange, this.e)).thenReturn(expectedResult); - this.entryPoint = new DelegatingAuthenticationEntryPoint( + this.entryPoint = new DelegatingServerAuthenticationEntryPoint( new DelegateEntry(this.matcher1, this.delegate1), new DelegateEntry(this.matcher2, this.delegate2)); @@ -78,7 +78,7 @@ public class DelegatingAuthenticationEntryPointTests { public void commenceWhenNotMatchThenDefault() { when(this.matcher1.matches(this.exchange)).thenReturn( ServerWebExchangeMatcher.MatchResult.notMatch()); - this.entryPoint = new DelegatingAuthenticationEntryPoint( + this.entryPoint = new DelegatingServerAuthenticationEntryPoint( new DelegateEntry(this.matcher1, this.delegate1)); this.entryPoint.commence(this.exchange, this.e).block(); diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java index 2fafb706ef..3338c85377 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java @@ -61,7 +61,7 @@ public class RedirectAuthenticationSuccessHandlerTests { @Test(expected = IllegalArgumentException.class) public void constructorStringWhenNullLocationThenException() { - new RedirectAuthenticationEntryPoint((String) null); + new RedirectServerAuthenticationEntryPoint((String) null); } @Test diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPointTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java similarity index 92% rename from webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPointTests.java rename to webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java index 7888f319e8..9d259af96f 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationEntryPointTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationEntryPointTests.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.when; * @since 5.0 */ @RunWith(MockitoJUnitRunner.class) -public class RedirectAuthenticationEntryPointTests { +public class RedirectServerAuthenticationEntryPointTests { @Mock private ServerWebExchange exchange; @@ -48,15 +48,15 @@ public class RedirectAuthenticationEntryPointTests { private String location = "/login"; - private RedirectAuthenticationEntryPoint entryPoint = - new RedirectAuthenticationEntryPoint("/login"); + private RedirectServerAuthenticationEntryPoint entryPoint = + new RedirectServerAuthenticationEntryPoint("/login"); private AuthenticationException exception = new AuthenticationCredentialsNotFoundException("Authentication Required"); @Test(expected = IllegalArgumentException.class) public void constructorStringWhenNullLocationThenException() { - new RedirectAuthenticationEntryPoint((String) null); + new RedirectServerAuthenticationEntryPoint((String) null); } @Test diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandlerTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/ServerAuthenticationEntryPointFailureHandlerTests.java similarity index 81% rename from webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandlerTests.java rename to webflux/src/test/java/org/springframework/security/web/server/authentication/ServerAuthenticationEntryPointFailureHandlerTests.java index 384a1989f8..867b7d838f 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationEntryPointFailureHandlerTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/ServerAuthenticationEntryPointFailureHandlerTests.java @@ -24,7 +24,7 @@ import org.mockito.junit.MockitoJUnitRunner; import reactor.core.publisher.Mono; import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.web.server.AuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.security.web.server.WebFilterExchange; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilterChain; @@ -37,9 +37,9 @@ import static org.mockito.Mockito.when; * @since 5.0 */ @RunWith(MockitoJUnitRunner.class) -public class AuthenticationEntryPointFailureHandlerTests { +public class ServerAuthenticationEntryPointFailureHandlerTests { @Mock - private AuthenticationEntryPoint authenticationEntryPoint; + private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint; @Mock private ServerWebExchange exchange; @Mock @@ -53,15 +53,15 @@ public class AuthenticationEntryPointFailureHandlerTests { @Test(expected = IllegalArgumentException.class) public void constructorWhenNullEntryPointThenException() { - this.authenticationEntryPoint = null; - new AuthenticationEntryPointFailureHandler(this.authenticationEntryPoint); + this.serverAuthenticationEntryPoint = null; + new AuthenticationEntryPointFailureHandler(this.serverAuthenticationEntryPoint); } @Test public void onAuthenticationFailureWhenInvokedThenDelegatesToEntryPoint() { Mono result = Mono.empty(); BadCredentialsException e = new BadCredentialsException("Failed"); - when(this.authenticationEntryPoint.commence(this.exchange, e)).thenReturn(result); + when(this.serverAuthenticationEntryPoint.commence(this.exchange, e)).thenReturn(result); assertThat(this.handler.onAuthenticationFailure(this.filterExchange, e)).isEqualTo(result); } diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPointTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPointTests.java similarity index 94% rename from webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPointTests.java rename to webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPointTests.java index cd33b3d539..4ab97973ed 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicAuthenticationEntryPointTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/www/HttpBasicServerAuthenticationEntryPointTests.java @@ -35,10 +35,10 @@ import static org.mockito.Mockito.verifyZeroInteractions; * @since 5.0 */ @RunWith(MockitoJUnitRunner.class) -public class HttpBasicAuthenticationEntryPointTests { +public class HttpBasicServerAuthenticationEntryPointTests { @Mock private ServerWebExchange exchange; - private HttpBasicAuthenticationEntryPoint entryPoint = new HttpBasicAuthenticationEntryPoint(); + private HttpBasicServerAuthenticationEntryPoint entryPoint = new HttpBasicServerAuthenticationEntryPoint(); private AuthenticationException exception = new AuthenticationCredentialsNotFoundException("Authenticate"); diff --git a/webflux/src/test/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilterTests.java b/webflux/src/test/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilterTests.java index 7daafc9bef..9c1d0c4520 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilterTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authorization/ExceptionTranslationWebFilterTests.java @@ -30,7 +30,7 @@ import reactor.test.publisher.PublisherProbe; import org.springframework.http.HttpStatus; import org.springframework.mock.http.server.reactive.MockServerHttpResponse; import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.server.AuthenticationEntryPoint; +import org.springframework.security.web.server.ServerAuthenticationEntryPoint; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilterChain; @@ -53,7 +53,7 @@ public class ExceptionTranslationWebFilterTests { @Mock private AccessDeniedHandler deniedHandler; @Mock - private AuthenticationEntryPoint entryPoint; + private ServerAuthenticationEntryPoint entryPoint; private PublisherProbe deniedPublisher = PublisherProbe.empty(); private PublisherProbe entryPointPublisher = PublisherProbe.empty(); @@ -66,7 +66,7 @@ public class ExceptionTranslationWebFilterTests { when(this.deniedHandler.handle(any(), any())).thenReturn(this.deniedPublisher.mono()); when(this.entryPoint.commence(any(), any())).thenReturn(this.entryPointPublisher.mono()); - this.filter.setAuthenticationEntryPoint(this.entryPoint); + this.filter.setServerAuthenticationEntryPoint(this.entryPoint); this.filter.setAccessDeniedHandler(this.deniedHandler); } @@ -155,6 +155,6 @@ public class ExceptionTranslationWebFilterTests { @Test(expected = IllegalArgumentException.class) public void setAuthenticationEntryPointWhenNullThenException() { - this.filter.setAuthenticationEntryPoint(null); + this.filter.setServerAuthenticationEntryPoint(null); } }