Exemplo n.º 1
0
  private void promptForJmxCredentialsIfNeeded() throws IOException {
    // If the username was not configured via cli, then prompt the user for the values
    if (username == null) {
      log.debug("Prompting user for jmx login");
      username = ShellUtils.readLine(session, "Jmx Login for " + parent + ": ", false);
    }

    if (password == null) {
      password = ShellUtils.readLine(session, "Jmx Password for " + parent + ": ", true);
    }
  }
Exemplo n.º 2
0
  private String[] promptForNewUser(String user, String password) throws IOException {
    String[] response = new String[2];
    // If the username was not configured via cli, then prompt the user for the values
    if (user == null || password == null) {
      System.out.println(
          "No user found in etc/users.properties or specified as an option. Please specify one ...");
    }
    while (user == null || user.isEmpty()) {
      user = ShellUtils.readLine(session, "New user name: ", false);
      if (user == null) {
        break;
      }
    }

    if (user != null && password == null) {
      String password1 = null;
      String password2 = null;
      while (password1 == null || !password1.equals(password2)) {
        password1 = ShellUtils.readLine(session, "Password for " + user + ": ", true);
        password2 = ShellUtils.readLine(session, "Verify password for " + user + ": ", true);

        if (password1 == null || password2 == null) {
          break;
        }

        if (password1 != null && password1.equals(password2)) {
          password = password1;
        } else {
          System.out.println("Passwords did not match. Please try again!");
        }
      }
    }
    response[0] = user;
    response[1] = password;
    return response;
  }