Class OAuth2AuthorizationContext
- java.lang.Object
-
- org.springframework.security.oauth2.client.OAuth2AuthorizationContext
-
public final class OAuth2AuthorizationContext extends java.lang.ObjectA context that holds authorization-specific state and is used by anOAuth2AuthorizedClientProviderwhen attempting to authorize (or re-authorize) an OAuth 2.0 Client.- Since:
- 5.2
- See Also:
OAuth2AuthorizedClientProvider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOAuth2AuthorizationContext.BuilderA builder forOAuth2AuthorizationContext.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPASSWORD_ATTRIBUTE_NAMEThe name of theattributein the context associated to the value for the resource owner's password.static java.lang.StringREQUEST_SCOPE_ATTRIBUTE_NAMEThe name of theattributein the context associated to the value for the "request scope(s)".static java.lang.StringUSERNAME_ATTRIBUTE_NAMEThe name of theattributein the context associated to the value for the resource owner's username.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetAttribute(java.lang.String name)Returns the value of an attribute associated to the context ornullif not available.java.util.Map<java.lang.String,java.lang.Object>getAttributes()Returns the attributes associated to the context.OAuth2AuthorizedClientgetAuthorizedClient()ClientRegistrationgetClientRegistration()Returns theclient registration.AuthenticationgetPrincipal()Returns thePrincipal(to be) associated to the authorized client.static OAuth2AuthorizationContext.BuilderwithAuthorizedClient(OAuth2AuthorizedClient authorizedClient)Returns a newOAuth2AuthorizationContext.Builderinitialized with theOAuth2AuthorizedClient.static OAuth2AuthorizationContext.BuilderwithClientRegistration(ClientRegistration clientRegistration)Returns a newOAuth2AuthorizationContext.Builderinitialized with theClientRegistration.
-
-
-
Field Detail
-
REQUEST_SCOPE_ATTRIBUTE_NAME
public static final java.lang.String REQUEST_SCOPE_ATTRIBUTE_NAME
-
USERNAME_ATTRIBUTE_NAME
public static final java.lang.String USERNAME_ATTRIBUTE_NAME
The name of theattributein the context associated to the value for the resource owner's username.
-
PASSWORD_ATTRIBUTE_NAME
public static final java.lang.String PASSWORD_ATTRIBUTE_NAME
The name of theattributein the context associated to the value for the resource owner's password.
-
-
Method Detail
-
getClientRegistration
public ClientRegistration getClientRegistration()
Returns theclient registration.- Returns:
- the
ClientRegistration
-
getAuthorizedClient
@Nullable public OAuth2AuthorizedClient getAuthorizedClient()
- Returns:
- the
OAuth2AuthorizedClientornullif the client registration was supplied
-
getPrincipal
public Authentication getPrincipal()
Returns thePrincipal(to be) associated to the authorized client.- Returns:
- the
Principal(to be) associated to the authorized client
-
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Returns the attributes associated to the context.- Returns:
- a
Mapof the attributes associated to the context
-
getAttribute
@Nullable public <T> T getAttribute(java.lang.String name)
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
-
-