package com.diagbot.config;

import com.diagbot.exception.CommonErrorCode;
import com.diagbot.exception.CommonException;
import com.diagbot.exception.ServiceErrorCode;
import com.diagbot.util.StringUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author songxl
 * @time: 2024/11/30
 */
@Component
public class AuthExceptionEntryPoint implements AuthenticationEntryPoint {
    @Autowired
    AuthenticationExceptionHandler authenticationExceptionHandler;

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response,
                         AuthenticationException authException)
            throws ServletException {
        try {
            authenticationExceptionHandler.handleException(request,response,authException);
        } catch (Exception e) {
            throw new ServletException();
        }
    }
}