Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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() + "" }");

    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #spring #security #controlleradvice
ADD COMMENT
Topic
Name
1+7 =