From c92a4a071c82fcd6a6addfe68d989b31913defae Mon Sep 17 00:00:00 2001 From: Andre Blanke Date: Sat, 26 Oct 2024 09:42:15 +0200 Subject: [PATCH] Default AuthenticatedPrincipal.getName implementation --- .../security/oauth2/core/OAuth2AuthenticatedPrincipal.java | 5 +++++ .../security/oauth2/core/user/DefaultOAuth2User.java | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) 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 6554deea606..160c68233be 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 @@ -64,4 +64,9 @@ default A getAttribute(String name) { */ String getNameAttributeKey(); + @Override + default String getName() { + return getAttribute(getNameAttributeKey()).toString(); + } + } diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/user/DefaultOAuth2User.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/user/DefaultOAuth2User.java index 433267a708c..10caa4b2edb 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/user/DefaultOAuth2User.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/user/DefaultOAuth2User.java @@ -79,11 +79,6 @@ public DefaultOAuth2User(Collection authorities, Map this.nameAttributeKey = nameAttributeKey; } - @Override - public String getName() { - return this.getAttribute(this.nameAttributeKey).toString(); - } - @Override public Collection getAuthorities() { return this.authorities;