Exception Handling In Spring Security

    Question 1SPRING SECURITY - Authentication vs Authorization Exceptions

    Which statement correctly differentiates between AuthenticationException and AccessDeniedException in Spring Security?

    Question 2SPRING SECURITY - Custom AuthenticationEntryPoint

    What is the purpose of implementing AuthenticationEntryPoint in Spring Security?

    Question 3SPRING SECURITY - Code Snippet (EntryPoint)

    What HTTP status does this custom entry point return for unauthenticated requests?

    @Component public class CustomEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied"); } }

    Question 4SPRING SECURITY - AccessDeniedHandler

    In Spring Security, what is the role of AccessDeniedHandler?

    Question 5SPRING SECURITY - Code Snippet (AccessDeniedHandler)

    What does this configuration achieve?

    http .exceptionHandling() .accessDeniedHandler((req, res, ex) -> res.sendError(HttpServletResponse.SC_FORBIDDEN, "Not Authorized"));

    Question 6SPRING SECURITY - Exception Translation Filter

    What is the purpose of ExceptionTranslationFilter in Spring Security’s filter chain?

    Question 7SPRING SECURITY - Code Snippet (Custom Config)

    What does the following snippet configure?

    http .exceptionHandling() .authenticationEntryPoint(new CustomEntryPoint()) .accessDeniedHandler(new CustomAccessDeniedHandler());

    Question 8SPRING SECURITY - Handling CSRF Exceptions

    Which exception is typically thrown when a CSRF token is missing or invalid in Spring Security?

    Question 9SPRING SECURITY - AuthenticationFailureHandler

    When customizing login failures, which handler is used to control the response after an AuthenticationException occurs during form login?

    Question 10SPRING SECURITY - Default Exception Handling

    By default, how does Spring Security handle AccessDeniedException in a web application with form login enabled?