Class OAuth2AuthorizationContext
java.lang.Object
org.springframework.security.oauth2.client.OAuth2AuthorizationContext
A context that holds authorization-specific state and is used by an
OAuth2AuthorizedClientProvider
when attempting to authorize (or re-authorize)
an OAuth 2.0 Client.- Since:
- 5.2
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of theattribute
in the context associated to the value for the resource owner's password.static final String
The name of theattribute
in the context associated to the value for the "request scope(s)".static final String
The name of theattribute
in the context associated to the value for the resource owner's username. -
Method Summary
Modifier and TypeMethodDescription<T> T
getAttribute
(String name) Returns the value of an attribute associated to the context ornull
if not available.Returns the attributes associated to the context.Returns theclient registration
.Returns thePrincipal
(to be) associated to the authorized client.withAuthorizedClient
(OAuth2AuthorizedClient authorizedClient) Returns a newOAuth2AuthorizationContext.Builder
initialized with theOAuth2AuthorizedClient
.withClientRegistration
(ClientRegistration clientRegistration) Returns a newOAuth2AuthorizationContext.Builder
initialized with theClientRegistration
.
-
Field Details
-
Method Details
-
getClientRegistration
Returns theclient registration
.- Returns:
- the
ClientRegistration
-
getAuthorizedClient
- Returns:
- the
OAuth2AuthorizedClient
ornull
if the client registration was supplied
-
getPrincipal
Returns thePrincipal
(to be) associated to the authorized client.- Returns:
- the
Principal
(to be) associated to the authorized client
-
getAttributes
Returns the attributes associated to the context.- Returns:
- a
Map
of the attributes associated to the context
-
getAttribute
Returns the value of an attribute associated to the context ornull
if not available.- Type Parameters:
T
- the type of the attribute- Parameters:
name
- the name of the attribute- Returns:
- the value of the attribute associated to the context
-
withClientRegistration
public static OAuth2AuthorizationContext.Builder withClientRegistration(ClientRegistration clientRegistration) Returns a newOAuth2AuthorizationContext.Builder
initialized with theClientRegistration
.- Parameters:
clientRegistration
- theclient registration
- Returns:
- the
OAuth2AuthorizationContext.Builder
-
withAuthorizedClient
public static OAuth2AuthorizationContext.Builder withAuthorizedClient(OAuth2AuthorizedClient authorizedClient) Returns a newOAuth2AuthorizationContext.Builder
initialized with theOAuth2AuthorizedClient
.- Parameters:
authorizedClient
- theauthorized client
- Returns:
- the
OAuth2AuthorizationContext.Builder
-