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
ConstructorsConstructorDescriptionDefaultOAuth2User(Collection<? extends GrantedAuthority> authorities, Map<String, Object> attributes, String nameAttributeKey) Constructs aDefaultOAuth2Userusing the provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the OAuth 2.0 token attributesCollection<? extends GrantedAuthority>Get theCollectionofGrantedAuthoritys associated with this OAuth 2.0 tokengetName()Returns the name of the authenticatedPrincipal.inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 aDefaultOAuth2Userusing 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:AuthenticatedPrincipalReturns the name of the authenticatedPrincipal. Nevernull.- Specified by:
getNamein interfaceAuthenticatedPrincipal- Returns:
- the name of the authenticated
Principal
-
getAuthorities
Description copied from interface:OAuth2AuthenticatedPrincipalGet theCollectionofGrantedAuthoritys associated with this OAuth 2.0 token- Specified by:
getAuthoritiesin interfaceOAuth2AuthenticatedPrincipal- Returns:
- the OAuth 2.0 token authorities
-
getAttributes
Description copied from interface:OAuth2AuthenticatedPrincipalGet the OAuth 2.0 token attributes- Specified by:
getAttributesin interfaceOAuth2AuthenticatedPrincipal- Returns:
- the OAuth 2.0 token attributes
-
equals
-
hashCode
public int hashCode() -
toString
-