Me da el siguiente error: este es mi codigo del filter @Autowired private TokenService tokenService;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
System.out.println("El filtro esta siendo llamado");
//Obtener el token de los header
var token = request.getHeader("Authorization");
System.out.println(token);
if (token == null || token == ""){
throw new RuntimeException("El token enviado no es valido");
}
token = token.replace("Bearer"," ");
System.out.println(token);
System.out.println(tokenService.getSubject(token));
filterChain.doFilter(request,response);
}
**Token service**
public String getSubject(String token){
DecodedJWT verifier = null;
try {
Algorithm algorithm = Algorithm.HMAC256("123456"); // validando firma
verifier = JWT.require(algorithm)
.withIssuer("voll med")
.build()
.verify(token);
} catch (JWTVerificationException exception) {
System.out.println(exception.toString());
}
if (verifier.getSubject() == null) {
throw new RuntimeException("Verifier invalido");
}
return verifier.getSubject();
}