Class DefaultOAuth2User
- java.lang.Object
-
- org.springframework.security.oauth2.core.user.DefaultOAuth2User
-
- All Implemented Interfaces:
java.io.Serializable
,AuthenticatedPrincipal
,OAuth2AuthenticatedPrincipal
,OAuth2User
- Direct Known Subclasses:
DefaultOidcUser
public class DefaultOAuth2User extends java.lang.Object implements OAuth2User, java.io.Serializable
The default implementation of anOAuth2User
.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) viagetAttributes()
and returning it fromgetName()
.- Since:
- 5.0
- See Also:
OAuth2User
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultOAuth2User(java.util.Collection<? extends GrantedAuthority> authorities, java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.String nameAttributeKey)
Constructs aDefaultOAuth2User
using the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.util.Map<java.lang.String,java.lang.Object>
getAttributes()
Get the OAuth 2.0 token attributesjava.util.Collection<? extends GrantedAuthority>
getAuthorities()
Get theCollection
ofGrantedAuthority
s associated with this OAuth 2.0 tokenjava.lang.String
getName()
Returns the name of the authenticatedPrincipal
.int
hashCode()
java.lang.String
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 Detail
-
DefaultOAuth2User
public DefaultOAuth2User(java.util.Collection<? extends GrantedAuthority> authorities, java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.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 Detail
-
getName
public java.lang.String 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
public java.util.Collection<? extends GrantedAuthority> 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
public java.util.Map<java.lang.String,java.lang.Object> 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
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-