List of usage examples for org.springframework.security.web AuthenticationEntryPoint AuthenticationEntryPoint
AuthenticationEntryPoint
From source file:io.getlime.security.powerauth.app.server.WebSecurityConfig.java
@Bean public AuthenticationEntryPoint authenticationEntryPoint() { return new AuthenticationEntryPoint() { @Override//from w w w . j a v a2 s .co m public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { RESTResponseWrapper<String> errorResponse = new RESTResponseWrapper<>("ERROR", "Authentication failed"); httpServletResponse.setContentType("application/json"); httpServletResponse.setCharacterEncoding("UTF-8"); httpServletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); httpServletResponse.getOutputStream().println(new ObjectMapper().writeValueAsString(errorResponse)); httpServletResponse.getOutputStream().flush(); } }; }
From source file:eu.freme.broker.security.SecurityConfig.java
@Bean public AuthenticationEntryPoint unauthorizedEntryPoint() { return new AuthenticationEntryPoint() { @Override// w ww. j a va 2s . c o m public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } }; }