Class RestClientOpaqueTokenIntrospector
java.lang.Object
org.springframework.security.oauth2.server.resource.introspection.RestClientOpaqueTokenIntrospector
- All Implemented Interfaces:
OpaqueTokenIntrospector
public final class RestClientOpaqueTokenIntrospector
extends Object
implements OpaqueTokenIntrospector
A Spring implementation of
OpaqueTokenIntrospector that verifies and
introspects a token using the configured
OAuth 2.0 Introspection
Endpoint, using RestClient for HTTP communication.- Since:
- 7.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classUsed to buildRestClientOpaqueTokenIntrospector. -
Constructor Summary
ConstructorsConstructorDescriptionRestClientOpaqueTokenIntrospector(String introspectionUri, org.springframework.web.client.RestClient restClient) Creates aOpaqueTokenAuthenticationProviderwith the provided parameters The givenRestClientshould perform its own client authentication against the introspection endpoint. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipalintrospect(String token) Introspect and verify the given token, returning its attributes.voidsetAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.core.OAuth2TokenIntrospectionClaimAccessor, ? extends org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal> authenticationConverter) Sets theConverter<OAuth2TokenIntrospectionClaimAccessor, OAuth2AuthenticatedPrincipal>to use.withIntrospectionUri(String introspectionUri) Creates aRestClientOpaqueTokenIntrospector.Builderwith the given introspection endpoint uri
-
Constructor Details
-
RestClientOpaqueTokenIntrospector
public RestClientOpaqueTokenIntrospector(String introspectionUri, org.springframework.web.client.RestClient restClient) Creates aOpaqueTokenAuthenticationProviderwith the provided parameters The givenRestClientshould perform its own client authentication against the introspection endpoint.- Parameters:
introspectionUri- The introspection endpoint urirestClient- The client for performing the introspection request
-
-
Method Details
-
introspect
public org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal introspect(String token) Description copied from interface:OpaqueTokenIntrospectorIntrospect and verify the given token, returning its attributes. Returning aOAuth2AuthenticatedPrincipalis indicative that the token is valid.- Specified by:
introspectin interfaceOpaqueTokenIntrospector- Parameters:
token- the token to introspect- Returns:
- the token's attributes
-
setAuthenticationConverter
public void setAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.core.OAuth2TokenIntrospectionClaimAccessor, ? extends org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal> authenticationConverter) Sets the
Converter<OAuth2TokenIntrospectionClaimAccessor, OAuth2AuthenticatedPrincipal>to use. Defaults todefaultAuthenticationConverter(OAuth2TokenIntrospectionClaimAccessor).Use if you need a custom mapping of OAuth 2.0 token claims to the authenticated principal.
- Parameters:
authenticationConverter- the converter
-
withIntrospectionUri
public static RestClientOpaqueTokenIntrospector.Builder withIntrospectionUri(String introspectionUri) Creates aRestClientOpaqueTokenIntrospector.Builderwith the given introspection endpoint uri- Parameters:
introspectionUri- The introspection endpoint uri- Returns:
- the
RestClientOpaqueTokenIntrospector.Builder
-