Class CustomOidcUser

  • All Implemented Interfaces:
    java.io.Serializable, org.springframework.security.core.AuthenticatedPrincipal, org.springframework.security.oauth2.core.ClaimAccessor, org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal, org.springframework.security.oauth2.core.oidc.IdTokenClaimAccessor, org.springframework.security.oauth2.core.oidc.StandardClaimAccessor, org.springframework.security.oauth2.core.oidc.user.OidcUser, org.springframework.security.oauth2.core.user.OAuth2User

    public class CustomOidcUser
    extends CustomOAuth2User
    implements org.springframework.security.oauth2.core.oidc.user.OidcUser
    Custom class which is replica of the DefaultOidcUser

    Once https://github.com/spring-projects/spring-security/issues/9366 is addressed, this class can be removed.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, org.springframework.security.oauth2.core.oidc.OidcIdToken idToken)
      Constructs a CustomOidcUser using the provided parameters.
      CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, org.springframework.security.oauth2.core.oidc.OidcIdToken idToken, java.lang.String nameAttributeKey)
      Constructs a CustomOidcUser using the provided parameters.
      CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, org.springframework.security.oauth2.core.oidc.OidcIdToken idToken, org.springframework.security.oauth2.core.oidc.OidcUserInfo userInfo)
      Constructs a CustomOidcUser using the provided parameters.
      CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, org.springframework.security.oauth2.core.oidc.OidcIdToken idToken, org.springframework.security.oauth2.core.oidc.OidcUserInfo userInfo, java.lang.String nameAttributeKey)
      Constructs a CustomOidcUser 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()  
      org.springframework.security.oauth2.core.oidc.OidcIdToken getIdToken()  
      org.springframework.security.oauth2.core.oidc.OidcUserInfo getUserInfo()  
      • 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

      • CustomOidcUser

        public CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities,
                              org.springframework.security.oauth2.core.oidc.OidcIdToken idToken)
        Constructs a CustomOidcUser using the provided parameters.
        Parameters:
        authorities - the authorities granted to the user
        idToken - the ID Token containing claims about the user
      • CustomOidcUser

        public CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities,
                              org.springframework.security.oauth2.core.oidc.OidcIdToken idToken,
                              java.lang.String nameAttributeKey)
        Constructs a CustomOidcUser using the provided parameters.
        Parameters:
        authorities - the authorities granted to the user
        idToken - the ID Token containing claims about the user
        nameAttributeKey - the key used to access the user's "name" from CustomOAuth2User.getAttributes()
      • CustomOidcUser

        public CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities,
                              org.springframework.security.oauth2.core.oidc.OidcIdToken idToken,
                              org.springframework.security.oauth2.core.oidc.OidcUserInfo userInfo)
        Constructs a CustomOidcUser using the provided parameters.
        Parameters:
        authorities - the authorities granted to the user
        idToken - the ID Token containing claims about the user
        userInfo - the UserInfo containing claims about the user, may be null
      • CustomOidcUser

        public CustomOidcUser​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities,
                              org.springframework.security.oauth2.core.oidc.OidcIdToken idToken,
                              org.springframework.security.oauth2.core.oidc.OidcUserInfo userInfo,
                              java.lang.String nameAttributeKey)
        Constructs a CustomOidcUser using the provided parameters.
        Parameters:
        authorities - the authorities granted to the user
        idToken - the ID Token containing claims about the user
        userInfo - the UserInfo containing claims about the user, may be null
        nameAttributeKey - the key used to access the user's "name" from CustomOAuth2User.getAttributes()
    • Method Detail

      • getClaims

        public java.util.Map<java.lang.String,​java.lang.Object> getClaims()
        Specified by:
        getClaims in interface org.springframework.security.oauth2.core.ClaimAccessor
        Specified by:
        getClaims in interface org.springframework.security.oauth2.core.oidc.user.OidcUser
      • getIdToken

        public org.springframework.security.oauth2.core.oidc.OidcIdToken getIdToken()
        Specified by:
        getIdToken in interface org.springframework.security.oauth2.core.oidc.user.OidcUser
      • getUserInfo

        public org.springframework.security.oauth2.core.oidc.OidcUserInfo getUserInfo()
        Specified by:
        getUserInfo in interface org.springframework.security.oauth2.core.oidc.user.OidcUser