Class JwtAuthenticationEntryPoint

java.lang.Object
com.example.blogs.app.exception.JwtAuthenticationEntryPoint
All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint

@Component public class JwtAuthenticationEntryPoint extends Object implements org.springframework.security.web.AuthenticationEntryPoint
Handles JWT authentication failures by writing appropriate error responses.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException)
    Handles authentication exceptions by determining the error type and writing an appropriate response.

    Methods inherited from class java.lang.Object

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

    • JwtAuthenticationEntryPoint

      public JwtAuthenticationEntryPoint()
  • Method Details

    • commence

      public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) throws IOException
      Handles authentication exceptions by determining the error type and writing an appropriate response. Distinguishes between expired JWT tokens and other JWT validation failures.
      Specified by:
      commence in interface org.springframework.security.web.AuthenticationEntryPoint
      Parameters:
      request - the HTTP request that triggered authentication
      response - the HTTP response to write to
      authException - the authentication exception that occurred
      Throws:
      IOException - if writing to response fails