Skip to content

Commit 171242b

Browse files
committed
Polish ReactiveOidcIdTokenDecoderFactory WebClient Support
- Changed to #setWebClientFactory to align with other methods - Updated Copyright - Added @SInCE attribute Issue spring-projectsgh-13274
1 parent 3495ea8 commit 171242b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/ReactiveOidcIdTokenDecoderFactory.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -91,7 +91,7 @@ public final class ReactiveOidcIdTokenDecoderFactory implements ReactiveJwtDecod
9191
private Function<ClientRegistration, Converter<Map<String, Object>, Map<String, Object>>> claimTypeConverterFactory = (
9292
clientRegistration) -> DEFAULT_CLAIM_TYPE_CONVERTER;
9393

94-
private Function<ClientRegistration, WebClient> webClientResolver = (clientRegistration) -> WebClient.create();
94+
private Function<ClientRegistration, WebClient> webClientFactory = (clientRegistration) -> WebClient.create();
9595

9696
/**
9797
* Returns the default {@link Converter}'s used for type conversion of claim values
@@ -168,7 +168,7 @@ private NimbusReactiveJwtDecoder buildDecoder(ClientRegistration clientRegistrat
168168
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
169169
}
170170
return NimbusReactiveJwtDecoder.withJwkSetUri(jwkSetUri).jwsAlgorithm((SignatureAlgorithm) jwsAlgorithm)
171-
.webClient(this.webClientResolver.apply(clientRegistration)).build();
171+
.webClient(this.webClientFactory.apply(clientRegistration)).build();
172172
}
173173
if (jwsAlgorithm != null && MacAlgorithm.class.isAssignableFrom(jwsAlgorithm.getClass())) {
174174
// https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
@@ -248,12 +248,13 @@ public void setClaimTypeConverterFactory(
248248
* {@link NimbusReactiveJwtDecoder}. The default resolver provides {@link WebClient}
249249
* that is created by {@code WebClient.create()}. This is optional method if we need
250250
* to set custom web client in {@link NimbusReactiveJwtDecoder}.
251-
* @param webClientResolver a function that will provide {@link WebClient} for a
251+
* @param webClientFactory a function that will provide {@link WebClient} for a
252252
* {@link ClientRegistration}
253+
* @since 6.3
253254
*/
254-
public void setWebClientResolver(Function<ClientRegistration, WebClient> webClientResolver) {
255-
Assert.notNull(webClientResolver, "webClientResolver cannot be null");
256-
this.webClientResolver = webClientResolver;
255+
public void setWebClientFactory(Function<ClientRegistration, WebClient> webClientFactory) {
256+
Assert.notNull(webClientFactory, "webClientFactory cannot be null");
257+
this.webClientFactory = webClientFactory;
257258
}
258259

259260
}

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/authentication/ReactiveOidcIdTokenDecoderFactoryTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -97,8 +97,8 @@ public void setClaimTypeConverterFactoryWhenNullThenThrowIllegalArgumentExceptio
9797
}
9898

9999
@Test
100-
public void setWebClientResolverWhenNullThenThrowIllegalArgumentException() {
101-
assertThatIllegalArgumentException().isThrownBy(() -> this.idTokenDecoderFactory.setWebClientResolver(null));
100+
public void setWebClientFactoryWhenNullThenThrowIllegalArgumentException() {
101+
assertThatIllegalArgumentException().isThrownBy(() -> this.idTokenDecoderFactory.setWebClientFactory(null));
102102
}
103103

104104
@Test
@@ -188,7 +188,7 @@ public void createDecoderWhenCustomClaimTypeConverterFactorySetThenApplied() {
188188
public void createDecoderWhenCustomWebClientResolverSetThenApplied() {
189189
WebClient webClient = mock(WebClient.class);
190190
Function<ClientRegistration, WebClient> customWebClientResolver = mock(Function.class);
191-
this.idTokenDecoderFactory.setWebClientResolver(customWebClientResolver);
191+
this.idTokenDecoderFactory.setWebClientFactory(customWebClientResolver);
192192
ClientRegistration clientRegistration = this.registration.build();
193193
given(customWebClientResolver.apply(clientRegistration)).willReturn(webClient);
194194
this.idTokenDecoderFactory.createDecoder(clientRegistration);

0 commit comments

Comments
 (0)