mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-30 16:52:13 +00:00
Update Deprecated Reactor Usage
This commit is contained in:
parent
834370d8eb
commit
eecd7d9559
@ -84,9 +84,7 @@ public abstract class AbstractWebClientReactiveOAuth2AccessTokenResponseClient<T
|
||||
Assert.notNull(grantRequest, "grantRequest cannot be null");
|
||||
// @formatter:off
|
||||
return Mono.defer(() -> this.requestEntityConverter.convert(grantRequest)
|
||||
.exchange()
|
||||
.flatMap((response) -> response.body(this.bodyExtractor))
|
||||
);
|
||||
.exchangeToMono((response) -> response.body(this.bodyExtractor)));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,6 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
|
||||
// @formatter:off
|
||||
return Mono.just(token)
|
||||
.flatMap(this::makeRequest)
|
||||
.flatMap(this::adaptToNimbusResponse)
|
||||
.map(this::convertClaimsSet)
|
||||
.flatMap(this.authenticationConverter::convert)
|
||||
.cast(OAuth2AuthenticatedPrincipal.class)
|
||||
@ -113,13 +112,13 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
private Mono<ClientResponse> makeRequest(String token) {
|
||||
private Mono<Map<String, Object>> makeRequest(String token) {
|
||||
// @formatter:off
|
||||
return this.webClient.post()
|
||||
.uri(this.introspectionUri)
|
||||
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
|
||||
.body(BodyInserters.fromFormData("token", token))
|
||||
.exchange();
|
||||
.exchangeToMono(this::adaptToNimbusResponse);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.mockwebserver.Dispatcher;
|
||||
@ -322,7 +323,10 @@ public class SpringReactiveOpaqueTokenIntrospectorTests {
|
||||
ClientResponse.Headers headers = mock(ClientResponse.Headers.class);
|
||||
given(headers.contentType()).willReturn(Optional.of(MediaType.APPLICATION_JSON));
|
||||
given(clientResponse.headers()).willReturn(headers);
|
||||
given(spec.exchange()).willReturn(Mono.just(clientResponse));
|
||||
given(spec.exchangeToMono(any())).willAnswer((invocation) -> {
|
||||
Function<ClientResponse, Mono<ClientResponse>> fun = invocation.getArgument(0);
|
||||
return fun.apply(clientResponse);
|
||||
});
|
||||
return webClient;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user