Package api.mpba.rastvdmy.config
Class AuthenticationEntryPointImpl
java.lang.Object
api.mpba.rastvdmy.config.AuthenticationEntryPointImpl
- All Implemented Interfaces:
org.springframework.security.web.AuthenticationEntryPoint
@Component
public class AuthenticationEntryPointImpl
extends Object
implements org.springframework.security.web.AuthenticationEntryPoint
Custom implementation of
AuthenticationEntryPoint
used to handle authentication exceptions.
This class serves as an entry point for unauthenticated requests and utilizes a HandlerExceptionResolver
to resolve the authentication exception.
It is primarily used in security configurations to handle cases where a user tries to access a resource without proper authentication, by resolving the exception and responding accordingly.
-
Constructor Summary
ConstructorDescriptionAuthenticationEntryPointImpl
(org.springframework.web.servlet.HandlerExceptionResolver resolver) Constructor forAuthenticationEntryPointImpl
that injects theHandlerExceptionResolver
to handle the resolution of exceptions related to authentication. -
Method Summary
Modifier and TypeMethodDescriptionvoid
commence
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) Handles the commencement of an authentication error response.
-
Constructor Details
-
AuthenticationEntryPointImpl
public AuthenticationEntryPointImpl(@Qualifier("handlerExceptionResolver") org.springframework.web.servlet.HandlerExceptionResolver resolver) Constructor forAuthenticationEntryPointImpl
that injects theHandlerExceptionResolver
to handle the resolution of exceptions related to authentication.- Parameters:
resolver
- TheHandlerExceptionResolver
used for handling exceptions.
-
-
Method Details
-
commence
public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException authException) Handles the commencement of an authentication error response. This method is called whenever an unauthenticated user requests a secured HTTP resource, and anAuthenticationException
is thrown. The method delegates the exception resolution to the injectedHandlerExceptionResolver
.- Specified by:
commence
in interfaceorg.springframework.security.web.AuthenticationEntryPoint
- Parameters:
request
- The HTTP request that resulted in an authentication exception.response
- The HTTP response to be sent.authException
- The exception that was thrown when authentication failed.
-