Package org.nasutekds.server.util.args

Examples of org.nasutekds.server.util.args.BooleanArgument


   *           If a global argument could not be registered.
   */
  private void initializeGlobalArguments(String[] args)
  throws ArgumentException {
    if (globalArgumentsInitialized == false) {
      verboseArgument = new BooleanArgument("verbose", 'v', "verbose",
          INFO_DESCRIPTION_VERBOSE.get());

      quietArgument = new BooleanArgument(
          OPTION_LONG_QUIET,
          OPTION_SHORT_QUIET,
          OPTION_LONG_QUIET,
          INFO_DESCRIPTION_QUIET.get());
      quietArgument.setPropertyName(OPTION_LONG_QUIET);

      scriptFriendlyArgument = new BooleanArgument("script-friendly",
          OPTION_SHORT_SCRIPT_FRIENDLY, OPTION_LONG_SCRIPT_FRIENDLY,
          INFO_DESCRIPTION_SCRIPT_FRIENDLY.get());
      scriptFriendlyArgument.setPropertyName(OPTION_LONG_SCRIPT_FRIENDLY);

      noPromptArgument = new BooleanArgument(
          OPTION_LONG_NO_PROMPT,
          OPTION_SHORT_NO_PROMPT,
          OPTION_LONG_NO_PROMPT,
          INFO_DESCRIPTION_NO_PROMPT.get());

      advancedModeArgument = new BooleanArgument(OPTION_DSCFG_LONG_ADVANCED,
          OPTION_DSCFG_SHORT_ADVANCED, OPTION_DSCFG_LONG_ADVANCED,
          INFO_DSCFG_DESCRIPTION_ADVANCED.get());
      advancedModeArgument.setPropertyName(OPTION_DSCFG_LONG_ADVANCED);

      showUsageArgument = new BooleanArgument("showUsage", OPTION_SHORT_HELP,
          OPTION_LONG_HELP, INFO_DSCFG_DESCRIPTION_SHOW_GROUP_USAGE_SUMMARY
          .get());

      batchFileArgument = new StringArgument(OPTION_LONG_BATCH_FILE_PATH,
          OPTION_SHORT_BATCH_FILE_PATH, OPTION_LONG_BATCH_FILE_PATH,
          false, false, true, INFO_BATCH_FILE_PATH_PLACEHOLDER.get(),
          null, null,
          INFO_DESCRIPTION_BATCH_FILE_PATH.get());

      displayEquivalentArgument = new BooleanArgument(
          OPTION_DSCFG_LONG_DISPLAY_EQUIVALENT,
          null, OPTION_DSCFG_LONG_DISPLAY_EQUIVALENT,
          INFO_DSCFG_DESCRIPTION_DISPLAY_EQUIVALENT.get());
      advancedModeArgument.setPropertyName(
          OPTION_DSCFG_LONG_DISPLAY_EQUIVALENT);

      equivalentCommandFileArgument = new StringArgument(
          OPTION_LONG_EQUIVALENT_COMMAND_FILE_PATH, null,
          OPTION_LONG_EQUIVALENT_COMMAND_FILE_PATH, false, false, true,
          INFO_PATH_PLACEHOLDER.get(), null, null,
          INFO_DSCFG_DESCRIPTION_EQUIVALENT_COMMAND_FILE_PATH.get());

      propertiesFileArgument = new StringArgument("propertiesFilePath",
          null, OPTION_LONG_PROP_FILE_PATH,
          false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
          INFO_DESCRIPTION_PROP_FILE_PATH.get());

      noPropertiesFileArgument = new BooleanArgument(
          "noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
          INFO_DESCRIPTION_NO_PROP_FILE.get());

      // Register the global arguments.

View Full Code Here


        Tag tag = group.getKey();
        SortedSet<SubCommand> subCommands = group.getValue();

        String option = OPTION_LONG_HELP + "-" + tag.getName();
        String synopsis = tag.getSynopsis().toString().toLowerCase();
        BooleanArgument arg = new BooleanArgument(option, null, option,
            INFO_DSCFG_DESCRIPTION_SHOW_GROUP_USAGE.get(synopsis));

        parser.addGlobalArgument(arg);
        parser.setUsageGroupArgument(arg, subCommands);
      }

      // Register the --help-all argument.
      String option = OPTION_LONG_HELP + "-all";
      BooleanArgument arg = new BooleanArgument(option, null, option,
          INFO_DSCFG_DESCRIPTION_SHOW_GROUP_USAGE_ALL.get());

      parser.addGlobalArgument(arg);
      parser.setUsageGroupArgument(arg, allSubCommands);
    }
View Full Code Here

                   INFO_BACKENDNAME_PLACEHOLDER.get(), null, null,
                   INFO_BACKUPDB_DESCRIPTION_BACKEND_ID.get());
      argParser.addArgument(backendID);


      backUpAll = new BooleanArgument(
                  "backupall", 'a', "backUpAll",
                  INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL.get());
      argParser.addArgument(backUpAll);


      backupIDString =
           new StringArgument(
                   "backupid", 'I', "backupID", false, false, true,
                   INFO_BACKUPID_PLACEHOLDER.get(), null, null,
                   INFO_BACKUPDB_DESCRIPTION_BACKUP_ID.get());
      argParser.addArgument(backupIDString);


      backupDirectory =
           new StringArgument(
                   "backupdirectory", 'd', "backupDirectory", true,
                   false, true, INFO_BACKUPDIR_PLACEHOLDER.get(), null, null,
                   INFO_BACKUPDB_DESCRIPTION_BACKUP_DIR.get());
      argParser.addArgument(backupDirectory);


      incremental = new BooleanArgument(
                  "incremental", 'i', "incremental",
                  INFO_BACKUPDB_DESCRIPTION_INCREMENTAL.get());
      argParser.addArgument(incremental);


      incrementalBaseID =
           new StringArgument(
                   "incrementalbaseid", 'B', "incrementalBaseID",
                   false, false, true, INFO_BACKUPID_PLACEHOLDER.get(), null,
                   null,
                   INFO_BACKUPDB_DESCRIPTION_INCREMENTAL_BASE_ID.get());
      argParser.addArgument(incrementalBaseID);


      compress = new BooleanArgument(
                  "compress", OPTION_SHORT_COMPRESS,
                  OPTION_LONG_COMPRESS,
                  INFO_BACKUPDB_DESCRIPTION_COMPRESS.get());
      argParser.addArgument(compress);


      encrypt = new BooleanArgument(
                  "encrypt", 'y', "encrypt",
                  INFO_BACKUPDB_DESCRIPTION_ENCRYPT.get());
      argParser.addArgument(encrypt);


      hash = new BooleanArgument(
                  "hash", 'A', "hash",
                  INFO_BACKUPDB_DESCRIPTION_HASH.get());
      argParser.addArgument(hash);


      signHash =
           new BooleanArgument(
                   "signhash", 's', "signHash",
                   INFO_BACKUPDB_DESCRIPTION_SIGN_HASH.get());
      argParser.addArgument(signHash);


      displayUsage =
           new BooleanArgument(
                   "help", OPTION_SHORT_HELP,
                   OPTION_LONG_HELP,
                   INFO_DESCRIPTION_USAGE.get());
      argParser.addArgument(displayUsage);
      argParser.setUsageArgument(displayUsage);
View Full Code Here

    LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
    LDAPModifyOptions modifyOptions = new LDAPModifyOptions();
    LDAPConnection connection = null;

    BooleanArgument   continueOnError        = null;
    BooleanArgument   defaultAdd             = null;
    BooleanArgument   noop                   = null;
    BooleanArgument   reportAuthzID          = null;
    BooleanArgument   saslExternal           = null;
    BooleanArgument   showUsage              = null;
    BooleanArgument   startTLS               = null;
    BooleanArgument   trustAll               = null;
    BooleanArgument   useSSL                 = null;
    BooleanArgument   verbose                = null;
    FileBasedArgument bindPasswordFile       = null;
    FileBasedArgument keyStorePasswordFile   = null;
    FileBasedArgument trustStorePasswordFile = null;
    IntegerArgument   connectTimeout         = null;
    IntegerArgument   port                   = null;
    IntegerArgument   version                = null;
    StringArgument    assertionFilter        = null;
    StringArgument    bindDN                 = null;
    StringArgument    bindPassword           = null;
    StringArgument    certNickname           = null;
    StringArgument    controlStr             = null;
    StringArgument    encodingStr            = null;
    StringArgument    filename               = null;
    StringArgument    hostName               = null;
    StringArgument    keyStorePath           = null;
    StringArgument    keyStorePassword       = null;
    StringArgument    postReadAttributes     = null;
    StringArgument    preReadAttributes      = null;
    StringArgument    proxyAuthzID           = null;
    StringArgument    saslOptions            = null;
    StringArgument    trustStorePath         = null;
    StringArgument    trustStorePassword     = null;
    StringArgument    propertiesFileArgument   = null;
    BooleanArgument   noPropertiesFileArgument = null;

    // Create the command-line argument parser for use with this program.
    Message toolDescription = INFO_LDAPMODIFY_TOOL_DESCRIPTION.get();
    ArgumentParser argParser = new ArgumentParser(CLASS_NAME, toolDescription,
                                                  false);
    try
    {
      propertiesFileArgument = new StringArgument("propertiesFilePath",
          null, OPTION_LONG_PROP_FILE_PATH,
          false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
          INFO_DESCRIPTION_PROP_FILE_PATH.get());
      argParser.addArgument(propertiesFileArgument);
      argParser.setFilePropertiesArgument(propertiesFileArgument);

      noPropertiesFileArgument = new BooleanArgument(
          "noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
          INFO_DESCRIPTION_NO_PROP_FILE.get());
      argParser.addArgument(noPropertiesFileArgument);
      argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);

      hostName = new StringArgument("host", OPTION_SHORT_HOST,
                                    OPTION_LONG_HOST, false, false, true,
                                    INFO_HOST_PLACEHOLDER.get(), "localhost",
                                    null,
                                    INFO_DESCRIPTION_HOST.get());
      hostName.setPropertyName(OPTION_LONG_HOST);
      argParser.addArgument(hostName);

      port = new IntegerArgument("port", OPTION_SHORT_PORT,
                                 OPTION_LONG_PORT, false, false, true,
                                 INFO_PORT_PLACEHOLDER.get(), 389, null,
                                 INFO_DESCRIPTION_PORT.get());
      port.setPropertyName(OPTION_LONG_PORT);
      argParser.addArgument(port);

      useSSL = new BooleanArgument("useSSL", OPTION_SHORT_USE_SSL,
                                   OPTION_LONG_USE_SSL,
                                   INFO_DESCRIPTION_USE_SSL.get());
      useSSL.setPropertyName(OPTION_LONG_USE_SSL);
      argParser.addArgument(useSSL);

      startTLS = new BooleanArgument("startTLS", OPTION_SHORT_START_TLS,
                                     OPTION_LONG_START_TLS,
                                     INFO_DESCRIPTION_START_TLS.get());
      startTLS.setPropertyName(OPTION_LONG_START_TLS);
      argParser.addArgument(startTLS);

      bindDN = new StringArgument("bindDN", OPTION_SHORT_BINDDN,
                                  OPTION_LONG_BINDDN, false, false, true,
                                  INFO_BINDDN_PLACEHOLDER.get(), null, null,
                                  INFO_DESCRIPTION_BINDDN.get());
      bindDN.setPropertyName(OPTION_LONG_BINDDN);
      argParser.addArgument(bindDN);

      bindPassword = new StringArgument("bindPassword", OPTION_SHORT_BINDPWD,
                                        OPTION_LONG_BINDPWD,
                                        false, false, true,
                                        INFO_BINDPWD_PLACEHOLDER.get(),
                                        null, null,
                                        INFO_DESCRIPTION_BINDPASSWORD.get());
      bindPassword.setPropertyName(OPTION_LONG_BINDPWD);
      argParser.addArgument(bindPassword);

      bindPasswordFile =
           new FileBasedArgument("bindPasswordFile",
                                 OPTION_SHORT_BINDPWD_FILE,
                                 OPTION_LONG_BINDPWD_FILE,
                                 false, false,
                                 INFO_BINDPWD_FILE_PLACEHOLDER.get(), null,
                                 null, INFO_DESCRIPTION_BINDPASSWORDFILE.get());
      bindPasswordFile.setPropertyName(OPTION_LONG_BINDPWD_FILE);
      argParser.addArgument(bindPasswordFile);

      defaultAdd = new BooleanArgument(
              "defaultAdd", 'a', "defaultAdd",
              INFO_MODIFY_DESCRIPTION_DEFAULT_ADD.get());
      argParser.addArgument(defaultAdd);

      filename = new StringArgument("filename", OPTION_SHORT_FILENAME,
                                    OPTION_LONG_FILENAME, false, false,
                                    true, INFO_FILE_PLACEHOLDER.get(), null,
                                    null,
                                    INFO_LDAPMODIFY_DESCRIPTION_FILENAME.get());
      filename.setPropertyName(OPTION_LONG_FILENAME);
      argParser.addArgument(filename);

      saslExternal = new BooleanArgument(
              "useSASLExternal", 'r',
              "useSASLExternal",
              INFO_DESCRIPTION_USE_SASL_EXTERNAL.get());
      saslExternal.setPropertyName("useSASLExternal");
      argParser.addArgument(saslExternal);

      saslOptions = new StringArgument("saslOption", OPTION_SHORT_SASLOPTION,
                                       OPTION_LONG_SASLOPTION, false,
                                       true, true,
                                       INFO_SASL_OPTION_PLACEHOLDER.get(), null,
                                       null,
                                       INFO_DESCRIPTION_SASL_PROPERTIES.get());
      saslOptions.setPropertyName(OPTION_LONG_SASLOPTION);
      argParser.addArgument(saslOptions);

      trustAll = new BooleanArgument("trustAll", 'X', "trustAll",
                                    INFO_DESCRIPTION_TRUSTALL.get());
      trustAll.setPropertyName("trustAll");
      argParser.addArgument(trustAll);

      keyStorePath = new StringArgument("keyStorePath",
                                        OPTION_SHORT_KEYSTOREPATH,
                                        OPTION_LONG_KEYSTOREPATH,
                                        false, false, true,
                                        INFO_KEYSTOREPATH_PLACEHOLDER.get(),
                                        null, null,
                                        INFO_DESCRIPTION_KEYSTOREPATH.get());
      keyStorePath.setPropertyName(OPTION_LONG_KEYSTOREPATH);
      argParser.addArgument(keyStorePath);

      keyStorePassword =
              new StringArgument("keyStorePassword",
                                 OPTION_SHORT_KEYSTORE_PWD,
                                 OPTION_LONG_KEYSTORE_PWD,
                                 false, false,
                                 true,
                                 INFO_KEYSTORE_PWD_PLACEHOLDER.get(),
                                 null, null,
                                 INFO_DESCRIPTION_KEYSTOREPASSWORD.get());
      keyStorePassword.setPropertyName(OPTION_LONG_KEYSTORE_PWD);
      argParser.addArgument(keyStorePassword);

      keyStorePasswordFile =
           new FileBasedArgument("keystorepasswordfile",
                                 OPTION_SHORT_KEYSTORE_PWD_FILE,
                                 OPTION_LONG_KEYSTORE_PWD_FILE,
                                 false, false,
                                 INFO_KEYSTORE_PWD_FILE_PLACEHOLDER.get(),
                                 null, null,
                                 INFO_DESCRIPTION_KEYSTOREPASSWORD_FILE.get());
      keyStorePasswordFile.setPropertyName(OPTION_LONG_KEYSTORE_PWD_FILE);
      argParser.addArgument(keyStorePasswordFile);

      certNickname = new StringArgument(
              "certnickname", 'N', "certNickname",
              false, false, true, INFO_NICKNAME_PLACEHOLDER.get(), null,
              null, INFO_DESCRIPTION_CERT_NICKNAME.get());
      certNickname.setPropertyName("certNickname");
      argParser.addArgument(certNickname);

      trustStorePath = new StringArgument(
              "trustStorePath",
              OPTION_SHORT_TRUSTSTOREPATH,
              OPTION_LONG_TRUSTSTOREPATH,
              false, false, true,
              INFO_TRUSTSTOREPATH_PLACEHOLDER.get(),
              null, null,
              INFO_DESCRIPTION_TRUSTSTOREPATH.get());
      trustStorePath.setPropertyName(OPTION_LONG_TRUSTSTOREPATH);
      argParser.addArgument(trustStorePath);

      trustStorePassword =
           new StringArgument("trustStorePassword", null,
                              OPTION_LONG_TRUSTSTORE_PWD ,
                              false, false, true,
                              INFO_TRUSTSTORE_PWD_PLACEHOLDER.get(), null,
                              null, INFO_DESCRIPTION_TRUSTSTOREPASSWORD.get());
      trustStorePassword.setPropertyName(OPTION_LONG_TRUSTSTORE_PWD);
      argParser.addArgument(trustStorePassword);

      trustStorePasswordFile =
           new FileBasedArgument(
                   "truststorepasswordfile",
                   OPTION_SHORT_TRUSTSTORE_PWD_FILE,
                   OPTION_LONG_TRUSTSTORE_PWD_FILE, false, false,
                   INFO_TRUSTSTORE_PWD_FILE_PLACEHOLDER.get(), null, null,
                   INFO_DESCRIPTION_TRUSTSTOREPASSWORD_FILE.get());
      trustStorePasswordFile.setPropertyName(OPTION_LONG_TRUSTSTORE_PWD_FILE);
      argParser.addArgument(trustStorePasswordFile);

      proxyAuthzID = new StringArgument("proxy_authzid",
                                        OPTION_SHORT_PROXYAUTHID,
                                        OPTION_LONG_PROXYAUTHID, false,
                                        false, true,
                                        INFO_PROXYAUTHID_PLACEHOLDER.get(),
                                        null, null,
                                        INFO_DESCRIPTION_PROXY_AUTHZID.get());
      proxyAuthzID.setPropertyName(OPTION_LONG_PROXYAUTHID);
      argParser.addArgument(proxyAuthzID);

      reportAuthzID = new BooleanArgument(
              "reportauthzid", 'E',
              "reportAuthzID",
              INFO_DESCRIPTION_REPORT_AUTHZID.get());
      reportAuthzID.setPropertyName("reportAuthzID");
      argParser.addArgument(reportAuthzID);

      assertionFilter = new StringArgument(
              "assertionfilter", null,
              OPTION_LONG_ASSERTION_FILE,
              false, false,
              true,
              INFO_ASSERTION_FILTER_PLACEHOLDER.get(),
              null, null,
              INFO_DESCRIPTION_ASSERTION_FILTER.get());
      assertionFilter.setPropertyName(OPTION_LONG_ASSERTION_FILE);
      argParser.addArgument(assertionFilter);

      preReadAttributes = new StringArgument(
              "prereadattrs", null,
              "preReadAttributes", false, false,
              true, INFO_ATTRIBUTE_LIST_PLACEHOLDER.get(), null, null,
              INFO_DESCRIPTION_PREREAD_ATTRS.get());
      preReadAttributes.setPropertyName("preReadAttributes");
      argParser.addArgument(preReadAttributes);

      postReadAttributes = new StringArgument(
              "postreadattrs", null,
              "postReadAttributes", false,
              false, true, INFO_ATTRIBUTE_LIST_PLACEHOLDER.get(), null,
              null,
              INFO_DESCRIPTION_POSTREAD_ATTRS.get());
      postReadAttributes.setPropertyName("postReadAttributes");
      argParser.addArgument(postReadAttributes);

      controlStr =
           new StringArgument("control", 'J', "control", false, true, true,
                    INFO_LDAP_CONTROL_PLACEHOLDER.get(),
                    null, null, INFO_DESCRIPTION_CONTROLS.get());
      controlStr.setPropertyName("control");
      argParser.addArgument(controlStr);

      version = new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
                              OPTION_LONG_PROTOCOL_VERSION,
                              false, false, true,
                              INFO_PROTOCOL_VERSION_PLACEHOLDER.get(), 3, null,
                              INFO_DESCRIPTION_VERSION.get());
      version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
      argParser.addArgument(version);

      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
      argParser.addArgument(connectTimeout);

      encodingStr = new StringArgument("encoding", 'i', "encoding",
                                      false, false,
                                      true, INFO_ENCODING_PLACEHOLDER.get(),
                                      null, null,
                                      INFO_DESCRIPTION_ENCODING.get());
      encodingStr.setPropertyName("encoding");
      argParser.addArgument(encodingStr);

      continueOnError = new BooleanArgument("continueOnError", 'c',
                                    "continueOnError",
                                    INFO_DESCRIPTION_CONTINUE_ON_ERROR.get());
      continueOnError.setPropertyName("continueOnError");
      argParser.addArgument(continueOnError);

      noop = new BooleanArgument("no-op", OPTION_SHORT_DRYRUN,
                                    OPTION_LONG_DRYRUN,
                                    INFO_DESCRIPTION_NOOP.get());
      noop.setPropertyName(OPTION_LONG_DRYRUN);
      argParser.addArgument(noop);

      verbose = new BooleanArgument("verbose", 'v', "verbose",
                                    INFO_DESCRIPTION_VERBOSE.get());
      verbose.setPropertyName("verbose");
      argParser.addArgument(verbose);

      showUsage = new BooleanArgument("showUsage", OPTION_SHORT_HELP,
                                      OPTION_LONG_HELP,
                                      INFO_DESCRIPTION_SHOWUSAGE.get());
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage, out);
    } catch (ArgumentException ae)
View Full Code Here

    // Create the naming arguments.
    this.namingArgs = createNamingArgs(subCommand, c, false);

    // Create the --force argument which is used to force deletion.
    this.forceArgument = new BooleanArgument(OPTION_DSCFG_LONG_FORCE,
        OPTION_DSCFG_SHORT_FORCE, OPTION_DSCFG_LONG_FORCE,
        INFO_DSCFG_DESCRIPTION_FORCE.get(ufpn));
    subCommand.addArgument(forceArgument);

    // Register the tags associated with the child managed objects.
View Full Code Here

      err = new PrintStream(errStream);
    }


    // Create the arguments that will be used by this program.
    BooleanArgument   provideDNForAuthzID;
    BooleanArgument   showUsage;
    BooleanArgument   sslBlindTrust;
    BooleanArgument   useSSL;
    BooleanArgument   useStartTLS;
    FileBasedArgument bindPWFile;
    StringArgument    certNickname           = null;
    FileBasedArgument currentPWFile;
    FileBasedArgument newPWFile;
    FileBasedArgument sslKeyStorePINFile;
    FileBasedArgument sslTrustStorePINFile;
    IntegerArgument   ldapPort;
    StringArgument    authzID;
    StringArgument    bindDN;
    StringArgument    bindPW;
    StringArgument    controlStr;
    StringArgument    currentPW;
    StringArgument    ldapHost;
    StringArgument    newPW;
    StringArgument    sslKeyStore;
    StringArgument    sslKeyStorePIN;
    StringArgument    sslTrustStore;
    StringArgument    sslTrustStorePIN;
    IntegerArgument   connectTimeout;
    StringArgument    propertiesFileArgument;
    BooleanArgument   noPropertiesFileArgument;


    // Initialize the argument parser.
    Message toolDescription = INFO_LDAPPWMOD_TOOL_DESCRIPTION.get();
    ArgumentParser argParser = new ArgumentParser(CLASS_NAME, toolDescription,
                                                  false);

    try
    {
      propertiesFileArgument = new StringArgument("propertiesFilePath",
          null, OPTION_LONG_PROP_FILE_PATH,
          false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
          INFO_DESCRIPTION_PROP_FILE_PATH.get());
      argParser.addArgument(propertiesFileArgument);
      argParser.setFilePropertiesArgument(propertiesFileArgument);

      noPropertiesFileArgument = new BooleanArgument(
          "noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
          INFO_DESCRIPTION_NO_PROP_FILE.get());
      argParser.addArgument(noPropertiesFileArgument);
      argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);

      ldapHost = new StringArgument("ldaphost", OPTION_SHORT_HOST,
                                    OPTION_LONG_HOST, false, false,
                                    true, INFO_HOST_PLACEHOLDER.get(),
                                    "127.0.0.1", null,
                                    INFO_LDAPPWMOD_DESCRIPTION_HOST.get());
      ldapHost.setPropertyName(OPTION_LONG_HOST);
      argParser.addArgument(ldapHost);


      ldapPort = new IntegerArgument(
              "ldapport", OPTION_SHORT_PORT,
              OPTION_LONG_PORT, false, false,
              true, INFO_PORT_PLACEHOLDER.get(), 389,
              null, true, 1, true,
              65535, INFO_LDAPPWMOD_DESCRIPTION_PORT.get());
      ldapPort.setPropertyName(OPTION_LONG_PORT);
      argParser.addArgument(ldapPort);


      useSSL = new BooleanArgument("usessl", OPTION_SHORT_USE_SSL,
                                   OPTION_LONG_USE_SSL,
                                   INFO_LDAPPWMOD_DESCRIPTION_USE_SSL.get());
      useSSL.setPropertyName(OPTION_LONG_USE_SSL);
      argParser.addArgument(useSSL);


      useStartTLS = new BooleanArgument("usestarttls", OPTION_SHORT_START_TLS,
                             OPTION_LONG_START_TLS,
                             INFO_LDAPPWMOD_DESCRIPTION_USE_STARTTLS.get());
      useStartTLS.setPropertyName(OPTION_LONG_START_TLS);
      argParser.addArgument(useStartTLS);


      bindDN = new StringArgument("binddn", OPTION_SHORT_BINDDN,
                                  OPTION_LONG_BINDDN, false, false, true,
                                  INFO_BINDDN_PLACEHOLDER.get(), null, null,
                                  INFO_LDAPPWMOD_DESCRIPTION_BIND_DN.get());
      bindDN.setPropertyName(OPTION_LONG_BINDDN);
      argParser.addArgument(bindDN);


      bindPW = new StringArgument("bindpw", OPTION_SHORT_BINDPWD,
                                  OPTION_LONG_BINDPWD, false, false,
                                  true, INFO_BINDPWD_PLACEHOLDER.get(), null,
                                  null,
                                  INFO_LDAPPWMOD_DESCRIPTION_BIND_PW.get());
      bindPW.setPropertyName(OPTION_LONG_BINDPWD);
      argParser.addArgument(bindPW);


      bindPWFile =
           new FileBasedArgument("bindpwfile", OPTION_SHORT_BINDPWD_FILE,
                                 OPTION_LONG_BINDPWD_FILE, false,
                                 false, INFO_BINDPWD_FILE_PLACEHOLDER.get(),
                                 null, null,
                                 INFO_LDAPPWMOD_DESCRIPTION_BIND_PW_FILE.get());
      bindPWFile.setPropertyName(OPTION_LONG_BINDPWD_FILE);
      argParser.addArgument(bindPWFile);


      authzID = new StringArgument("authzid", 'a', "authzID", false, false,
                                   true, INFO_PROXYAUTHID_PLACEHOLDER.get(),
                                   null, null,
                                   INFO_LDAPPWMOD_DESCRIPTION_AUTHZID.get());
      authzID.setPropertyName("authzID");
      argParser.addArgument(authzID);


      provideDNForAuthzID =
           new BooleanArgument("providednforauthzid", 'A',"provideDNForAuthzID",
                    INFO_LDAPPWMOD_DESCRIPTION_PROVIDE_DN_FOR_AUTHZID.get());
      provideDNForAuthzID.setPropertyName("provideDNForAuthzID");
      argParser.addArgument(provideDNForAuthzID);


      newPW = new StringArgument("newpw", 'n', "newPassword", false, false,
                                 true, INFO_NEW_PASSWORD_PLACEHOLDER.get(),
                                 null, null,
                                 INFO_LDAPPWMOD_DESCRIPTION_NEWPW.get());
      newPW.setPropertyName("newPassword");
      argParser.addArgument(newPW);


      newPWFile = new FileBasedArgument(
              "newpwfile", 'N', "newPasswordFile",
              false, false, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDAPPWMOD_DESCRIPTION_NEWPWFILE.get());
      newPWFile.setPropertyName("newPasswordFile");
      argParser.addArgument(newPWFile);


      currentPW =
           new StringArgument("currentpw", 'c', "currentPassword", false, false,
                              true, INFO_CURRENT_PASSWORD_PLACEHOLDER.get(),
                              null,  null,
                              INFO_LDAPPWMOD_DESCRIPTION_CURRENTPW.get());
      currentPW.setPropertyName("currentPassword");
      argParser.addArgument(currentPW);


      currentPWFile =
           new FileBasedArgument(
                   "currentpwfile", 'C', "currentPasswordFile",
                   false, false, INFO_FILE_PLACEHOLDER.get(), null, null,
                   INFO_LDAPPWMOD_DESCRIPTION_CURRENTPWFILE.get());
      currentPWFile.setPropertyName("currentPasswordFile");
      argParser.addArgument(currentPWFile);


      sslBlindTrust =
           new BooleanArgument("blindtrust", 'X', "trustAll",
                               INFO_LDAPPWMOD_DESCRIPTION_BLIND_TRUST.get());
      sslBlindTrust.setPropertyName("trustAll");
      argParser.addArgument(sslBlindTrust);


      sslKeyStore =
           new StringArgument("keystorepath", OPTION_SHORT_KEYSTOREPATH,
                              OPTION_LONG_KEYSTOREPATH, false, false,
                              true, INFO_KEYSTOREPATH_PLACEHOLDER.get(), null,
                              null,
                              INFO_LDAPPWMOD_DESCRIPTION_KEYSTORE.get());
      sslKeyStore.setPropertyName(OPTION_LONG_KEYSTOREPATH);
      argParser.addArgument(sslKeyStore);


      sslKeyStorePIN =
           new StringArgument("keystorepassword",
                              OPTION_SHORT_KEYSTORE_PWD,
                              OPTION_LONG_KEYSTORE_PWD ,
                              false, false, true,
                              INFO_KEYSTORE_PWD_PLACEHOLDER.get(),
                              null, null,
                              INFO_LDAPPWMOD_DESCRIPTION_KEYSTORE_PIN.get());
      sslKeyStorePIN.setPropertyName(OPTION_LONG_KEYSTORE_PWD);
      argParser.addArgument(sslKeyStorePIN);


      sslKeyStorePINFile =
           new FileBasedArgument(
                   "keystorepasswordfile",
                   OPTION_SHORT_KEYSTORE_PWD_FILE,
                   OPTION_LONG_KEYSTORE_PWD_FILE,
                   false, false, INFO_KEYSTORE_PWD_FILE_PLACEHOLDER.get(),
                   null, null,
                   INFO_LDAPPWMOD_DESCRIPTION_KEYSTORE_PINFILE.get());
      sslKeyStorePINFile.setPropertyName(OPTION_LONG_KEYSTORE_PWD_FILE);
      argParser.addArgument(sslKeyStorePINFile);

      certNickname = new StringArgument("certnickname", null, "certNickname",
          false, false, true, INFO_NICKNAME_PLACEHOLDER.get(), null, null,
          INFO_DESCRIPTION_CERT_NICKNAME.get());
      certNickname.setPropertyName("certNickname");
      argParser.addArgument(certNickname);



      sslTrustStore =
           new StringArgument("truststorepath",
                              OPTION_SHORT_TRUSTSTOREPATH,
                              OPTION_LONG_TRUSTSTOREPATH, false,
                              false, true,
                              INFO_TRUSTSTOREPATH_PLACEHOLDER.get(), null, null,
                              INFO_LDAPPWMOD_DESCRIPTION_TRUSTSTORE.get());
      sslTrustStore.setPropertyName(OPTION_LONG_TRUSTSTOREPATH);
      argParser.addArgument(sslTrustStore);


      sslTrustStorePIN =
           new StringArgument("truststorepassword", null,
                              OPTION_LONG_TRUSTSTORE_PWD,
                              false, false, true,
                              INFO_TRUSTSTORE_PWD_PLACEHOLDER.get(), null, null,
                              INFO_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PIN.get());
      sslTrustStorePIN.setPropertyName(OPTION_LONG_TRUSTSTORE_PWD);
      argParser.addArgument(sslTrustStorePIN);


      sslTrustStorePINFile =
           new FileBasedArgument("truststorepasswordfile",
                    OPTION_SHORT_TRUSTSTORE_PWD_FILE,
                    OPTION_LONG_TRUSTSTORE_PWD_FILE, false, false,
                    INFO_TRUSTSTORE_PWD_FILE_PLACEHOLDER.get(), null,
                    null, INFO_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PINFILE.get());
      sslTrustStorePINFile.setPropertyName(OPTION_LONG_TRUSTSTORE_PWD_FILE);
      argParser.addArgument(sslTrustStorePINFile);


      controlStr =
           new StringArgument("control", 'J', "control", false, true, true,
                    INFO_LDAP_CONTROL_PLACEHOLDER.get(),
                    null, null, INFO_DESCRIPTION_CONTROLS.get());
      controlStr.setPropertyName("control");
      argParser.addArgument(controlStr);

      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
      argParser.addArgument(connectTimeout);


      showUsage = new BooleanArgument("help", OPTION_SHORT_HELP,
                                      OPTION_LONG_HELP,
                                      INFO_DESCRIPTION_USAGE.get());
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage, out);
    }
View Full Code Here

     * Whether LDAP is enabled or not.
     */
    {
      ServerProperty prop = ServerProperty.LDAP_ENABLED;
      String attName = prop.getAttributeName();
      BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
      arg.setDefaultValue("false");
      serverProperties.put(prop, arg);
    }

    /**
     * Whether LDAPS is enabled or not.
     */
    {
      ServerProperty prop = ServerProperty.LDAPS_ENABLED;
      String attName = prop.getAttributeName();
      BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
      arg.setDefaultValue("false");
      serverProperties.put(prop, arg);
    }

    /**
     * Whether StartTLS is enabled or not.
     */
    {
      ServerProperty prop = ServerProperty.STARTTLS_ENABLED;
      String attName = prop.getAttributeName();
      BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
      arg.setDefaultValue("false");
      serverProperties.put(prop, arg);
    }

    /**
     * Whether JMX is enabled or not.
     */
    {
      ServerProperty prop = ServerProperty.JMX_ENABLED;
      String attName = prop.getAttributeName();
      BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
      arg.setDefaultValue("false");
      serverProperties.put(prop, arg);
    }

    /**
     * Whether JMXS is enabled or not.
     */
    {
      ServerProperty prop = ServerProperty.JMXS_ENABLED;
      String attName = prop.getAttributeName();
      BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
      arg.setDefaultValue("false");
      serverProperties.put(prop, arg);
    }

    /**
     * The location of the server.
     */
    {
      ServerProperty prop = ServerProperty.LOCATION;
      String attName = prop.getAttributeName();
      StringArgument arg = new StringArgument(attName, null, attName, false,
          false, true, Message.raw(attName), null, null, null);
      serverProperties.put(prop, arg);
    }

    /**
     * The list of groups in which the server is registered.
     */
    {
      ServerProperty prop = ServerProperty.GROUPS;
      String attName = prop.getAttributeName();
      StringArgument arg = new StringArgument(attName, null, attName, false,
          true, true, Message.raw(attName), null, null, null);
      arg.setHidden(true);
      serverProperties.put(prop, arg);
    }

   /**
    * The INSTANCE_KEY_ID used to identify the server key ID.
View Full Code Here

    else
    {
      err = new PrintStream(errStream);
    }

    BooleanArgument overwriteExisting;
    BooleanArgument showUsage;
    BooleanArgument singleValueChanges;
    BooleanArgument doCheckSchema;
    StringArgument  configClass;
    StringArgument  configFile;
    StringArgument  outputLDIF;
    StringArgument  sourceLDIF;
    StringArgument  targetLDIF;
    StringArgument  ignoreAttrsFile;
    StringArgument  ignoreEntriesFile;


    Message toolDescription = INFO_LDIFDIFF_TOOL_DESCRIPTION.get();
    ArgumentParser argParser = new ArgumentParser(CLASS_NAME, toolDescription,
                                                  false);
    try
    {
      sourceLDIF = new StringArgument(
              "sourceldif", 's', "sourceLDIF", true,
              false, true, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDIFDIFF_DESCRIPTION_SOURCE_LDIF.get());
      argParser.addArgument(sourceLDIF);

      targetLDIF = new StringArgument(
              "targetldif", 't', "targetLDIF", true,
              false, true, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDIFDIFF_DESCRIPTION_TARGET_LDIF.get());
      argParser.addArgument(targetLDIF);

      outputLDIF = new StringArgument(
              "outputldif", 'o', "outputLDIF", false,
              false, true, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDIFDIFF_DESCRIPTION_OUTPUT_LDIF.get());
      argParser.addArgument(outputLDIF);

      ignoreAttrsFile = new StringArgument(
              "ignoreattrs", 'a', "ignoreAttrs", false,
              false, true, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDIFDIFF_DESCRIPTION_IGNORE_ATTRS.get());
      argParser.addArgument(ignoreAttrsFile);

      ignoreEntriesFile = new StringArgument(
              "ignoreentries", 'e', "ignoreEntries", false,
              false, true, INFO_FILE_PLACEHOLDER.get(), null, null,
              INFO_LDIFDIFF_DESCRIPTION_IGNORE_ENTRIES.get());
      argParser.addArgument(ignoreEntriesFile);

      overwriteExisting =
           new BooleanArgument(
                   "overwriteexisting", 'O',
                   "overwriteExisting",
                   INFO_LDIFDIFF_DESCRIPTION_OVERWRITE_EXISTING.get());
      argParser.addArgument(overwriteExisting);

      singleValueChanges =
           new BooleanArgument(
                   "singlevaluechanges", 'S', "singleValueChanges",
                   INFO_LDIFDIFF_DESCRIPTION_SINGLE_VALUE_CHANGES.get());
      argParser.addArgument(singleValueChanges);

      doCheckSchema =
        new BooleanArgument(
                "checkschema", null, "checkSchema",
                INFO_LDIFDIFF_DESCRIPTION_CHECK_SCHEMA.get());
      argParser.addArgument(doCheckSchema);

      configFile = new StringArgument("configfile", 'c', "configFile", false,
                                      false, true,
                                      INFO_CONFIGFILE_PLACEHOLDER.get(), null,
                                      null,
                                      INFO_DESCRIPTION_CONFIG_FILE.get());
      configFile.setHidden(true);
      argParser.addArgument(configFile);

      configClass = new StringArgument("configclass", OPTION_SHORT_CONFIG_CLASS,
                             OPTION_LONG_CONFIG_CLASS, false,
                             false, true, INFO_CONFIGCLASS_PLACEHOLDER.get(),
                             ConfigFileHandler.class.getName(), null,
                             INFO_DESCRIPTION_CONFIG_CLASS.get());
      configClass.setHidden(true);
      argParser.addArgument(configClass);

      showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
                                      OPTION_LONG_HELP,
                                      INFO_DESCRIPTION_USAGE.get());
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage);
    }
    catch (ArgumentException ae)
    {

      Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(message);
      return 1;
    }


    // Parse the command-line arguments provided to the program.
    try
    {
      argParser.parseArguments(args);
    }
    catch (ArgumentException ae)
    {

      Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());

      err.println(message);
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }


    // If we should just display usage or version information,
    // then print it and exit.
    if (argParser.usageOrVersionDisplayed())
    {
      return 0;
    }

    if (doCheckSchema.isPresent() && !configFile.isPresent())
    {
      String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
      if (scriptName == null)
      {
        scriptName = "ldif-diff";
      }
      Message message = WARN_LDIFDIFF_NO_CONFIG_FILE.get(scriptName);
      err.println(message);
    }


    boolean checkSchema = configFile.isPresent() && doCheckSchema.isPresent();
    if (! serverInitialized)
    {
      // Bootstrap the Directory Server configuration for use as a client.
      DirectoryServer directoryServer = DirectoryServer.getInstance();
      DirectoryServer.bootstrapClient();
View Full Code Here

   * @throws ArgumentException if there was an error creating or adding the
   * arguments.  If this occurs is likely to be a bug.
   */
  public void initializeArguments() throws ArgumentException
  {
    quietArg = new BooleanArgument(
        "quiet", OPTION_SHORT_QUIET,
        OPTION_LONG_QUIET,
        INFO_JAVAPROPERTIES_DESCRIPTION_SILENT.get());
    quietArg.setPropertyName(OPTION_LONG_QUIET);
    addArgument(quietArg);

    propertiesFileArg = new StringArgument("propertiesFile",
        'p', "propertiesFile", false,
        false, true, INFO_PATH_PLACEHOLDER.get(), getDefaultPropertiesValue(),
        "propertiesFile",
        INFO_JAVAPROPERTIES_DESCRIPTION_PROPERTIES_FILE.get(
            getDefaultPropertiesValue()));
    propertiesFileArg.setHidden(true);
    addArgument(propertiesFileArg);

    destinationFileArg = new StringArgument("destinationFile",
        'd', "destinationFile", false,
        false, true, INFO_PATH_PLACEHOLDER.get(), getDefaultDestinationValue(),
        "destinationFile",
        INFO_JAVAPROPERTIES_DESCRIPTION_DESTINATION_FILE.get(
            getDefaultDestinationValue()));
    destinationFileArg.setHidden(true);
    addArgument(destinationFileArg);

    showUsageArg = new BooleanArgument("help", OPTION_SHORT_HELP,
        OPTION_LONG_HELP,
        INFO_JAVAPROPERTIES_DESCRIPTION_HELP.get());
    addArgument(showUsageArg);
    setUsageArgument(showUsageArg);
  }
View Full Code Here

        false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
        INFO_DESCRIPTION_PROP_FILE_PATH.get());
      argParser.addArgument(propertiesFileArgument);
      argParser.setFilePropertiesArgument(propertiesFileArgument);

      BooleanArgument noPropertiesFileArgument = new BooleanArgument(
        "noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
        INFO_DESCRIPTION_NO_PROP_FILE.get());
      argParser.addArgument(noPropertiesFileArgument);
      argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);

      taskScheduleArgs = new TaskScheduleArgs();

      for (Argument arg : taskScheduleArgs.getArguments())
      {
        argParser.addArgument(arg, taskGroup);
      }

      testIfOfflineArg = new BooleanArgument("testIfOffline", null,
          "testIfOffline", INFO_DESCRIPTION_TEST_IF_OFFLINE.get());
      testIfOfflineArg.setHidden(true);
      argParser.addArgument(testIfOfflineArg);
    } catch (ArgumentException e) {
      // should never happen
View Full Code Here

TOP

Related Classes of org.nasutekds.server.util.args.BooleanArgument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.