Package io.micronaut.security.token
Class TokenAuthenticationFetcher
java.lang.Object
io.micronaut.security.token.TokenAuthenticationFetcher
- All Implemented Interfaces:
- io.micronaut.core.order.Ordered,- AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
@Requires(classes=io.micronaut.http.HttpRequest.class) @Requires(beans=io.micronaut.http.server.util.HttpHostResolver.class)
@Singleton
public class TokenAuthenticationFetcher
extends Object
implements AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
Attempts to retrieve a token form the 
HttpRequest and if existing validated.
 It uses a TokenResolver and the list of TokenValidator registered in the ApplicationContext.- Since:
- 1.0
- Author:
- Sergio del Amo, Graeme Rocher
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final io.micronaut.http.server.util.HttpHostResolverprotected final io.micronaut.http.server.util.locale.HttpLocaleResolverstatic final IntegerThe order of the fetcher.protected final io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent>protected final Collection<TokenValidator<io.micronaut.http.HttpRequest<?>>>Fields inherited from interface io.micronaut.core.order.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionTokenAuthenticationFetcher(Collection<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.TokenAuthenticationFetcher(List<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.TokenAuthenticationFetcher(List<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher, io.micronaut.http.server.util.HttpHostResolver httpHostResolver, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) 
- 
Method SummaryModifier and TypeMethodDescriptionorg.reactivestreams.Publisher<Authentication>fetchAuthentication(io.micronaut.http.HttpRequest<?> request) Attempts to read anAuthenticationfrom an HTTP Request being executed.intgetOrder()
- 
Field Details- 
ORDERThe order of the fetcher.
- 
tokenValidators
- 
httpHostResolverprotected final io.micronaut.http.server.util.HttpHostResolver httpHostResolver
- 
httpLocaleResolverprotected final io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver
- 
tokenValidatedEventPublisherprotected final io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher
 
- 
- 
Constructor Details- 
TokenAuthenticationFetcher@Deprecated(forRemoval=true, since="4.4.0") public TokenAuthenticationFetcher(Collection<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
- tokenValidators- The list of- TokenValidatorwhich attempt to validate the request
- tokenResolver- The- TokenResolverwhich returns the first found token in the request.
- tokenValidatedEventPublisher- Application event publisher for- TokenValidatedEvent.
 
- 
TokenAuthenticationFetcher@Deprecated(forRemoval=true, since="4.7.0") public TokenAuthenticationFetcher(List<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
- tokenValidators- The list of- TokenValidatorwhich attempt to validate the request
- tokenResolver- The- TokenResolverwhich returns the first found token in the request.
- tokenValidatedEventPublisher- Application event publisher for- TokenValidatedEvent.
 
- 
TokenAuthenticationFetcher@Inject public TokenAuthenticationFetcher(List<TokenValidator<io.micronaut.http.HttpRequest<?>>> tokenValidators, TokenResolver<io.micronaut.http.HttpRequest<?>> tokenResolver, io.micronaut.context.event.ApplicationEventPublisher<TokenValidatedEvent> tokenValidatedEventPublisher, io.micronaut.http.server.util.HttpHostResolver httpHostResolver, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) - Parameters:
- tokenValidators- The list of- TokenValidatorwhich attempt to validate the request
- tokenResolver- The- TokenResolverwhich returns the first found token in the request.
- tokenValidatedEventPublisher- Application event publisher for- TokenValidatedEvent.
- httpHostResolver- The http host resolver
- httpLocaleResolver- The http locale resolver
- Since:
- 4.7.0
 
 
- 
- 
Method Details- 
fetchAuthenticationpublic org.reactivestreams.Publisher<Authentication> fetchAuthentication(io.micronaut.http.HttpRequest<?> request) Description copied from interface:AuthenticationFetcherAttempts to read anAuthenticationfrom an HTTP Request being executed.- Specified by:
- fetchAuthenticationin interface- AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
- Parameters:
- request- an HTTP Request being executed.
- Returns:
- Authenticationif found
 
- 
getOrderpublic int getOrder()- Specified by:
- getOrderin interface- io.micronaut.core.order.Ordered
 
 
- 
TokenAuthenticationFetcher(java.util.List<io.micronaut.security.token.validator.TokenValidator<io.micronaut.http.HttpRequest<?>>>,io.micronaut.security.token.reader.TokenResolver<io.micronaut.http.HttpRequest<?>>,io.micronaut.context.event.ApplicationEventPublisher<io.micronaut.security.event.TokenValidatedEvent>)instead.