package com.airlock.iam.common.domain.model.user;

import com.airlock.iam.base.api.domain.model.exception.FailureException;
import com.airlock.iam.common.api.domain.model.user.UserIdentity;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;

public final class TentativePrincipalInfo {
   private Optional<UserIdentity> tentativeIdentity = Optional.empty();

   public void setTentativeIdentity(UserIdentity tentativeIdentity) {
      if (this.tentativeIdentity.isPresent()) {
         throw new FailureException("Unexpected authentication process while session already authenticating.");
      }

      this.tentativeIdentity = Optional.of(tentativeIdentity);
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<UserIdentity> getTentativeIdentity() {
      return this.tentativeIdentity;
   }
}
