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

    Constructors
    Constructor
    Description
    AuthenticationEntryPointImpl(org.springframework.web.servlet.HandlerExceptionResolver resolver)
    Constructor for AuthenticationEntryPointImpl that injects the HandlerExceptionResolver to handle the resolution of exceptions related to authentication.
  • 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 the commencement of an authentication error response.

    Methods inherited from class java.lang.Object

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

    • AuthenticationEntryPointImpl

      public AuthenticationEntryPointImpl(@Qualifier("handlerExceptionResolver") org.springframework.web.servlet.HandlerExceptionResolver resolver)
      Constructor for AuthenticationEntryPointImpl that injects the HandlerExceptionResolver to handle the resolution of exceptions related to authentication.
      Parameters:
      resolver - The HandlerExceptionResolver 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 an AuthenticationException is thrown. The method delegates the exception resolution to the injected HandlerExceptionResolver.
      Specified by:
      commence in interface org.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.