Class DefaultOidcUser
- java.lang.Object
-
- org.springframework.security.oauth2.core.user.DefaultOAuth2User
-
- org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser
-
- All Implemented Interfaces:
java.io.Serializable
,AuthenticatedPrincipal
,ClaimAccessor
,OAuth2AuthenticatedPrincipal
,IdTokenClaimAccessor
,StandardClaimAccessor
,OidcUser
,OAuth2User
public class DefaultOidcUser extends DefaultOAuth2User implements OidcUser
The default implementation of anOidcUser
.The default claim used for accessing the "name" of the user
Principal
fromgetClaims()
isIdTokenClaimNames.SUB
.- Since:
- 5.0
- See Also:
OidcUser
,DefaultOAuth2User
,OidcIdToken
,OidcUserInfo
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken)
Constructs aDefaultOidcUser
using the provided parameters.DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, java.lang.String nameAttributeKey)
Constructs aDefaultOidcUser
using the provided parameters.DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, OidcUserInfo userInfo)
Constructs aDefaultOidcUser
using the provided parameters.DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, OidcUserInfo userInfo, java.lang.String nameAttributeKey)
Constructs aDefaultOidcUser
using the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getClaims()
Returns the claims about the user.OidcIdToken
getIdToken()
Returns theID Token
containing claims about the user.OidcUserInfo
getUserInfo()
Returns theUserInfo
containing claims about the user.-
Methods inherited from class org.springframework.security.oauth2.core.user.DefaultOAuth2User
equals, getAttributes, getAuthorities, getName, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.springframework.security.core.AuthenticatedPrincipal
getName
-
Methods inherited from interface org.springframework.security.oauth2.core.ClaimAccessor
containsClaim, getClaim, getClaimAsBoolean, getClaimAsInstant, getClaimAsMap, getClaimAsString, getClaimAsStringList, getClaimAsURL, hasClaim
-
Methods inherited from interface org.springframework.security.oauth2.core.oidc.IdTokenClaimAccessor
getAccessTokenHash, getAudience, getAuthenticatedAt, getAuthenticationContextClass, getAuthenticationMethods, getAuthorizationCodeHash, getAuthorizedParty, getExpiresAt, getIssuedAt, getIssuer, getNonce, getSubject
-
Methods inherited from interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
getAttribute, getAttributes, getAuthorities
-
Methods inherited from interface org.springframework.security.oauth2.core.oidc.StandardClaimAccessor
getAddress, getBirthdate, getEmail, getEmailVerified, getFamilyName, getFullName, getGender, getGivenName, getLocale, getMiddleName, getNickName, getPhoneNumber, getPhoneNumberVerified, getPicture, getPreferredUsername, getProfile, getUpdatedAt, getWebsite, getZoneInfo
-
-
-
-
Constructor Detail
-
DefaultOidcUser
public DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken)
Constructs aDefaultOidcUser
using the provided parameters.- Parameters:
authorities
- the authorities granted to the useridToken
- theID Token
containing claims about the user
-
DefaultOidcUser
public DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, java.lang.String nameAttributeKey)
Constructs aDefaultOidcUser
using the provided parameters.- Parameters:
authorities
- the authorities granted to the useridToken
- theID Token
containing claims about the usernameAttributeKey
- the key used to access the user's "name" fromDefaultOAuth2User.getAttributes()
-
DefaultOidcUser
public DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, OidcUserInfo userInfo)
Constructs aDefaultOidcUser
using the provided parameters.
-
DefaultOidcUser
public DefaultOidcUser(java.util.Collection<? extends GrantedAuthority> authorities, OidcIdToken idToken, OidcUserInfo userInfo, java.lang.String nameAttributeKey)
Constructs aDefaultOidcUser
using the provided parameters.- Parameters:
authorities
- the authorities granted to the useridToken
- theID Token
containing claims about the useruserInfo
- theUserInfo
containing claims about the user, may benull
nameAttributeKey
- the key used to access the user's "name" fromDefaultOAuth2User.getAttributes()
-
-
Method Detail
-
getClaims
public java.util.Map<java.lang.String,java.lang.Object> getClaims()
Description copied from interface:OidcUser
Returns the claims about the user. The claims are aggregated fromOidcUser.getIdToken()
andOidcUser.getUserInfo()
(if available).- Specified by:
getClaims
in interfaceClaimAccessor
- Specified by:
getClaims
in interfaceOidcUser
- Returns:
- a
Map
of claims about the user
-
getIdToken
public OidcIdToken getIdToken()
Description copied from interface:OidcUser
Returns theID Token
containing claims about the user.- Specified by:
getIdToken
in interfaceOidcUser
- Returns:
- the
OidcIdToken
containing claims about the user.
-
getUserInfo
public OidcUserInfo getUserInfo()
Description copied from interface:OidcUser
Returns theUserInfo
containing claims about the user.- Specified by:
getUserInfo
in interfaceOidcUser
- Returns:
- the
OidcUserInfo
containing claims about the user.
-
-