Class JwtTokenServiceImpl
java.lang.Object
com.espacogeek.geek.services.impl.JwtTokenServiceImpl
- All Implemented Interfaces:
JwtTokenService
Implementation of JwtTokenService.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintClean up expired tokens.voiddeleteToken(String token) Delete a specific token.voiddeleteUserTokens(Integer userId) Delete all tokens for a user.findByToken(String token) Find a token by its value.findByUserId(Integer userId) Get all tokens for a user.booleanisTokenValid(String token) Validate if a token exists and is not expired.Save a new JWT token.
-
Constructor Details
-
JwtTokenServiceImpl
public JwtTokenServiceImpl()
-
-
Method Details
-
saveToken
Description copied from interface:JwtTokenServiceSave a new JWT token.- Specified by:
saveTokenin interfaceJwtTokenService- Parameters:
token- the JWT token stringuser- the user associated with the tokendeviceInfo- optional device information- Returns:
- the saved JwtTokenModel
-
isTokenValid
Description copied from interface:JwtTokenServiceValidate if a token exists and is not expired.- Specified by:
isTokenValidin interfaceJwtTokenService- Parameters:
token- the JWT token string- Returns:
- true if valid, false otherwise
-
findByToken
Description copied from interface:JwtTokenServiceFind a token by its value.- Specified by:
findByTokenin interfaceJwtTokenService- Parameters:
token- the JWT token string- Returns:
- Optional containing the token model if found
-
findByUserId
Description copied from interface:JwtTokenServiceGet all tokens for a user.- Specified by:
findByUserIdin interfaceJwtTokenService- Parameters:
userId- the user ID- Returns:
- list of tokens for the user
-
deleteToken
Description copied from interface:JwtTokenServiceDelete a specific token.- Specified by:
deleteTokenin interfaceJwtTokenService- Parameters:
token- the JWT token string
-
deleteUserTokens
Description copied from interface:JwtTokenServiceDelete all tokens for a user.- Specified by:
deleteUserTokensin interfaceJwtTokenService- Parameters:
userId- the user ID
-
cleanupExpiredTokens
@Transactional @Scheduled(cron="* * 23 * * *") public int cleanupExpiredTokens()Description copied from interface:JwtTokenServiceClean up expired tokens.- Specified by:
cleanupExpiredTokensin interfaceJwtTokenService- Returns:
- number of deleted tokens
-