I'm doing something similar in my AuthenticationDao implementation. Since all the roles are stored in the DB without the "ROLE_" prefix (and usually in lower case), I simply convert them in my Dao before returning to Acegi: --- public User loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException { ... final GrantedAuthority[] authorities = new GrantedAuthority[roles.size()]; final Iterator iRoles = roles.iterator();
for(int i = 0;iRoles.hasNext();i++) { final Role role = (Role)iRoles.next(); authorities[i] = new GrantedAuthorityImpl("ROLE_" + role.getName().toUpperCase()); } ... return new User(username, password, true, authorities); } --- - Andy On Tuesday 13 July 2004 03:45 am, Karel Miarka wrote: > Hi, > > When you want to use the net.sf.acegisecurity.vote.RoleVoter you must use > this prefix (unless you create a subclass of RoleVoter working with some > differet prefix, but it doesn't make sence to do this). You can have any > other config attribute names for your custom voters. > > I imagine that you ask this question, because you have some role names in > your database, but without the "ROLE_" prefix. That's not a problem, you > can use code similar to this: > > public GrantedAuthority[] getAuthorities() { > if (authorities==null) { > authorities = new GrantedAuthority[roles.size()]; > Iterator iterator = roles.iterator(); > for (int i = 0; iterator.hasNext(); i++) { > authorities[i] = new GrantedAuthorityImpl("ROLE_" + > ((String)iterator.next()).toUpperCase()); > } > } > return authorities; > } > > Regards, > Karel > ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Acegisecurity-developer mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer