Class 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 Detail

      • JWTTokenHandler

        public JWTTokenHandler()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.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.JOSEException
        ParseException
        SQLException
      • 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.JOSEException
        SQLException
      • 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()