/**
* Return currently logged in user.
*/
public static User getLoggedInUser() {
try {
HappyfacesUserDetails authenticatedUser = (HappyfacesUserDetails) ((SecurityContext) SecurityContextHolder.getContext()).getAuthentication()
.getPrincipal();
return authenticatedUser.getUser();
} catch (Throwable e) {
log.error("Error getting logged in user", e);
return null;
}
}