solution is
you could get
SecurityContext instance via SecurityContextHolder
then via
SecurityContext's setAuthentication(Authentication authentication)
UsernamePasswordAuthenticationToken is subclass of Authentication
so,you have to create a new one which contains new aurhorites(roles) via constructor as below shown
reference url:http://forum.springsource.org/showthread.php?52229-How-to-change-GrantedAuthority-dynamically
you could get
SecurityContext instance via SecurityContextHolder
then via
SecurityContext's setAuthentication(Authentication authentication)
UsernamePasswordAuthenticationToken is subclass of Authentication
so,you have to create a new one which contains new aurhorites(roles) via constructor as below shown
SecurityContext 's setAuthentication. (UsernamePasswordAuthenticationToken(Object principal, Object credentials, GrantedAuthority[] authorities) ) ;
reference url:http://forum.springsource.org/showthread.php?52229-How-to-change-GrantedAuthority-dynamically
转载于:https://blog.51cto.com/wanqiufeng/629549