How to change GrantedAuthority dynamically in Spring Security framework

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

 SecurityContext 's setAuthentication. (UsernamePasswordAuthenticationToken(Object principal, Object credentials, GrantedAuthority[] authorities) ) ;


reference url:http://forum.springsource.org/showthread.php?52229-How-to-change-GrantedAuthority-dynamically

你可能感兴趣的:(spring,Security,职场,Authentication,休闲)