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:
-
RegisteredClient
AuthorizationGrantType
OAuth2Token
OAuth2AccessToken
OAuth2RefreshToken
- Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A builder forOAuth2Authorization
.static class
OAuth2Authorization.Token<T extends org.springframework.security.oauth2.core.OAuth2Token>
A holder of an OAuth 2.0 Token and it's associated metadata. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static OAuth2Authorization.Builder
from
(OAuth2Authorization authorization) Returns a newOAuth2Authorization.Builder
, initialized with the values from the providedOAuth2Authorization
.OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2AccessToken>
Returns theOAuth2Authorization.Token
of typeOAuth2AccessToken
.<T> T
getAttribute
(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.AuthorizationGrantType
Returns theauthorization grant type
used for the authorization.Returns the authorized scope(s).getId()
Returns the identifier for the authorization.Returns thePrincipal
name of the resource owner (or client).OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2RefreshToken>
Returns theOAuth2Authorization.Token
of typeOAuth2RefreshToken
.Returns the identifier for theregistered client
.<T extends org.springframework.security.oauth2.core.OAuth2Token>
OAuth2Authorization.Token<T>Returns theOAuth2Authorization.Token
of typetokenType
.<T extends org.springframework.security.oauth2.core.OAuth2Token>
OAuth2Authorization.Token<T>Returns theOAuth2Authorization.Token
matching thetokenValue
.int
hashCode()
static OAuth2Authorization.Builder
withRegisteredClient
(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 thePrincipal
name of the resource owner (or client).- Returns:
- the
Principal
name of the resource owner (or client)
-
getAuthorizationGrantType
public org.springframework.security.oauth2.core.AuthorizationGrantType getAuthorizationGrantType()Returns theauthorization grant type
used for the authorization.- Returns:
- the
AuthorizationGrantType
used for the authorization
-
getAuthorizedScopes
Returns the authorized scope(s).- Returns:
- the
Set
of authorized scope(s) - Since:
- 0.4.0
-
getAccessToken
public OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2AccessToken> getAccessToken()Returns theOAuth2Authorization.Token
of typeOAuth2AccessToken
.- Returns:
- the
OAuth2Authorization.Token
of typeOAuth2AccessToken
-
getRefreshToken
@Nullable public OAuth2Authorization.Token<org.springframework.security.oauth2.core.OAuth2RefreshToken> getRefreshToken()Returns theOAuth2Authorization.Token
of typeOAuth2RefreshToken
.- Returns:
- the
OAuth2Authorization.Token
of typeOAuth2RefreshToken
, ornull
if not available
-
getToken
@Nullable public <T extends org.springframework.security.oauth2.core.OAuth2Token> OAuth2Authorization.Token<T> getToken(Class<T> tokenType) Returns theOAuth2Authorization.Token
of typetokenType
.- Type Parameters:
T
- the type of the token- Parameters:
tokenType
- the token type- Returns:
- the
OAuth2Authorization.Token
, ornull
if not available
-
getToken
@Nullable public <T extends org.springframework.security.oauth2.core.OAuth2Token> OAuth2Authorization.Token<T> getToken(String tokenValue) Returns theOAuth2Authorization.Token
matching thetokenValue
.- Type Parameters:
T
- the type of the token- Parameters:
tokenValue
- the token value- Returns:
- the
OAuth2Authorization.Token
, ornull
if not available
-
getAttributes
Returns the attribute(s) associated to the authorization.- Returns:
- a
Map
of 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
null
if 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
- theOAuth2Authorization
used for initializing theOAuth2Authorization.Builder
- Returns:
- the
OAuth2Authorization.Builder
-