public List<String> getRolesForUser(final String username)
     throws UsernameNotFoundException, DataAccessException {
   UserDetails user = userDetailsService.loadUserByUsername(username);
   List<String> roles = new ArrayList<String>(user.getAuthorities().length);
   for (GrantedAuthority role : user.getAuthorities()) {
     roles.add(role.getAuthority());
   }
   return roles;
 }
Exemple #2
0
 private void getUserAuthorityInfo() {
   GrantedAuthority[] authorities = userDetails.getAuthorities();
   userAuthority = authorities;
 }