Package io.micronaut.security.token
Class TokenAuthenticationFetcher
- java.lang.Object
-
- io.micronaut.security.token.TokenAuthenticationFetcher
-
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,AuthenticationFetcher
@Singleton public class TokenAuthenticationFetcher extends java.lang.Object implements AuthenticationFetcher
Attempts to retrieve a token form theHttpRequest
and if existing validated. It uses aTokenResolver
and the list ofTokenValidator
registered in the ApplicationContext.- Since:
- 1.0
- Author:
- Sergio del Amo, Graeme Rocher
-
-
Field Summary
Fields Modifier and Type Field Description protected io.micronaut.context.event.ApplicationEventPublisher
eventPublisher
static java.lang.Integer
ORDER
The order of the fetcher.protected java.util.Collection<TokenValidator>
tokenValidators
-
Constructor Summary
Constructors Constructor Description TokenAuthenticationFetcher(java.util.Collection<TokenValidator> tokenValidators, TokenResolver tokenResolver, io.micronaut.context.event.ApplicationEventPublisher eventPublisher)
TokenAuthenticationFetcher(java.util.Collection<TokenValidator> tokenValidators, java.util.Collection<TokenReader> tokenReaders, io.micronaut.context.event.ApplicationEventPublisher eventPublisher)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactivestreams.Publisher<Authentication>
fetchAuthentication(io.micronaut.http.HttpRequest<?> request)
Attempts to read anAuthentication
from aHttpRequest
being executed.int
getOrder()
-
-
-
Field Detail
-
ORDER
public static final java.lang.Integer ORDER
The order of the fetcher.
-
tokenValidators
protected final java.util.Collection<TokenValidator> tokenValidators
-
eventPublisher
protected final io.micronaut.context.event.ApplicationEventPublisher eventPublisher
-
-
Constructor Detail
-
TokenAuthenticationFetcher
@Inject public TokenAuthenticationFetcher(java.util.Collection<TokenValidator> tokenValidators, TokenResolver tokenResolver, io.micronaut.context.event.ApplicationEventPublisher eventPublisher)
- Parameters:
tokenValidators
- The list ofTokenValidator
which attempt to validate the requesttokenResolver
- TheTokenResolver
which returns the first found token in the request.eventPublisher
- The Application event publisher
-
TokenAuthenticationFetcher
@Deprecated public TokenAuthenticationFetcher(java.util.Collection<TokenValidator> tokenValidators, java.util.Collection<TokenReader> tokenReaders, io.micronaut.context.event.ApplicationEventPublisher eventPublisher)
Deprecated.UseTokenAuthenticationFetcher(Collection, TokenResolver, ApplicationEventPublisher)
instead. ATokenResolver
can be created usingDefaultTokenResolver(Collection)
.- Parameters:
tokenValidators
- The list ofTokenValidator
which attempt to validate the requesttokenReaders
- The listTokenReader
which attempt to read the requesteventPublisher
- The Application event publisher
-
-
Method Detail
-
fetchAuthentication
public org.reactivestreams.Publisher<Authentication> fetchAuthentication(io.micronaut.http.HttpRequest<?> request)
Description copied from interface:AuthenticationFetcher
Attempts to read anAuthentication
from aHttpRequest
being executed.- Specified by:
fetchAuthentication
in interfaceAuthenticationFetcher
- Parameters:
request
-HttpRequest
being executed.- Returns:
Authentication
if found
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-
-