Package it.univr.passportease.helper
Class RequestAnalyzer
java.lang.Object
it.univr.passportease.helper.RequestAnalyzer
This class is used to analyze the request and extract the JWT token from the Authorization header.
It also checks if the token is valid and not expired.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
The regex used to check if the token is valid.private final JwtService
The service used to check if the token is valid and not expired.private final jakarta.servlet.http.HttpServletRequest
The request to analyze. -
Constructor Summary
ConstructorDescriptionRequestAnalyzer
(JwtService jwtService, jakarta.servlet.http.HttpServletRequest request) Constructor for the RequestAnalyzer class. -
Method Summary
Modifier and TypeMethodDescriptionThis method extracts the JWT token from the Authorization header of the request.
-
Field Details
-
JWT_REGEX
The regex used to check if the token is valid.- See Also:
-
request
private final jakarta.servlet.http.HttpServletRequest requestThe request to analyze. -
jwtService
The service used to check if the token is valid and not expired.
-
-
Constructor Details
-
RequestAnalyzer
Constructor for the RequestAnalyzer class.- Parameters:
jwtService
- The service used to check if the token is valid and not expiredrequest
- The request to analyze
-
-
Method Details
-
getTokenFromRequest
This method extracts the JWT token from the Authorization header of the request.- Returns:
- The JWT token extracted from the Authorization header
- Throws:
AuthenticationCredentialsNotFoundException
- If the token is not provided, is invalid or expired
-