/** Handle challenges from keyboard-interactive authentication mode. */
 public String[] replyToChallenge(
     String name, String instruction, int numPrompts, String[] prompt, boolean[] echo) {
   String[] responses = new String[numPrompts];
   for (int i = 0; i < numPrompts; i++) {
     // request response from user for each prompt
     responses[i] = promptHelper.requestPasswordPrompt(instruction, prompt[i]);
   }
   return responses;
 }
  /** Force disconnection of this terminal bridge. */
  public void dispatchDisconnect(boolean immediate) {
    // We don't need to do this multiple times.
    synchronized (this) {
      if (disconnected && !immediate) return;

      disconnected = true;
    }

    // Cancel any pending prompts.
    promptHelper.cancelPrompt();

    // disconnection request hangs if we havent really connected to a host yet
    // temporary fix is to just spawn disconnection into a thread
    Thread disconnectThread =
        new Thread(
            new Runnable() {
              public void run() {
                if (transport != null && transport.isConnected()) transport.close();
              }
            });
    disconnectThread.setName("Disconnect");
    disconnectThread.start();

    if (immediate) {
      awaitingClose = true;
      if (disconnectListener != null) disconnectListener.onDisconnected(TerminalBridge.this);
    } else {
      {
        final String line = manager.res.getString(R.string.alert_disconnect_msg);
        ((vt320) buffer).putString("\r\n" + line + "\r\n");
      }
      if (host.getStayConnected()) {
        manager.requestReconnect(this);
        return;
      }
      Thread disconnectPromptThread =
          new Thread(
              new Runnable() {
                public void run() {
                  Boolean result =
                      promptHelper.requestBooleanPrompt(
                          null, manager.res.getString(R.string.prompt_host_disconnected));
                  if (result == null || result.booleanValue()) {
                    awaitingClose = true;

                    // Tell the TerminalManager that we can be destroyed now.
                    if (disconnectListener != null)
                      disconnectListener.onDisconnected(TerminalBridge.this);
                  }
                }
              });
      disconnectPromptThread.setName("DisconnectPrompt");
      disconnectPromptThread.setDaemon(true);
      disconnectPromptThread.start();
    }
  }