Class JwtTokenServiceImpl

java.lang.Object
com.espacogeek.geek.services.impl.JwtTokenServiceImpl
All Implemented Interfaces:
JwtTokenService

@Service public class JwtTokenServiceImpl extends Object implements JwtTokenService
Implementation of JwtTokenService.
  • Constructor Details

    • JwtTokenServiceImpl

      public JwtTokenServiceImpl()
  • Method Details

    • saveToken

      @Transactional public JwtTokenModel saveToken(String token, UserModel user, String deviceInfo)
      Description copied from interface: JwtTokenService
      Save a new JWT token.
      Specified by:
      saveToken in interface JwtTokenService
      Parameters:
      token - the JWT token string
      user - the user associated with the token
      deviceInfo - optional device information
      Returns:
      the saved JwtTokenModel
    • isTokenValid

      public boolean isTokenValid(String token)
      Description copied from interface: JwtTokenService
      Validate if a token exists and is not expired.
      Specified by:
      isTokenValid in interface JwtTokenService
      Parameters:
      token - the JWT token string
      Returns:
      true if valid, false otherwise
    • findByToken

      public Optional<JwtTokenModel> findByToken(String token)
      Description copied from interface: JwtTokenService
      Find a token by its value.
      Specified by:
      findByToken in interface JwtTokenService
      Parameters:
      token - the JWT token string
      Returns:
      Optional containing the token model if found
    • findByUserId

      public List<JwtTokenModel> findByUserId(Integer userId)
      Description copied from interface: JwtTokenService
      Get all tokens for a user.
      Specified by:
      findByUserId in interface JwtTokenService
      Parameters:
      userId - the user ID
      Returns:
      list of tokens for the user
    • deleteToken

      @Transactional public void deleteToken(String token)
      Description copied from interface: JwtTokenService
      Delete a specific token.
      Specified by:
      deleteToken in interface JwtTokenService
      Parameters:
      token - the JWT token string
    • deleteUserTokens

      @Transactional public void deleteUserTokens(Integer userId)
      Description copied from interface: JwtTokenService
      Delete all tokens for a user.
      Specified by:
      deleteUserTokens in interface JwtTokenService
      Parameters:
      userId - the user ID
    • cleanupExpiredTokens

      @Transactional @Scheduled(cron="* * 23 * * *") public int cleanupExpiredTokens()
      Description copied from interface: JwtTokenService
      Clean up expired tokens.
      Specified by:
      cleanupExpiredTokens in interface JwtTokenService
      Returns:
      number of deleted tokens