}
private void updateAuthorities(User user, Collection<? extends Role> roles) {
if (!CollectionUtils.isEmpty(roles)) {
for (Role role : roles) {
Role authority = dao.findAuthority(role.getRole());
if (authority != null) {
if ((user.getRoles() == null) || (!user.getRoles().contains(authority))) {
user.addRole(authority);
authority.addMember(user);
}
}
}
}
if (!CollectionUtils.isEmpty(user.getRoles())) {
for (Iterator<? extends Role> it = user.getRoles().iterator(); it.hasNext();) {
Role role = it.next();
if (!roles.contains(role)) {
it.remove();
role.removeMember(user);
}
}
}
dao.updateUser(user);
if (!CollectionUtils.isEmpty(user.getRoles()))