Class JwtUtil
java.lang.Object
com.needleandstitch.pavuk.security.JwtUtil
Utility class for handling JWT token operations, such as generating, parsing, and validating JWT tokens.
- Since:
- 15.12.2024
- Version:
- 1.0.0
- Author:
- Needle & Stitch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
extractClaim
(String token, Function<io.jsonwebtoken.Claims, T> claimsResolver) Extracts a specific claim from the JWT token.extractEmail
(String token) Extracts the email (subject) from the JWT token to identify the user associated with the token.extractExpiration
(String token) Extracts the expiration date from the JWT token.generateToken
(User user) Generates a JWT token for a given user.isTokenValid
(String token) Validates the JWT token.
-
Constructor Details
-
JwtUtil
public JwtUtil()
-
-
Method Details
-
generateToken
-
extractEmail
-
extractExpiration
-
extractClaim
Extracts a specific claim from the JWT token.- Type Parameters:
T
- Claim type- Parameters:
token
- The JWT token from which to extract the claimclaimsResolver
- A function that extracts the desired claim from the Claims object- Returns:
- The value of the extracted claim
-
isTokenValid
-