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

    Fields
    Modifier and Type
    Field
    Description
    private JwtService
    The service that handles the JWT.
    The service that handles the user details of the application.

    Fields inherited from class org.springframework.web.filter.OncePerRequestFilter

    ALREADY_FILTERED_SUFFIX

    Fields inherited from class org.springframework.web.filter.GenericFilterBean

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doFilterInternal(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, shouldNotFilterErrorDispatch

    Methods inherited from class org.springframework.web.filter.GenericFilterBean

    addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • jwtService

      private JwtService jwtService
      The service that handles the JWT.
    • userDetailsService

      private AppUserDetailsService 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:
      doFilterInternal in class org.springframework.web.filter.OncePerRequestFilter
      Parameters:
      request - The request to be filtered
      response - The response to be filtered
      filterChain - The chain of filters to be applied
      Throws:
      jakarta.servlet.ServletException - If the request cannot be handled
      IOException - If an input or output error occurs while the filter is handling the request, in the filterChain