Skip to content

Commit 6284e1d

Browse files
committed
Remove deprecated API usage
1 parent 4934088 commit 6284e1d

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/config/annotation/web/configurers/OAuth2AuthorizationServerConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import org.springframework.security.oauth2.server.authorization.web.ProviderContextFilter;
3939
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
4040
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
41-
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
41+
import org.springframework.security.web.context.SecurityContextHolderFilter;
4242
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
4343
import org.springframework.security.web.util.matcher.OrRequestMatcher;
4444
import org.springframework.security.web.util.matcher.RequestMatcher;
@@ -246,7 +246,7 @@ public void configure(HttpSecurity httpSecurity) {
246246
ProviderSettings providerSettings = OAuth2ConfigurerUtils.getProviderSettings(httpSecurity);
247247

248248
ProviderContextFilter providerContextFilter = new ProviderContextFilter(providerSettings);
249-
httpSecurity.addFilterAfter(postProcess(providerContextFilter), SecurityContextPersistenceFilter.class);
249+
httpSecurity.addFilterAfter(postProcess(providerContextFilter), SecurityContextHolderFilter.class);
250250

251251
JWKSource<com.nimbusds.jose.proc.SecurityContext> jwkSource = OAuth2ConfigurerUtils.getJwkSource(httpSecurity);
252252
if (jwkSource != null) {

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/OAuth2AuthorizationServerMetadataTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public void claimsWhenRemovingClaimThenNotPresent() {
562562
.claim("claim-name", "claim-value")
563563
.claims((claims) -> claims.remove("claim-name"))
564564
.build();
565-
assertThat(authorizationServerMetadata.containsClaim("claim-name")).isFalse();
565+
assertThat(authorizationServerMetadata.hasClaim("claim-name")).isFalse();
566566
}
567567

568568
@Test
@@ -571,7 +571,7 @@ public void claimsWhenAddingClaimThenPresent() {
571571
this.minimalBuilder
572572
.claim("claim-name", "claim-value")
573573
.build();
574-
assertThat(authorizationServerMetadata.containsClaim("claim-name")).isTrue();
574+
assertThat(authorizationServerMetadata.hasClaim("claim-name")).isTrue();
575575
}
576576

577577
private static URL url(String urlString) {

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/annotation/web/configurers/OidcUserInfoTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import static org.assertj.core.api.Assertions.assertThat;
7676
import static org.mockito.Mockito.reset;
7777
import static org.mockito.Mockito.spy;
78-
import static org.springframework.test.web.servlet.ResultMatcher.matchAll;
7978
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
8079
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
8180
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@@ -124,7 +123,7 @@ public void requestWhenUserInfoRequestGetThenUserInfoResponse() throws Exception
124123
this.mvc.perform(get(DEFAULT_OIDC_USER_INFO_ENDPOINT_URI)
125124
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken.getTokenValue()))
126125
.andExpect(status().is2xxSuccessful())
127-
.andExpect(userInfoResponse());
126+
.andExpectAll(userInfoResponse());
128127
// @formatter:on
129128
}
130129

@@ -140,7 +139,7 @@ public void requestWhenUserInfoRequestPostThenUserInfoResponse() throws Exceptio
140139
this.mvc.perform(post(DEFAULT_OIDC_USER_INFO_ENDPOINT_URI)
141140
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken.getTokenValue()))
142141
.andExpect(status().is2xxSuccessful())
143-
.andExpect(userInfoResponse());
142+
.andExpectAll(userInfoResponse());
144143
// @formatter:on
145144
}
146145

@@ -156,7 +155,7 @@ public void requestWhenSignedJwtAndCustomUserInfoMapperThenMapJwtClaimsToUserInf
156155
this.mvc.perform(get(DEFAULT_OIDC_USER_INFO_ENDPOINT_URI)
157156
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken.getTokenValue()))
158157
.andExpect(status().is2xxSuccessful())
159-
.andExpect(userInfoResponse());
158+
.andExpectAll(userInfoResponse());
160159
// @formatter:on
161160
}
162161

@@ -173,7 +172,7 @@ public void requestWhenUserInfoRequestThenBearerTokenAuthenticationNotPersisted(
173172
MvcResult mvcResult = this.mvc.perform(get(DEFAULT_OIDC_USER_INFO_ENDPOINT_URI)
174173
.header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken.getTokenValue()))
175174
.andExpect(status().is2xxSuccessful())
176-
.andExpect(userInfoResponse())
175+
.andExpectAll(userInfoResponse())
177176
.andReturn();
178177
// @formatter:on
179178

@@ -182,9 +181,9 @@ public void requestWhenUserInfoRequestThenBearerTokenAuthenticationNotPersisted(
182181
assertThat(securityContext.getAuthentication()).isNull();
183182
}
184183

185-
private static ResultMatcher userInfoResponse() {
184+
private static ResultMatcher[] userInfoResponse() {
186185
// @formatter:off
187-
return matchAll(
186+
return new ResultMatcher[] {
188187
jsonPath("sub").value("user1"),
189188
jsonPath("name").value("First Last"),
190189
jsonPath("given_name").value("First"),
@@ -205,7 +204,7 @@ private static ResultMatcher userInfoResponse() {
205204
jsonPath("phone_number_verified").value("false"),
206205
jsonPath("address.formatted").value("Champ de Mars\n5 Av. Anatole France\n75007 Paris\nFrance"),
207206
jsonPath("updated_at").value("1970-01-01T00:00:00Z")
208-
);
207+
};
209208
// @formatter:on
210209
}
211210

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/oidc/OidcClientRegistrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public void claimsWhenRemovingClaimThenNotPresent() {
399399
.build();
400400
// @formatter:on
401401

402-
assertThat(clientRegistration.containsClaim("claim-name")).isFalse();
402+
assertThat(clientRegistration.hasClaim("claim-name")).isFalse();
403403
}
404404

405405
@Test
@@ -410,7 +410,7 @@ public void claimsWhenAddingClaimThenPresent() {
410410
.build();
411411
// @formatter:on
412412

413-
assertThat(clientRegistration.containsClaim("claim-name")).isTrue();
413+
assertThat(clientRegistration.hasClaim("claim-name")).isTrue();
414414
}
415415

416416
}

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/oidc/OidcProviderConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public void claimsWhenAddingClaimThenPresent() {
514514
this.minimalConfigurationBuilder
515515
.claim("claim-name", "claim-value")
516516
.build();
517-
assertThat(configuration.containsClaim("claim-name")).isTrue();
517+
assertThat(configuration.hasClaim("claim-name")).isTrue();
518518
}
519519

520520
private static URL url(String urlString) {

0 commit comments

Comments
 (0)