code: public static User getAuthenticatedUser(Authentication auth) {
  		User user = null;
  		if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof AuthenticatedUserDetails) {
  			user = ((AuthenticatedUserDetails) auth.getPrincipal()).getUser();
  		}
  		return user;
  	}
docs: Extracts a User object from the security context.
  @param auth the authentication object
  @return an authenticated user or null if a user is not authenticated