// for getting the current logged in user from spring SecurityContextHolder
 public void setCurrentUser() throws Exception {
   authentication = SecurityContextHolder.getContext().getAuthentication();
   if (authentication != null)
     userSession.setUser(userService.getUserByEmail(authentication.getName().toString()));
   else System.out.println("Authentication is null");
 }