1Set<GrantedAuthority> authorities = new HashSet<>();
2authorities.add(new SimpleGrantedAuthority("USER"));
3authorities.add(new SimpleGrantedAuthority("ADMIN"));
4
5Authentication reAuth = new UsernamePasswordAuthenticationToken("user",new
6
7BCryptPasswordEncoder().encode("password"),authorities);
8
9SecurityContextHolder.getContext().setAuthentication(reAuth);
10