Klasse JwtService
java.lang.Object
com.spaghetticodegang.trylater.security.JwtService
Service layer for generating and extracting JWT tokens.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungJwtService
(String secret, int expirationDays) Initializes the JWT service with the secret key and token expiration period. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungextractUsernameFromToken
(String token) Extracts the username (subject) from a valid JWT token.generateTokenWithUsername
(String username) Generates a signed JWT token containing the given username as subject.
-
Konstruktordetails
-
JwtService
public JwtService(@Value("${jwt.secret}") String secret, @Value("${jwt.expiration-days}") int expirationDays) Initializes the JWT service with the secret key and token expiration period.- Parameter:
secret
- the secret used to sign tokensexpirationDays
- the token validity duration in days
-
-
Methodendetails
-
generateTokenWithUsername
-
extractUsernameFromToken
-