public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
Collection<GrantedAuthority> authorities = (Collection<GrantedAuthority>) authentication.getAuthorities();
for (GrantedAuthority authority : authorities) {
if(authority instanceof Role){
Role role = (Role) authority;
List<Privilege> privileges = role.getPrivileges();
for (Privilege privilege : privileges) {
if (permission.equals(privilege.getName())) {
return true;
}
}