/** Retrieve a person's security question account. */
  public static void getSecurityQuestionAccount() {

    // Create a new instance of the security question account client.
    SecurityQuestionAccountClient client = createAccountClient();

    // The id of the person.
    String personId = "e4d7e969af82";

    // Retrieve the account.
    SecurityQuestionAccount account = client.get(personId).checkedGet();

    System.out.println("Retrieved security question account: " + account);
  }
  /**
   * Sets up a person's security question account. First, searches for available security questions
   * that the person can choose from.
   */
  public static void setSecurityQuestionAccount() {

    // Create the security question and account clients.
    SecurityQuestionClient questionClient = createSecurityQuestionClient();
    SecurityQuestionAccountClient accountClient = createAccountClient();

    // First, let's perform a search on available questions. We will request to those questions
    // defined for the
    // given organization.
    String ownerId = "612aae4bc62a";
    String ownerType = "organization";

    // Retrieve default page of results.
    Page page = Page.DEFAULT;

    // Perform the search on available questions.
    List<SecurityQuestion> availableQuestions =
        questionClient.search(ownerId, ownerType, page).checkedGet();

    // Let's just assume the person wants to answer the first two questions in the search results.
    String firstQuestionId = availableQuestions.get(0).getId();
    String secondQuestionId = availableQuestions.get(1).getId();

    // The id of the person whose account is being set up.
    String personId = "3792c2000ad5";

    // Build the account object.
    Question firstAnswer = Question.withAnswer(firstQuestionId, "Answer to first question.");
    Question secondAnswer = Question.withAnswer(secondQuestionId, "Answer to second question.");

    SecurityQuestionAccount account = new SecurityQuestionAccount().setId(personId);
    account.setQuestions(Arrays.asList(firstAnswer, secondAnswer));
    account.setVersion(1L);

    // Create or update the account.
    SecurityQuestionAccount updated = accountClient.update(personId, account).checkedGet();

    System.out.println("Updated or specified security question account: " + updated);
  }