Class CustomOAuth2User

  • All Implemented Interfaces:
    java.io.Serializable, org.springframework.security.core.AuthenticatedPrincipal, org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal, org.springframework.security.oauth2.core.user.OAuth2User
    Direct Known Subclasses:
    CustomOidcUser

    public class CustomOAuth2User
    extends java.lang.Object
    implements org.springframework.security.oauth2.core.user.OAuth2User, java.io.Serializable
    Custom class which is replica of the DefaultOAuth2User

    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
      CustomOAuth2User​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities, java.util.Map<java.lang.String,​java.lang.Object> attributes, java.lang.String nameAttributeKey)
      Constructs a CustomOAuth2User 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()  
      java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> getAuthorities()  
      java.lang.String getName()  
      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

      • CustomOAuth2User

        public CustomOAuth2User​(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities,
                                java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                java.lang.String nameAttributeKey)
        Constructs a CustomOAuth2User using the provided parameters.
        Parameters:
        authorities - the authorities granted to the user
        attributes - the attributes about the user
        nameAttributeKey - the key used to access the user's "name" from getAttributes()
    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface org.springframework.security.core.AuthenticatedPrincipal
      • getAuthorities

        public java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> getAuthorities()
        Specified by:
        getAuthorities in interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
      • getAttributes

        public java.util.Map<java.lang.String,​java.lang.Object> getAttributes()
        Specified by:
        getAttributes in interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object