private Long getCurrentUserId() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) { log.info("No Authentication available, cannot tell current user ID"); return null; } String currentUserName = auth.getName(); SimpleUserFilter filter = new SimpleUserFilter(); filter.setUniqueId(currentUserName); FilterResults<Match> results = userDao.findFiltered(filter, null, null, null); if (results.getReturnedResultCount() < 1) { return null; } return results.getResults().iterator().next().getId(); }