package br.com.ifpb.depsback.config.security;
import org.hibernate.annotations.Filter;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class AutenticacaoViaTokenFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
String token = recuperarToken(request);
System.out.println(token);
filterChain.doFilter(request, response);
}
private String recuperarToken(HttpServletRequest request) {
String token = request.getHeader("Authorization");
if (token == null || token.isEmpty()){
return null;
}
return token.substring(7, token.length());
}
}
Ele devolve no Postman porém não esta printando no console, no console é devolvido "null".