I have a web application with Spring 2.5.6, Icefaces 1.8.2 and SpringSecurity 2.0.5.
I've implemented my custom UserDetailsServiceImpl who searchs the user and roles in DB. Everything works nice. I return a UserDetails with more than one role for that User.
Later in the application I call SecurityContextHolder.getAuthentication().getAutho rities() for obtaining the GrantedAuthority[] authorities but this array only contains one element.
How could it be possible? Any help is very appreciated. I attach my UserDetailsServiceImpl and applicationContext-security.xml
UserDetailsServiceImpl.java
Code:public class UserDetailServiceImpl implements UserDetailsService { private UsuarioService usuarioService; private static final Logger log = LoggerFactory.getLogger(UserDetailServiceImpl.class); public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { CviUsuarios usr = usuarioService.findUsuarioByUsername(username); if (usr == null) { throw new UsernameNotFoundException("No existe usuario"); } List<CviPermisos> perList = usuarioService.cargaListaPermisos(usr.getUsuId()); GrantedAuthority[] authorities = new GrantedAuthorityImpl[perList.size()]; int i = 0; for (CviPermisos per : perList) { authorities[i] = new GrantedAuthorityImpl(per.getPerDescabrv()); i++; } boolean accountEnabled = true; boolean accountNonLocked = usuarioService.getLoginAttempts(usr.getUsuId()) < Integer.valueOf(StaticDataUtils.variableSistemaMap.get("reintentos_login")); boolean accountNonExpired = true; boolean credentialsNonExpired = usr.getUsuFechaCaducidad() != null ? usr.getUsuFechaCaducidad().compareTo(new Date()) > 0 : true; UserDetails usrDtl = new User(usr.getUsuLogin(), usr.getUsuPassword(), accountEnabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); if (!accountNonLocked) { throw new LockedException("User account is locked", usrDtl); } if (!accountNonExpired) { throw new AccountExpiredException("User account has expired", usrDtl); } if (!credentialsNonExpired) { throw new CredentialsExpiredException("User account has expired", usrDtl); } if (!accountEnabled) { throw new DisabledException("User account is disabled", usrDtl); } //UserBean userBean = (UserBean)FacesUtils.getManagedBean("userBean"); //userBean.initialize(); return usrDtl; } public void setUsuarioService(UsuarioService usuarioService) { this.usuarioService = usuarioService; }


