From 6499a235b02e3a5557eb7fe2e7c6a2d0f8c94be4 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Fri, 8 Jan 2021 11:30:28 -0700 Subject: [PATCH] Suppress Compiler Warnings --- .../security/oauth2/core/OAuth2AuthenticatedPrincipal.java | 1 + .../authentication/JwtGrantedAuthoritiesConverter.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthenticatedPrincipal.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthenticatedPrincipal.java index f056aba43d..17be893e94 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthenticatedPrincipal.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/OAuth2AuthenticatedPrincipal.java @@ -39,6 +39,7 @@ public interface OAuth2AuthenticatedPrincipal extends AuthenticatedPrincipal { * @return the attribute or {@code null} otherwise */ @Nullable + @SuppressWarnings("unchecked") default A getAttribute(String name) { return (A) getAttributes().get(name); } diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java index 271e4c3c90..ab020a3fc8 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java @@ -118,9 +118,14 @@ public final class JwtGrantedAuthoritiesConverter implements Converter) authorities; + return castAuthoritiesToCollection(authorities); } return Collections.emptyList(); } + @SuppressWarnings("unchecked") + private Collection castAuthoritiesToCollection(Object authorities) { + return (Collection) authorities; + } + }