Class DefaultOAuth2User
java.lang.Object
org.springframework.security.oauth2.core.user.DefaultOAuth2User
- All Implemented Interfaces:
Serializable
,AuthenticatedPrincipal
,OAuth2AuthenticatedPrincipal
,OAuth2User
- Direct Known Subclasses:
DefaultOidcUser
The default implementation of an
OAuth2User
.
User attribute names are not standardized between providers and therefore it is
required to supply the key for the user's "name" attribute to one of
the constructors. The key will be used for accessing the "name" of the
Principal
(user) via getAttributes()
and returning it from
getName()
.
- Since:
- 5.0
- See Also:
-
Constructor Summary
ConstructorDescriptionDefaultOAuth2User
(Collection<? extends GrantedAuthority> authorities, Map<String, Object> attributes, String nameAttributeKey) Constructs aDefaultOAuth2User
using the provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the OAuth 2.0 token attributesCollection<? extends GrantedAuthority>
Get theCollection
ofGrantedAuthority
s associated with this OAuth 2.0 tokengetName()
Returns the name of the authenticatedPrincipal
.int
hashCode()
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
getAttribute
-
Constructor Details
-
DefaultOAuth2User
public DefaultOAuth2User(Collection<? extends GrantedAuthority> authorities, Map<String, Object> attributes, String nameAttributeKey) Constructs aDefaultOAuth2User
using the provided parameters.- Parameters:
authorities
- the authorities granted to the userattributes
- the attributes about the usernameAttributeKey
- the key used to access the user's "name" fromgetAttributes()
-
-
Method Details
-
getName
Description copied from interface:AuthenticatedPrincipal
Returns the name of the authenticatedPrincipal
. Nevernull
.- Specified by:
getName
in interfaceAuthenticatedPrincipal
- Returns:
- the name of the authenticated
Principal
-
getAuthorities
Description copied from interface:OAuth2AuthenticatedPrincipal
Get theCollection
ofGrantedAuthority
s associated with this OAuth 2.0 token- Specified by:
getAuthorities
in interfaceOAuth2AuthenticatedPrincipal
- Returns:
- the OAuth 2.0 token authorities
-
getAttributes
Description copied from interface:OAuth2AuthenticatedPrincipal
Get the OAuth 2.0 token attributes- Specified by:
getAttributes
in interfaceOAuth2AuthenticatedPrincipal
- Returns:
- the OAuth 2.0 token attributes
-
equals
-
hashCode
public int hashCode() -
toString
-