Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.example.security; import java.io.IOException; import java.util.logging.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; /** * Authentication entry point for REST services */ public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { Logger.getLogger("org.example.security.RestAuthenticationEntryPoint") .info("Inside RestAuthenticationEntryPoint..."); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } }