Class OpaqueTokenAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.oauth2.server.resource.authentication.OpaqueTokenAuthenticationProvider
-
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public final class OpaqueTokenAuthenticationProvider extends java.lang.Object implements org.springframework.security.authentication.AuthenticationProviderAnAuthenticationProviderimplementation for opaque Bearer Tokens, using an OAuth 2.0 Introspection Endpoint to check the token's validity and reveal its attributes.This
AuthenticationProvideris responsible for introspecting and verifying an opaque access token, returning its attributes set as part of theAuthenticationstatement.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
OpaqueTokenIntrospectoris responsible for retrieving token attributes from an authorization server.An
OpaqueTokenAuthenticationConverteris responsible for turning a successful introspection result into anAuthenticationinstance (which may include mappingGrantedAuthoritys from token attributes or retrieving from another source).- Since:
- 5.2
- See Also:
AuthenticationProvider
-
-
Constructor Summary
Constructors Constructor Description OpaqueTokenAuthenticationProvider(OpaqueTokenIntrospector introspector)Creates aOpaqueTokenAuthenticationProviderwith the provided parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.security.core.Authenticationauthenticate(org.springframework.security.core.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.booleansupports(java.lang.Class<?> authentication)
-
-
-
Constructor Detail
-
OpaqueTokenAuthenticationProvider
public OpaqueTokenAuthenticationProvider(OpaqueTokenIntrospector introspector)
Creates aOpaqueTokenAuthenticationProviderwith the provided parameters- Parameters:
introspector- TheOpaqueTokenIntrospectorto use
-
-
Method Detail
-
authenticate
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationExceptionIntrospect 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 interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- the authentication request object.- Returns:
- A successful authentication
- Throws:
org.springframework.security.core.AuthenticationException- if authentication failed for some reason
-
supports
public boolean supports(java.lang.Class<?> authentication)
- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider
-
setAuthenticationConverter
public void setAuthenticationConverter(OpaqueTokenAuthenticationConverter authenticationConverter)
Provide 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
-
-