1@Component("restAuthenticationEntryPoint")
2public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint{
3
4 public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) throws IOException, ServletException {
5
6 response.setContentType("application/json");
7 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
8 response.getOutputStream().println("{ \"error\": \"" + authenticationException.getMessage() + "\" }");
9
10 }
11}