springsecurity将authenticationToken填充到安全上下文的问题

authenticationToken.setDetails这是什么作用,看了一下博客,有的写这段,有的又不写


//将用户信息和权限填充 到用户身份token对象中
UsernamePasswordAuthenticationToken authenticationToken
= new UsernamePasswordAuthenticationToken(jwtTokenInfo.getUser_name(),null, AuthorityUtils.createAuthorityList(authorities));
authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
//将authenticationToken填充到安全上下文
SecurityContextHolder.getContext().setAuthentication(authenticationToken);

作用:这个主要是将用户token和用户信息绑定,然后验证token通过之后,可以通过token获取用户信息,