Class DefaultTokenService

  • All Implemented Interfaces:
    TokenService

    public class DefaultTokenService
    extends java.lang.Object
    implements TokenService
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkIfTokenIsValid​(java.lang.String userId, java.lang.String tokenToCheck)
      Method verifies if passed token for particular user is valid
      java.lang.String getOrCreateTokenForUser​(java.lang.String userId)
      Method should return the current token assigned to user or create it and return it if the token does not exist
      boolean revokeTokenForUser​(java.lang.String userId)
      Method should invalidate the current token for user
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultTokenService

        public DefaultTokenService​(ModelService modelService,
                                   UserDao userDao)
    • Method Detail

      • getOrCreateTokenForUser

        public java.lang.String getOrCreateTokenForUser​(java.lang.String userId)
        Description copied from interface: TokenService
        Method should return the current token assigned to user or create it and return it if the token does not exist
        Specified by:
        getOrCreateTokenForUser in interface TokenService
        Parameters:
        userId - uid
        Returns:
        token assigned to user
      • revokeTokenForUser

        public boolean revokeTokenForUser​(java.lang.String userId)
        Description copied from interface: TokenService
        Method should invalidate the current token for user
        Specified by:
        revokeTokenForUser in interface TokenService
        Parameters:
        userId - uid
        Returns:
        true if operation was successful
      • checkIfTokenIsValid

        public boolean checkIfTokenIsValid​(java.lang.String userId,
                                           java.lang.String tokenToCheck)
        Description copied from interface: TokenService
        Method verifies if passed token for particular user is valid
        Specified by:
        checkIfTokenIsValid in interface TokenService
        Parameters:
        userId - uid
        tokenToCheck - token to be verified
        Returns:
        true if the token submitted for verification matches the one currently assigned to the user