use of com.gmoon.springsecurityjwt.jwt.exception.JwtVerifyException in project toy by gmoon92.
the class JwtVerifyFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
String token = request.getHeader(JwtAuthenticationFilter.HEADER_NAME);
try {
User user = jwtUtil.decode(token);
Authentication authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
} catch (JWTVerificationException e) {
SecurityContextHolder.clearContext();
getAuthenticationEntryPoint().commence(request, response, new JwtVerifyException(e));
}
}
use of com.gmoon.springsecurityjwt.jwt.exception.JwtVerifyException in project Toy by gmoon92.
the class JwtVerifyFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
String token = request.getHeader(JwtAuthenticationFilter.HEADER_NAME);
try {
User user = jwtUtil.decode(token);
Authentication authentication = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
} catch (JWTVerificationException e) {
SecurityContextHolder.clearContext();
getAuthenticationEntryPoint().commence(request, response, new JwtVerifyException(e));
}
}
Aggregations