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 aDefaultOAuth2Userusing the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(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 theCollectionofGrantedAuthoritys associated with this OAuth 2.0 tokenjava.lang.StringgetName()Returns the name of the authenticatedPrincipal.inthashCode()java.lang.StringtoString()-
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 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 Detail
-
getName
public java.lang.String getName()
Description copied from interface:AuthenticatedPrincipalReturns the name of the authenticatedPrincipal. Nevernull.- Specified by:
getNamein interfaceAuthenticatedPrincipal- Returns:
- the name of the authenticated
Principal
-
getAuthorities
public java.util.Collection<? extends GrantedAuthority> 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
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Description copied from interface:OAuth2AuthenticatedPrincipalGet the OAuth 2.0 token attributes- Specified by:
getAttributesin interfaceOAuth2AuthenticatedPrincipal- Returns:
- the OAuth 2.0 token attributes
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-