serverAuthenticationEntryPoint->authenticationEntryPoint
Issue: gh-4822
This commit is contained in:
+5
-5
@@ -28,18 +28,18 @@ import reactor.core.publisher.Mono;
|
||||
*/
|
||||
public class ServerAuthenticationEntryPointFailureHandler
|
||||
implements ServerAuthenticationFailureHandler {
|
||||
private final ServerAuthenticationEntryPoint serverAuthenticationEntryPoint;
|
||||
private final ServerAuthenticationEntryPoint authenticationEntryPoint;
|
||||
|
||||
public ServerAuthenticationEntryPointFailureHandler(
|
||||
ServerAuthenticationEntryPoint serverAuthenticationEntryPoint) {
|
||||
Assert.notNull(serverAuthenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
this.serverAuthenticationEntryPoint = serverAuthenticationEntryPoint;
|
||||
ServerAuthenticationEntryPoint authenticationEntryPoint) {
|
||||
Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
this.authenticationEntryPoint = authenticationEntryPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> onAuthenticationFailure(WebFilterExchange webFilterExchange,
|
||||
AuthenticationException exception) {
|
||||
return this.serverAuthenticationEntryPoint
|
||||
return this.authenticationEntryPoint
|
||||
.commence(webFilterExchange.getExchange(), exception);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -33,7 +33,7 @@ import org.springframework.web.server.WebFilterChain;
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ExceptionTranslationWebFilter implements WebFilter {
|
||||
private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint = new HttpBasicServerAuthenticationEntryPoint();
|
||||
private ServerAuthenticationEntryPoint authenticationEntryPoint = new HttpBasicServerAuthenticationEntryPoint();
|
||||
|
||||
private ServerAccessDeniedHandler serverAccessDeniedHandler = new HttpStatusServerAccessDeniedHandler(HttpStatus.FORBIDDEN);
|
||||
|
||||
@@ -59,17 +59,17 @@ public class ExceptionTranslationWebFilter implements WebFilter {
|
||||
|
||||
/**
|
||||
* Sets the authentication entry point used when authentication is required
|
||||
* @param serverAuthenticationEntryPoint the authentication entry point to use. Default is
|
||||
* @param authenticationEntryPoint the authentication entry point to use. Default is
|
||||
* {@link HttpBasicServerAuthenticationEntryPoint}
|
||||
*/
|
||||
public void setServerAuthenticationEntryPoint(
|
||||
ServerAuthenticationEntryPoint serverAuthenticationEntryPoint) {
|
||||
Assert.notNull(serverAuthenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
this.serverAuthenticationEntryPoint = serverAuthenticationEntryPoint;
|
||||
public void setAuthenticationEntryPoint(
|
||||
ServerAuthenticationEntryPoint authenticationEntryPoint) {
|
||||
Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
this.authenticationEntryPoint = authenticationEntryPoint;
|
||||
}
|
||||
|
||||
private <T> Mono<T> commenceAuthentication(ServerWebExchange exchange, AccessDeniedException denied) {
|
||||
return this.serverAuthenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied))
|
||||
return this.authenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied))
|
||||
.then(Mono.empty());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.when;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ServerAuthenticationEntryPointFailureHandlerTests {
|
||||
@Mock
|
||||
private ServerAuthenticationEntryPoint serverAuthenticationEntryPoint;
|
||||
private ServerAuthenticationEntryPoint authenticationEntryPoint;
|
||||
@Mock
|
||||
private ServerWebExchange exchange;
|
||||
@Mock
|
||||
@@ -53,15 +53,15 @@ public class ServerAuthenticationEntryPointFailureHandlerTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void constructorWhenNullEntryPointThenException() {
|
||||
this.serverAuthenticationEntryPoint = null;
|
||||
new ServerAuthenticationEntryPointFailureHandler(this.serverAuthenticationEntryPoint);
|
||||
this.authenticationEntryPoint = null;
|
||||
new ServerAuthenticationEntryPointFailureHandler(this.authenticationEntryPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAuthenticationFailureWhenInvokedThenDelegatesToEntryPoint() {
|
||||
Mono<Void> result = Mono.empty();
|
||||
BadCredentialsException e = new BadCredentialsException("Failed");
|
||||
when(this.serverAuthenticationEntryPoint.commence(this.exchange, e)).thenReturn(result);
|
||||
when(this.authenticationEntryPoint.commence(this.exchange, e)).thenReturn(result);
|
||||
|
||||
assertThat(this.handler.onAuthenticationFailure(this.filterExchange, e)).isEqualTo(result);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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.setServerAuthenticationEntryPoint(this.entryPoint);
|
||||
this.filter.setAuthenticationEntryPoint(this.entryPoint);
|
||||
this.filter.setServerAccessDeniedHandler(this.deniedHandler);
|
||||
}
|
||||
|
||||
@@ -155,6 +155,6 @@ public class ExceptionTranslationWebFilterTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void setAuthenticationEntryPointWhenNullThenException() {
|
||||
this.filter.setServerAuthenticationEntryPoint(null);
|
||||
this.filter.setAuthenticationEntryPoint(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user