Class OAuth2UserAuthority
java.lang.Object
org.springframework.security.oauth2.core.user.OAuth2UserAuthority
- All Implemented Interfaces:
Serializable,GrantedAuthority
- Direct Known Subclasses:
OidcUserAuthority
A
GrantedAuthority that may be associated to an OAuth2User.- Since:
- 5.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOAuth2UserAuthority(String authority, Map<String, Object> attributes) Constructs aOAuth2UserAuthorityusing the provided parameters.Constructs aOAuth2UserAuthorityusing the provided parameters.OAuth2UserAuthority(Map<String, Object> attributes) Constructs aOAuth2UserAuthorityusing the provided parameters and defaultsgetAuthority()toOAUTH2_USER.OAuth2UserAuthority(Map<String, Object> attributes, String userNameAttributeName) Constructs aOAuth2UserAuthorityusing the provided parameters and defaultsgetAuthority()toOAUTH2_USER. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the attributes about the user.If theGrantedAuthoritycan be represented as aStringand thatStringis sufficient in precision to be relied upon for an access control decision by anAuthorizationManager(or delegate), this method should return such aString.Returns the attribute name used to access the user's name from the attributes.inthashCode()toString()
-
Constructor Details
-
OAuth2UserAuthority
Constructs aOAuth2UserAuthorityusing the provided parameters and defaultsgetAuthority()toOAUTH2_USER.- Parameters:
attributes- the attributes about the user
-
OAuth2UserAuthority
Constructs aOAuth2UserAuthorityusing the provided parameters and defaultsgetAuthority()toOAUTH2_USER.- Parameters:
attributes- the attributes about the useruserNameAttributeName- the attribute name used to access the user's name from the attributes- Since:
- 6.4
-
OAuth2UserAuthority
Constructs aOAuth2UserAuthorityusing the provided parameters.- Parameters:
authority- the authority granted to the userattributes- the attributes about the user
-
OAuth2UserAuthority
public OAuth2UserAuthority(String authority, Map<String, Object> attributes, String userNameAttributeName) Constructs aOAuth2UserAuthorityusing the provided parameters.- Parameters:
authority- the authority granted to the userattributes- the attributes about the useruserNameAttributeName- the attribute name used to access the user's name from the attributes- Since:
- 6.4
-
-
Method Details
-
getAuthority
Description copied from interface:GrantedAuthorityIf theGrantedAuthoritycan be represented as aStringand thatStringis sufficient in precision to be relied upon for an access control decision by anAuthorizationManager(or delegate), this method should return such aString.If the
GrantedAuthoritycannot be expressed with sufficient precision as aString,nullshould be returned. Returningnullwill require anAccessDecisionManager(or delegate) to specifically support theGrantedAuthorityimplementation, so returningnullshould be avoided unless actually required.- Specified by:
getAuthorityin interfaceGrantedAuthority- Returns:
- a representation of the granted authority (or
nullif the granted authority cannot be expressed as aStringwith sufficient precision).
-
getAttributes
Returns the attributes about the user.- Returns:
- a
Mapof attributes about the user
-
getUserNameAttributeName
Returns the attribute name used to access the user's name from the attributes.- Returns:
- the attribute name used to access the user's name from the attributes
- Since:
- 6.4
-
equals
-
hashCode
public int hashCode() -
toString
-