package es.unizar.smartcampuz.infrastructure.auth.jwt;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Component
public class JwtAuthFilter implements Filter{

    private static final Logger LOG = LoggerFactory
        .getLogger(JwtAuthFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException{

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest servletRequest = (HttpServletRequest) request;
        String authorization = servletRequest.getHeader("Authorization");
        if(authorization != null && authorization.contains("Bearer")){
            JwtAuthToken token = new JwtAuthToken(authorization.replaceAll("Bearer", ""));
            SecurityContextHolder.getContext().setAuthentication(token);
        }
        chain.doFilter(request, response);
    }

    @Override
    public void destroy(){

    }
}

@@ -937,16 +937,44 @@
 Bearer%22)
+ && authorization.length()%3E7
 )%7B%0A     

Fix JWT issue