Package org.dspace.app.rest.security.jwt
Class ShortLivedJWTTokenHandler
java.lang.Object
org.dspace.app.rest.security.jwt.JWTTokenHandler
org.dspace.app.rest.security.jwt.ShortLivedJWTTokenHandler
Class responsible for creating and parsing JSON Web Tokens (JWTs) used for bitstream
downloads among other things, supports both JWS and JWE https://jwt.io/ .
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringGet the configuration property key for the compression enable setting.protected StringGet the configuration property key for the encryption enable setting.protected StringGet the configuration property key for the encryption secret.protected StringGet the configuration property key for the expiration time.protected StringGet the configuration property key for the token secret.protected booleanisValidToken(jakarta.servlet.http.HttpServletRequest request, com.nimbusds.jwt.SignedJWT signedJWT, com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet, EPerson ePerson) Determine if current JWT is valid for the given EPerson object.protected EPersonupdateSessionSalt(Context context, Instant previousLoginDate) The session salt doesn't need to be updated for short lived tokens.Methods inherited from class org.dspace.app.rest.security.jwt.JWTTokenHandler
buildSigningKey, createTokenForEPerson, getCompressionEnabled, getEncryptionKey, getExpirationPeriod, getJwtKey, invalidateToken, isEncryptionEnabled, parseEPersonFromToken
-
Constructor Details
-
ShortLivedJWTTokenHandler
public ShortLivedJWTTokenHandler()
-
-
Method Details
-
isValidToken
protected boolean isValidToken(jakarta.servlet.http.HttpServletRequest request, com.nimbusds.jwt.SignedJWT signedJWT, com.nimbusds.jwt.JWTClaimsSet jwtClaimsSet, EPerson ePerson) throws com.nimbusds.jose.JOSEException Determine if current JWT is valid for the given EPerson object. To be valid, current JWT *must* have been signed by the EPerson and not be expired. If EPerson is null or does not have a known active session, false is returned immediately.- Overrides:
isValidTokenin classJWTTokenHandler- Parameters:
request- current requestsignedJWT- current signed JWTjwtClaimsSet- claims set of current JWTePerson- EPerson parsed from current signed JWT- Returns:
- true if valid, false otherwise
- Throws:
com.nimbusds.jose.JOSEException
-
updateSessionSalt
The session salt doesn't need to be updated for short lived tokens.- Overrides:
updateSessionSaltin classJWTTokenHandler- Parameters:
context- current DSpace ContextpreviousLoginDate- date of last login (prior to this one)- Returns:
- EPerson object of current user, with an updated session salt
-
getTokenSecretConfigurationKey
Description copied from class:JWTTokenHandlerGet the configuration property key for the token secret.- Specified by:
getTokenSecretConfigurationKeyin classJWTTokenHandler- Returns:
- the configuration property key
-
getEncryptionSecretConfigurationKey
Description copied from class:JWTTokenHandlerGet the configuration property key for the encryption secret.- Specified by:
getEncryptionSecretConfigurationKeyin classJWTTokenHandler- Returns:
- the configuration property key
-
getTokenExpirationConfigurationKey
Description copied from class:JWTTokenHandlerGet the configuration property key for the expiration time.- Specified by:
getTokenExpirationConfigurationKeyin classJWTTokenHandler- Returns:
- the configuration property key
-
getEncryptionEnabledConfigurationKey
Description copied from class:JWTTokenHandlerGet the configuration property key for the encryption enable setting.- Specified by:
getEncryptionEnabledConfigurationKeyin classJWTTokenHandler- Returns:
- the configuration property key
-
getCompressionEnabledConfigurationKey
Description copied from class:JWTTokenHandlerGet the configuration property key for the compression enable setting.- Specified by:
getCompressionEnabledConfigurationKeyin classJWTTokenHandler- Returns:
- the configuration property key
-