Class JwtAuthenticationService
java.lang.Object
cf.maybelambda.httpvalidator.springboot.service.JwtAuthenticationService
Service for handling JWT authentication, including token generation,
validation, and secret key management.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNewTokenValidFor
(int hours) Generates a new signed JWT token that is valid for a specified number of hours.boolean
isValidToken
(String authorizationHeader) Validates a JWT token from the Authorization header of an incoming request.
-
Field Details
-
BEARER_PREFIX
- See Also:
-
-
Constructor Details
-
JwtAuthenticationService
public JwtAuthenticationService()
-
-
Method Details
-
getNewTokenValidFor
Generates a new signed JWT token that is valid for a specified number of hours.- Parameters:
hours
- Number of hours the token is valid for- Returns:
- JWT token
-
isValidToken
Validates a JWT token from the Authorization header of an incoming request.- Parameters:
authorizationHeader
- Authorization header containing the JWT token- Returns:
- true if the token is valid, false otherwise or if the header is null or empty
-