JwtAuthEntryPoint.java 708 B

123456789101112131415161718
  1. package com.example.projectback.security.jwt;
  2. import org.springframework.security.core.AuthenticationException;
  3. import org.springframework.security.web.AuthenticationEntryPoint;
  4. import org.springframework.stereotype.Component;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import java.io.IOException;
  8. @Component
  9. public class JwtAuthEntryPoint implements AuthenticationEntryPoint {
  10. @Override
  11. public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException {
  12. httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Error -> Unauthorized");
  13. }
  14. }