Closed tnodev closed 10 years ago
You;re right.. i've written a simple test and it seems not to work. I may create a patch for this.
So i've created a fix:
Replaced the method
private Collection<GrantedAuthority> retainAll(final Collection<GrantedAuthority> granted, final Collection<GrantedAuthority> required)
with:
private Collection<GrantedAuthority> retainAll(final Collection<GrantedAuthority> granted, final Collection<GrantedAuthority> required) {
Collection<GrantedAuthority> grantedRoles = new ArrayList<GrantedAuthority>();
for (GrantedAuthority auth: granted) {
for (GrantedAuthority req: required) {
if (req.getAuthority().equals(auth.getAuthority())) {
grantedRoles.add(auth);
break;
}
}
}
return rolesToAuthorities(grantedRoles, granted);
}
This way the implementation only uses the interface GrantedAuthority and not it's actual implementation as the retainAll function in the Collections does.
Let me know what you think, i've tested it with 'SimpleGrantedAuthority' and it seems to work.
I test...
OK it works !
Great
Hello
The component IfRole doesn't work when using other implementation of GrantedAuthority than GrantedAuthorityImpl. Exemple : SimpleGrantedAuthority, or your own !
May be you should use a String collection and put the getAuthority from any implementation of GrantedAuthority
Thomas