public void permitted(User user, Integer experimentId) throws SecurityException {
    Experiment experiment = (Experiment) dao.get(Experiment.class.getName(), "id", experimentId);

    if (experiment.getOwner().equals(user) || experiment.userAllowed(user)) {
      user.setCurrentExperiment(experiment);
      User loadedUser = (User) dao.get(User.class.getName(), "username", user.getUsername());
      loadedUser.setCurrentExperiment(experiment);
      dao.update(loadedUser);
    } else {
      throw new SecurityException(
          "You do not have permission to view the experiment: " + experiment.getName());
    }
  }
 public Experiment getExperiment(Integer id) {
   return (Experiment) dao.get(Experiment.class.getName(), "id", id);
 }