From 6413511eb682f06b865974bac8d9edf01dd666de Mon Sep 17 00:00:00 2001 From: Marcus Hert da Coregio Date: Thu, 6 May 2021 10:04:49 -0300 Subject: [PATCH] Update Deprecated Property in Opaque Token Introspectors Update NimbusOpaqueTokenIntrospector and NimbusReactiveOpaqueTokenIntrospector to use MediaType.APPLICATION_JSON instead of the deprecated MediaType.APPLICATION_JSON_UTF8 Closes gh-9353 --- .../resource/introspection/NimbusOpaqueTokenIntrospector.java | 4 ++-- .../introspection/NimbusReactiveOpaqueTokenIntrospector.java | 4 ++-- .../NimbusReactiveOpaqueTokenIntrospectorTests.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusOpaqueTokenIntrospector.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusOpaqueTokenIntrospector.java index 4fc09ee93e..51fe7d0df6 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusOpaqueTokenIntrospector.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusOpaqueTokenIntrospector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ public class NimbusOpaqueTokenIntrospector implements OpaqueTokenIntrospector { private HttpHeaders requestHeaders() { HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON_UTF8)); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); return headers; } diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospector.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospector.java index 8b8dc9bd39..670f6a3ac5 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospector.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class NimbusReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke // @formatter:off return this.webClient.post() .uri(this.introspectionUri) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_UTF8_VALUE) + .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE) .body(BodyInserters.fromFormData("token", token)) .exchange(); // @formatter:on diff --git a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospectorTests.java b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospectorTests.java index 666bf301ac..844faa6d74 100644 --- a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospectorTests.java +++ b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/introspection/NimbusReactiveOpaqueTokenIntrospectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -244,7 +244,7 @@ public class NimbusReactiveOpaqueTokenIntrospectorTests { given(clientResponse.statusCode()).willReturn(HttpStatus.OK); given(clientResponse.bodyToMono(String.class)).willReturn(Mono.just(response)); ClientResponse.Headers headers = mock(ClientResponse.Headers.class); - given(headers.contentType()).willReturn(Optional.of(MediaType.APPLICATION_JSON_UTF8)); + given(headers.contentType()).willReturn(Optional.of(MediaType.APPLICATION_JSON)); given(clientResponse.headers()).willReturn(headers); given(spec.exchange()).willReturn(Mono.just(clientResponse)); return webClient;