Answers for "send msg to AuthenticationEntryPoint"

0

spring security controlleradvice

@Component("restAuthenticationEntryPoint")
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint{

    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) throws IOException, ServletException {

        response.setContentType("application/json");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        response.getOutputStream().println("{ \"error\": \"" + authenticationException.getMessage() + "\" }");

    }
}
Posted by: Guest on May-30-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language