Class OpaqueTokenAuthenticationProvider
- All Implemented Interfaces:
- AuthenticationProvider
AuthenticationProvider implementation for opaque
 Bearer
 Tokens, using an
 OAuth 2.0 Introspection
 Endpoint to check the token's validity and reveal its attributes.
 
 This AuthenticationProvider is responsible for introspecting and verifying an
 opaque access token, returning its attributes set as part of the Authentication
 statement.
 
 Scopes are translated into GrantedAuthoritys according to the following
 algorithm:
 
- If there is a "scope" attribute, then convert to a CollectionofStrings.
- Take the resulting Collectionand prepend the "SCOPE_" keyword to each element, adding asGrantedAuthoritys.
 An OpaqueTokenIntrospector is responsible for retrieving token attributes from
 an authorization server.
 
 An OpaqueTokenAuthenticationConverter is responsible for turning a successful
 introspection result into an Authentication instance (which may include mapping
 GrantedAuthoritys from token attributes or retrieving from another source).
- Since:
- 5.2
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionOpaqueTokenAuthenticationProvider(OpaqueTokenIntrospector introspector) Creates aOpaqueTokenAuthenticationProviderwith the provided parameters
- 
Method SummaryModifier and TypeMethodDescriptionauthenticate(Authentication authentication) Introspect and validate the opaque Bearer Token and then delegatesAuthenticationinstantiation toOpaqueTokenAuthenticationConverter.voidsetAuthenticationConverter(OpaqueTokenAuthenticationConverter authenticationConverter) Provide with a custom bean to turn successful introspection result into anAuthenticationinstance of your choice.booleanReturnstrueif thisAuthenticationProvidersupports the indicatedAuthenticationobject.
- 
Constructor Details- 
OpaqueTokenAuthenticationProviderCreates aOpaqueTokenAuthenticationProviderwith the provided parameters- Parameters:
- introspector- The- OpaqueTokenIntrospectorto use
 
 
- 
- 
Method Details- 
authenticateIntrospect and validate the opaque Bearer Token and then delegatesAuthenticationinstantiation toOpaqueTokenAuthenticationConverter.If created Authentication is instance of AbstractAuthenticationTokenand details are null, then introspection result details are used.- Specified by:
- authenticatein interface- AuthenticationProvider
- Parameters:
- authentication- the authentication request object.
- Returns:
- A successful authentication
- Throws:
- AuthenticationException- if authentication failed for some reason
 
- 
supportsDescription copied from interface:AuthenticationProviderReturnstrueif thisAuthenticationProvidersupports the indicatedAuthenticationobject.Returning truedoes not guarantee anAuthenticationProviderwill be able to authenticate the presentedAuthenticationobject. It simply indicates it can support closer evaluation of it. AnAuthenticationProvidercan still returnnullfrom theAuthenticationProvider.authenticate(Authentication)method to indicate anotherAuthenticationProvidershould be tried.Selection of an AuthenticationProvidercapable of performing authentication is conducted at runtime theProviderManager.- Specified by:
- supportsin interface- AuthenticationProvider
- Returns:
- trueif the implementation can more closely evaluate the- Authenticationclass presented
 
- 
setAuthenticationConverterProvide with a custom bean to turn successful introspection result into anAuthenticationinstance of your choice. By default,BearerTokenAuthenticationwill be built.- Parameters:
- authenticationConverter- the converter to use
- Since:
- 5.8
 
 
-