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
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T> TgetAttribute(String name) Returns the value of an attribute associated to the context ornullif not available.Returns the attributes associated to the context.Returns theclient registration.org.springframework.security.core.AuthenticationReturns thePrincipal(to be) associated to the authorized client.withAuthorizedClient(OAuth2AuthorizedClient authorizedClient) Returns a newOAuth2AuthorizationContext.Builderinitialized with theOAuth2AuthorizedClient.withClientRegistration(ClientRegistration clientRegistration) Returns a newOAuth2AuthorizationContext.Builderinitialized with theClientRegistration.
-
Field Details
-
REQUEST_SCOPE_ATTRIBUTE_NAME
-
-
Method Details
-
getClientRegistration
Returns theclient registration.- Returns:
- the
ClientRegistration
-
getAuthorizedClient
- Returns:
- the
OAuth2AuthorizedClientornullif the client registration was supplied
-
getPrincipal
public org.springframework.security.core.Authentication 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
Mapof the attributes associated to the context
-
getAttribute
Returns the value of an attribute associated to the context ornullif 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.Builderinitialized with theClientRegistration.- Parameters:
clientRegistration- theclient registration- Returns:
- the
OAuth2AuthorizationContext.Builder
-
withAuthorizedClient
public static OAuth2AuthorizationContext.Builder withAuthorizedClient(OAuth2AuthorizedClient authorizedClient) Returns a newOAuth2AuthorizationContext.Builderinitialized with theOAuth2AuthorizedClient.- Parameters:
authorizedClient- theauthorized client- Returns:
- the
OAuth2AuthorizationContext.Builder
-