Class HttpHeaderTokenReader
java.lang.Object
io.micronaut.security.token.reader.HttpHeaderTokenReader
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,TokenReader<io.micronaut.http.HttpRequest<?>>
- Direct Known Subclasses:
BearerTokenReader
public abstract class HttpHeaderTokenReader
extends Object
implements TokenReader<io.micronaut.http.HttpRequest<?>>
Reads a token from an HTTP request and removes prefix from HTTP Header Value.
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionextractTokenFromAuthorization
(String authorization) findToken
(io.micronaut.http.HttpRequest<?> request) Search for a JWT token in a HTTP request.protected abstract String
protected abstract String
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Constructor Details
-
HttpHeaderTokenReader
public HttpHeaderTokenReader()
-
-
Method Details
-
getPrefix
- Returns:
- a Prefix before the token in the header value. E.g. Basic
-
getHeaderName
- Returns:
- an HTTP Header name. e.g. Authorization
-
findToken
Search for a JWT token in a HTTP request.- Specified by:
findToken
in interfaceTokenReader<io.micronaut.http.HttpRequest<?>>
- Parameters:
request
- The request to look for the token in- Returns:
- if the JWT token is found it is returned, empty if not
-
extractTokenFromAuthorization
- Parameters:
authorization
- Authorization header value- Returns:
- If prefix is 'Bearer' for 'Bearer XXX' it returns 'XXX'
-