Package api.mpba.rastvdmy.service
Interface JwtService
- All Known Implementing Classes:
JwtServiceImpl
public interface JwtService
Service interface for managing JWT (JSON Web Token) operations.
-
Method Summary
Modifier and TypeMethodDescriptionextractSubject
(String token) Extracts the subject from the provided JWT token.extractToken
(jakarta.servlet.http.HttpServletRequest request) Extracts the JWT token from the provided HTTP request.extractUsername
(String token) Extracts the username from the provided JWT token.generateToken
(org.springframework.security.core.userdetails.UserDetails userDetails) Generates a new JWT token for the specified user details.long
Retrieves the expiration time for the JWT token in milliseconds.boolean
isTokenValid
(String token, org.springframework.security.core.userdetails.UserDetails userDetails) Validates the provided JWT token against the specified user details.
-
Method Details
-
extractUsername
Extracts the username from the provided JWT token.- Parameters:
token
- the JWT token from which to extract the username- Returns:
- the username contained in the token
-
generateToken
Generates a new JWT token for the specified user details.- Parameters:
userDetails
- the user details for whom to generate the token- Returns:
- the generated JWT token as a string
-
getExpirationTime
long getExpirationTime()Retrieves the expiration time for the JWT token in milliseconds.- Returns:
- the expiration time for the token
-
isTokenValid
boolean isTokenValid(String token, org.springframework.security.core.userdetails.UserDetails userDetails) Validates the provided JWT token against the specified user details.- Parameters:
token
- the JWT token to validateuserDetails
- the user details to check against- Returns:
- true if the token is valid for the user details; false otherwise
-
extractToken
Extracts the JWT token from the provided HTTP request.- Parameters:
request
- the HTTP request containing the token- Returns:
- the extracted JWT token as a string
-
extractSubject
Extracts the subject from the provided JWT token.- Parameters:
token
- the JWT token from which to extract the subject- Returns:
- the subject contained in the token
-