|
|
@@ -3,6 +3,7 @@ package com.example.config;
|
|
|
import io.jsonwebtoken.Claims;
|
|
|
import io.jsonwebtoken.Jwts;
|
|
|
import io.jsonwebtoken.SignatureException;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.filter.GenericFilterBean;
|
|
|
|
|
|
import javax.servlet.FilterChain;
|
|
|
@@ -16,6 +17,7 @@ import java.io.IOException;
|
|
|
/**
|
|
|
* Created by LXY on 2017/7/2.
|
|
|
*/
|
|
|
+//这个类先不要用了,感觉有点问题
|
|
|
public class JwtFilter extends GenericFilterBean{
|
|
|
|
|
|
@Override
|
|
|
@@ -27,7 +29,6 @@ public class JwtFilter extends GenericFilterBean{
|
|
|
if ("OPTIONS".equals(request.getMethod())) {
|
|
|
response.setStatus(HttpServletResponse.SC_OK);
|
|
|
|
|
|
- chain.doFilter(req, res);
|
|
|
} else {
|
|
|
if(authHeader==null||!authHeader.startsWith("Bearer ")){
|
|
|
throw new ServletException("Missing or invalid Authorization header");
|
|
|
@@ -40,7 +41,7 @@ public class JwtFilter extends GenericFilterBean{
|
|
|
}catch (final SignatureException e){
|
|
|
throw new ServletException("Invalid token");
|
|
|
}
|
|
|
- chain.doFilter(req,res);
|
|
|
}
|
|
|
+ chain.doFilter(req, res);
|
|
|
}
|
|
|
}
|