Package com.example.blogs.app.exception
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidcommence(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.
-
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:
commencein interfaceorg.springframework.security.web.AuthenticationEntryPoint- Parameters:
request- the HTTP request that triggered authenticationresponse- the HTTP response to write toauthException- the authentication exception that occurred- Throws:
IOException- if writing to response fails
-