Package it.univr.passportease.filter
Class JwtAuthFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
it.univr.passportease.filter.JwtAuthFilter
- All Implemented Interfaces:
jakarta.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
@Component
public class JwtAuthFilter
extends org.springframework.web.filter.OncePerRequestFilter
Filter that intercepts every request and checks if the user is authenticated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JwtServiceThe service that handles the JWT.private AppUserDetailsServiceThe service that handles the user details of the application.Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class org.springframework.web.filter.GenericFilterBean
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilterInternal(jakarta.servlet.http.HttpServletRequest request, @NotNull jakarta.servlet.http.HttpServletResponse response, @NotNull jakarta.servlet.FilterChain filterChain) Checks if the user is authenticated.Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Field Details
-
jwtService
The service that handles the JWT. -
userDetailsService
The service that handles the user details of the application. Used to manage the sessions.
-
-
Constructor Details
-
JwtAuthFilter
public JwtAuthFilter()
-
-
Method Details
-
doFilterInternal
protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest request, @NotNull @NotNull jakarta.servlet.http.HttpServletResponse response, @NotNull @NotNull jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException Checks if the user is authenticated.- Specified by:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Parameters:
request- The request to be filteredresponse- The response to be filteredfilterChain- The chain of filters to be applied- Throws:
jakarta.servlet.ServletException- If the request cannot be handledIOException- If an input or output error occurs while the filter is handling the request, in the filterChain
-