String url) throws AccessControlException {
Role[] roles = accreditableManager.getRoleManager().getRoles();
Set grantedRoles = new HashSet();
Policy policy = getPolicy(accreditableManager, url);
for (int i = 0; i < roles.length; i++) {
if (policy.check(identity, roles[i]) == Policy.RESULT_GRANTED) {
grantedRoles.add(roles[i]);
}
}
return (Role[]) grantedRoles.toArray(new Role[grantedRoles.size()]);
}