Class AbstractUserTokenService<E extends UserToken,​D extends AbstractUserTokenDao<E>>

    • Constructor Detail

      • AbstractUserTokenService

        public AbstractUserTokenService()
        Default constructor, which calls the type-constructor
      • AbstractUserTokenService

        protected AbstractUserTokenService​(java.lang.Class<E> entityClass)
        Constructor that sets the concrete entity class for the service. Subclasses MUST call this constructor.
    • Method Detail

      • buildConcreteInstance

        protected abstract E buildConcreteInstance​(User user,
                                                   java.lang.Integer expirationTimeInMinutes)
        Has to be implemented by subclasses to return a concrete instance for the given values. Should return an instance with a default expiration time if expirationTimeInMinutes is null.
        Parameters:
        user -
        expirationTimeInMinutes -
        Returns:
      • findByUser

        @Transactional(readOnly=true)
        public E findByUser​(User user)
        Parameters:
        user -
        Returns:
      • validateToken

        @Transactional(readOnly=true)
        public void validateToken​(E userToken)
                           throws java.lang.Exception
        If the passed token is null or expired or if there is no user associated with the token, this method will throw an Exception.
        Overrides:
        validateToken in class AbstractTokenService<E extends UserToken,​D extends AbstractUserTokenDao<E>>
        Parameters:
        userToken -
        Throws:
        java.lang.Exception - if the token is not valid (e.g. because it is expired)
      • getValidTokenForUser

        protected E getValidTokenForUser​(User user,
                                         java.lang.Integer expirationTimeInMinutes)
                                  throws java.lang.NoSuchMethodException,
                                         java.lang.SecurityException,
                                         java.lang.InstantiationException,
                                         java.lang.IllegalAccessException,
                                         java.lang.IllegalArgumentException,
                                         java.lang.reflect.InvocationTargetException
        Returns a valid (i.e. non-expired) UserToken for the given user. If the user already owns a valid token, it will be returned. If the user has an invalid/expired token, it will be deleted and a new one will be generated and returned by this method.

        An expiration time in minutes can also be passed. If this value is null, the default value will be used.

        Parameters:
        user - The user that needs a token.
        expirationTimeInMinutes - The expiration time in minutes. If null, the default value will be used.
        Returns:
        A valid user token.
        Throws:
        java.lang.SecurityException
        java.lang.NoSuchMethodException
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalArgumentException
        java.lang.IllegalAccessException
        java.lang.InstantiationException