/** * Called by Spring Security to evaluate the permission * * @param auth Spring Security authentication object, * from which the current-user can be found * @param targetDomainObject Object for which permission is being checked * @param permission What permission is being checked for, e.g. 'edit' */ @Override public boolean hasPermission(Authentication auth, Object targetDomainObject, Object permission) { log.debug("Checking whether " + auth + "\n has " + permission + " permission for " + targetDomainObject); if (targetDomainObject == null) // if no domain object is provided, return true; // let's pass, allowing the service method // to throw a more sensible error message // Let's delegate to the entity's hasPermission method PermissionEvaluatorEntity entity = (PermissionEvaluatorEntity) targetDomainObject; return entity.hasPermission(LecUtils.currentUser(auth), (String) permission); }