Class OAuth2Authorization
java.lang.Object
org.springframework.security.oauth2.server.authorization.OAuth2Authorization
- All Implemented Interfaces:
Serializable
A representation of an OAuth 2.0 Authorization, which holds state related to the
authorization granted to a
client, by the
resource owner or itself in the case of the
client_credentials grant type.- Since:
- 0.0.1
- See Also:
-
RegisteredClientAuthorizationGrantTypeOAuth2TokenOAuth2AccessTokenOAuth2RefreshToken- Serialized Form
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder forOAuth2Authorization.static classOAuth2Authorization.Token<T extends org.springframework.security.oauth2.core.OAuth2Token>A holder of an OAuth 2.0 Token and it's associated metadata. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic OAuth2Authorization.Builderfrom(OAuth2Authorization authorization) Returns a newOAuth2Authorization.Builder, initialized with the values from the providedOAuth2Authorization.OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2AccessToken>Returns theOAuth2Authorization.Tokenof typeOAuth2AccessToken.<T> TgetAttribute(String name) Returns the value of an attribute associated to the authorization.Returns the attribute(s) associated to the authorization.org.springframework.security.oauth2.core.AuthorizationGrantTypeReturns theauthorization grant typeused for the authorization.Returns the authorized scope(s).getId()Returns the identifier for the authorization.Returns thePrincipalname of the resource owner (or client).OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2RefreshToken>Returns theOAuth2Authorization.Tokenof typeOAuth2RefreshToken.Returns the identifier for theregistered client.<T extends org.springframework.security.oauth2.core.OAuth2Token>
OAuth2Authorization.Token<T>Returns theOAuth2Authorization.Tokenof typetokenType.<T extends org.springframework.security.oauth2.core.OAuth2Token>
OAuth2Authorization.Token<T>Returns theOAuth2Authorization.Tokenmatching thetokenValue.inthashCode()static OAuth2Authorization.BuilderwithRegisteredClient(RegisteredClient registeredClient) Returns a newOAuth2Authorization.Builder, initialized with the providedRegisteredClient.getId().
-
Constructor Details
-
OAuth2Authorization
protected OAuth2Authorization()
-
-
Method Details
-
getId
Returns the identifier for the authorization.- Returns:
- the identifier for the authorization
-
getRegisteredClientId
Returns the identifier for theregistered client.- Returns:
- the
RegisteredClient.getId()
-
getPrincipalName
Returns thePrincipalname of the resource owner (or client).- Returns:
- the
Principalname of the resource owner (or client)
-
getAuthorizationGrantType
public org.springframework.security.oauth2.core.AuthorizationGrantType getAuthorizationGrantType()Returns theauthorization grant typeused for the authorization.- Returns:
- the
AuthorizationGrantTypeused for the authorization
-
getAuthorizedScopes
Returns the authorized scope(s).- Returns:
- the
Setof authorized scope(s) - Since:
- 0.4.0
-
getAccessToken
public OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2AccessToken> getAccessToken()Returns theOAuth2Authorization.Tokenof typeOAuth2AccessToken.- Returns:
- the
OAuth2Authorization.Tokenof typeOAuth2AccessToken
-
getRefreshToken
@Nullable public OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2RefreshToken> getRefreshToken()Returns theOAuth2Authorization.Tokenof typeOAuth2RefreshToken.- Returns:
- the
OAuth2Authorization.Tokenof typeOAuth2RefreshToken, ornullif not available
-
getToken
@Nullable public <T extends org.springframework.security.oauth2.core.OAuth2Token> OAuth2Authorization.Token<T> getToken(Class<T> tokenType) Returns theOAuth2Authorization.Tokenof typetokenType.- Type Parameters:
T- the type of the token- Parameters:
tokenType- the token type- Returns:
- the
OAuth2Authorization.Token, ornullif not available
-
getToken
@Nullable public <T extends org.springframework.security.oauth2.core.OAuth2Token> OAuth2Authorization.Token<T> getToken(String tokenValue) Returns theOAuth2Authorization.Tokenmatching thetokenValue.- Type Parameters:
T- the type of the token- Parameters:
tokenValue- the token value- Returns:
- the
OAuth2Authorization.Token, ornullif not available
-
getAttributes
Returns the attribute(s) associated to the authorization.- Returns:
- a
Mapof the attribute(s)
-
getAttribute
Returns the value of an attribute associated to the authorization.- Type Parameters:
T- the type of the attribute- Parameters:
name- the name of the attribute- Returns:
- the value of an attribute associated to the authorization, or
nullif not available
-
equals
-
hashCode
public int hashCode() -
withRegisteredClient
Returns a newOAuth2Authorization.Builder, initialized with the providedRegisteredClient.getId().- Parameters:
registeredClient- theRegisteredClient- Returns:
- the
OAuth2Authorization.Builder
-
from
Returns a newOAuth2Authorization.Builder, initialized with the values from the providedOAuth2Authorization.- Parameters:
authorization- theOAuth2Authorizationused for initializing theOAuth2Authorization.Builder- Returns:
- the
OAuth2Authorization.Builder
-