private User loadAuthenticatedUser() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { String name = authentication.getName(); User user = userManager.loadByUserName(name); return user; } else { return null; } }