From 2e07ce8b8fdd61141db0a65972ebbb0af2339124 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Tue, 16 Aug 2022 02:58:03 -0400 Subject: [PATCH] Polish gh-738 --- .../OAuth2ClientCredentialsAuthenticationProvider.java | 2 +- .../OAuth2ClientCredentialsAuthenticationProviderTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProvider.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProvider.java index e67a69a8..a7405c42 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProvider.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProvider.java @@ -88,7 +88,7 @@ public final class OAuth2ClientCredentialsAuthenticationProvider implements Auth throw new OAuth2AuthenticationException(OAuth2ErrorCodes.UNAUTHORIZED_CLIENT); } - Set authorizedScopes = Collections.EMPTY_SET; // Empty by default + Set authorizedScopes = Collections.emptySet(); if (!CollectionUtils.isEmpty(clientCredentialsAuthentication.getScopes())) { for (String requestedScope : clientCredentialsAuthentication.getScopes()) { if (!registeredClient.getScopes().contains(requestedScope)) { diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProviderTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProviderTests.java index 804cf8ac..07c54613 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProviderTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2ClientCredentialsAuthenticationProviderTests.java @@ -212,7 +212,7 @@ public class OAuth2ClientCredentialsAuthenticationProviderTests { } @Test - public void authenticateWhenNoScopeRequestedThenAccessTokenNotContainsAnyScope() { + public void authenticateWhenNoScopeRequestedThenAccessTokenDoesNotContainScope() { RegisteredClient registeredClient = TestRegisteredClients.registeredClient2().build(); OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken( registeredClient, ClientAuthenticationMethod.CLIENT_SECRET_BASIC, registeredClient.getClientSecret());