Package io.micronaut.security.token
Class AbstractTokenAuthenticationFactory<T>
java.lang.Object
io.micronaut.security.token.AbstractTokenAuthenticationFactory<T>
- Type Parameters:
T
- The Token type. e.g JWT or Paseto
- All Implemented Interfaces:
TokenAuthenticationFactory<T>
- Direct Known Subclasses:
DefaultJwtAuthenticationFactory
public abstract class AbstractTokenAuthenticationFactory<T>
extends Object
implements TokenAuthenticationFactory<T>
Abstract implementation of
TokenAuthenticationFactory
which creates an authentication for a set of claims.- Since:
- 3.2.0
- Author:
- Sergio del Amo
-
Constructor Summary
ConstructorDescriptionAbstractTokenAuthenticationFactory
(TokenConfiguration tokenConfiguration, RolesFinder rolesFinder) -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<Authentication>
createAuthentication
(@NonNull Map<String, Object> attributes) usernameForClaims
(@NonNull Claims claims) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.security.token.TokenAuthenticationFactory
createAuthentication
-
Constructor Details
-
AbstractTokenAuthenticationFactory
public AbstractTokenAuthenticationFactory(TokenConfiguration tokenConfiguration, RolesFinder rolesFinder) - Parameters:
tokenConfiguration
- Token ConfigurationrolesFinder
- Utility to retrieve roles from token claims
-
-
Method Details
-
usernameForClaims
- Parameters:
claims
- Claims- Returns:
- the username defined by
TokenConfiguration.getNameKey()
()} or the sub claim.
-
createAuthentication
protected Optional<Authentication> createAuthentication(@NonNull @NonNull Map<String, Object> attributes) - Parameters:
attributes
- Claims- Returns:
Authentication
object based on the user claims
-