Exemple #1
0
  /**
   * Initialize an LdapConfig with command line options.
   *
   * @param line Parsed command line arguments container.
   * @return <code>LdapConfig</code> that has been initialized
   * @throws Exception On errors thrown by handler.
   */
  protected LdapConfig initLdapConfig(final CommandLine line) throws Exception {
    final LdapConfig config = new LdapConfig();
    this.initLdapProperties(config, line);
    if (line.hasOption(OPT_TRACE)) {
      config.setTracePackets(System.out);
    }
    if (config.getBindDn() != null && config.getBindCredential() == null) {
      // prompt the user to enter a password
      System.out.print("Enter password for service user " + config.getBindDn() + ": ");

      final String pass = (new BufferedReader(new InputStreamReader(System.in))).readLine();
      config.setBindCredential(pass);
    }
    return config;
  }