Package org.dspace.app.rest.security.jwt
Class JWTTokenHandler
- java.lang.Object
-
- org.dspace.app.rest.security.jwt.JWTTokenHandler
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
@Component public class JWTTokenHandler extends Object implements org.springframework.beans.factory.InitializingBean
Class responsible for creating and parsing JWTs, supports both JWS and JWE- Author:
- Frederic Van Reet (frederic dot vanreet at atmire dot com), Tom Desair (tom dot desair at atmire dot com)
-
-
Constructor Summary
Constructors Constructor Description JWTTokenHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()StringcreateTokenForEPerson(Context context, javax.servlet.http.HttpServletRequest request, Date previousLoginDate, List<Group> groups)Create a jwt with the EPerson details in itbyte[]getEncryptionKey()longgetExpirationPeriod()voidinvalidateToken(String token, javax.servlet.http.HttpServletRequest request, Context context)booleanisEncryptionEnabled()EPersonparseEPersonFromToken(String token, javax.servlet.http.HttpServletRequest request, Context context)Retrieve EPerson from a jwt
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
parseEPersonFromToken
public EPerson parseEPersonFromToken(String token, javax.servlet.http.HttpServletRequest request, Context context) throws com.nimbusds.jose.JOSEException, ParseException, SQLException
Retrieve EPerson from a jwt- Parameters:
token-request-context-- Returns:
- Throws:
com.nimbusds.jose.JOSEExceptionParseExceptionSQLException
-
createTokenForEPerson
public String createTokenForEPerson(Context context, javax.servlet.http.HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws com.nimbusds.jose.JOSEException, SQLException
Create a jwt with the EPerson details in it- Parameters:
context-request-previousLoginDate-groups-- Returns:
- Throws:
com.nimbusds.jose.JOSEExceptionSQLException
-
invalidateToken
public void invalidateToken(String token, javax.servlet.http.HttpServletRequest request, Context context) throws Exception
- Throws:
Exception
-
getExpirationPeriod
public long getExpirationPeriod()
-
isEncryptionEnabled
public boolean isEncryptionEnabled()
-
getEncryptionKey
public byte[] getEncryptionKey()
-
-