Package org.nuxeo.ecm.jwt
Class JWTServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.jwt.JWTServiceImpl
-
- All Implemented Interfaces:
JWTService
,Adaptable
,Component
,Extensible
,TimestampedService
public class JWTServiceImpl extends DefaultComponent implements JWTService
The JSON Web Token Service implementation.- Since:
- 10.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JWTServiceImpl.JWTBuilderImpl
Implementation ofJWTService.JWTBuilder
delegating to the auth0 JWT library.protected static class
JWTServiceImpl.JWTServiceConfigurationRegistry
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.jwt.JWTService
JWTService.JWTBuilder
-
-
Field Summary
Fields Modifier and Type Field Description protected static com.fasterxml.jackson.core.type.TypeReference<Map<String,Object>>
MAP_STRING_OBJECT
static String
NUXEO_ISSUER
protected static com.fasterxml.jackson.databind.ObjectMapper
OBJECT_MAPPER
protected JWTServiceImpl.JWTServiceConfigurationRegistry
registry
static String
XP_CONFIGURATION
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description JWTServiceImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
builderWithClaim(com.auth0.jwt.JWTCreator.Builder builder, String name, Object value)
protected com.auth0.jwt.algorithms.Algorithm
getAlgorithm()
protected int
getDefaultTTL()
JWTService.JWTBuilder
newBuilder()
Creates a new builder for a JSON Web Token.protected static Object
nodeToValue(com.fasterxml.jackson.databind.JsonNode node)
Converts aJsonNode
to a Java value.void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
Map<String,Object>
verifyToken(String token)
Verifies the token and returns its claims, ornull
if the token is invalid (corrupted, constructed from an invalid secret, or expired).-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
XP_CONFIGURATION
public static final String XP_CONFIGURATION
- See Also:
- Constant Field Values
-
NUXEO_ISSUER
public static final String NUXEO_ISSUER
- See Also:
- Constant Field Values
-
OBJECT_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
MAP_STRING_OBJECT
protected static final com.fasterxml.jackson.core.type.TypeReference<Map<String,Object>> MAP_STRING_OBJECT
-
registry
protected final JWTServiceImpl.JWTServiceConfigurationRegistry registry
-
-
Method Detail
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
newBuilder
public JWTService.JWTBuilder newBuilder()
Description copied from interface:JWTService
Creates a new builder for a JSON Web Token.- Specified by:
newBuilder
in interfaceJWTService
- Returns:
- the new builder
-
builderWithClaim
protected void builderWithClaim(com.auth0.jwt.JWTCreator.Builder builder, String name, Object value)
-
verifyToken
public Map<String,Object> verifyToken(String token)
Description copied from interface:JWTService
Verifies the token and returns its claims, ornull
if the token is invalid (corrupted, constructed from an invalid secret, or expired).The claim
JWTClaims.CLAIM_SUBJECT
contains the token's creator user id.The token hash algorithm is based on a secret provided by the service configuration.
- Specified by:
verifyToken
in interfaceJWTService
- Parameters:
token
- the token- Returns:
- the claims if the token is valid, or
null
if the token is invalid
-
nodeToValue
protected static Object nodeToValue(com.fasterxml.jackson.databind.JsonNode node)
Converts aJsonNode
to a Java value.
-
getDefaultTTL
protected int getDefaultTTL()
-
getAlgorithm
protected com.auth0.jwt.algorithms.Algorithm getAlgorithm()
-
-