From 73302adac1b5e9aa946418ca776df8be9613ced4 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Fri, 07 Feb 2014 10:15:15 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1303 - Extracted CLI arguments identifiers from CliConstants to ArgumentConstants. - Moved default CLI values like DEFAULT_LDAP_PORT, DEFAULT_ADMIN_PORT to CliConstants. - Code cleanup.
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java | 622 ++++++++++++++++++++++++++++
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java | 29 +
opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java | 2
opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java | 2
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java | 41 +
opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java | 617 ---------------------------
6 files changed, 697 insertions(+), 616 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
new file mode 100644
index 0000000..7ac76ce
--- /dev/null
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
@@ -0,0 +1,622 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2014 ForgeRock AS
+ */
+package com.forgerock.opendj.cli;
+
+/**
+ * This class contains short and long options used by the argument in CLI.
+ */
+public final class ArgumentConstants {
+
+ /**
+ * The name of the SASL property that can be used to provide the
+ * authentication ID for the bind.
+ */
+ public static final String SASL_PROPERTY_AUTHID = "authid";
+
+ /**
+ * The name of the SASL property that can be used to provide the
+ * authorization ID for the bind.
+ */
+ public static final String SASL_PROPERTY_AUTHZID = "authzid";
+
+ /**
+ * The name of the SASL property that can be used to provide the digest URI
+ * for the bind.
+ */
+ public static final String SASL_PROPERTY_DIGEST_URI = "digest-uri";
+
+ /**
+ * The name of the SASL property that can be used to provide the KDC for use
+ * in Kerberos authentication.
+ */
+ public static final String SASL_PROPERTY_KDC = "kdc";
+
+ /**
+ * The name of the SASL property that can be used to provide the quality of
+ * protection for the bind.
+ */
+ public static final String SASL_PROPERTY_QOP = "qop";
+
+ /**
+ * The name of the SASL property that can be used to provide the realm for
+ * the bind.
+ */
+ public static final String SASL_PROPERTY_REALM = "realm";
+
+ /**
+ * The name of the SASL property that can be used to provide the SASL
+ * mechanism to use.
+ */
+ public static final String SASL_PROPERTY_MECH = "mech";
+
+ /**
+ * The value for the short option batchFilePath.
+ */
+ public static final char OPTION_SHORT_BATCH_FILE_PATH = 'F';
+
+ /**
+ * The value for the long option batchFilePath .
+ */
+ public static final String OPTION_LONG_BATCH_FILE_PATH = "batchFilePath";
+
+ /**
+ * The value for the short option host name.
+ */
+ public static final char OPTION_SHORT_HOST = 'h';
+
+ /**
+ * The value for the long option host name.
+ */
+ public static final String OPTION_LONG_HOST = "hostname";
+
+ /**
+ * The value for the short option port.
+ */
+ public static final char OPTION_SHORT_PORT = 'p';
+
+ /**
+ * The value for the long option port.
+ */
+ public static final String OPTION_LONG_PORT = "port";
+
+ /**
+ * The value for the short option useSSL.
+ */
+ public static final char OPTION_SHORT_USE_SSL = 'Z';
+
+ /**
+ * The value for the long option useSSL.
+ */
+ public static final String OPTION_LONG_USE_SSL = "useSSL";
+
+ /**
+ * The value for the short option baseDN.
+ */
+ public static final char OPTION_SHORT_BASEDN = 'b';
+
+ /**
+ * The value for the long option baseDN.
+ */
+ public static final String OPTION_LONG_BASEDN = "baseDN";
+
+ /**
+ * The value for the short option bindDN.
+ */
+ public static final char OPTION_SHORT_BINDDN = 'D';
+
+ /**
+ * The value for the long option bindDN.
+ */
+ public static final String OPTION_LONG_BINDDN = "bindDN";
+
+ /**
+ * The value for the short option bindPassword.
+ */
+ public static final char OPTION_SHORT_BINDPWD = 'w';
+
+ /**
+ * The value for the long option bindPassword.
+ */
+ public static final String OPTION_LONG_BINDPWD = "bindPassword";
+
+ /**
+ * The value for the short option bindPasswordFile.
+ */
+ public static final char OPTION_SHORT_BINDPWD_FILE = 'j';
+
+ /**
+ * The value for the long option bindPasswordFile.
+ */
+ public static final String OPTION_LONG_BINDPWD_FILE = "bindPasswordFile";
+
+ /**
+ * The value for the short option compress.
+ */
+ public static final char OPTION_SHORT_COMPRESS = 'c';
+
+ /**
+ * The value for the long option compress.
+ */
+ public static final String OPTION_LONG_COMPRESS = "compress";
+
+ /**
+ * The value for the short option filename.
+ */
+ public static final char OPTION_SHORT_FILENAME = 'f';
+
+ /**
+ * The value for the long option filename.
+ */
+ public static final String OPTION_LONG_FILENAME = "filename";
+
+ /**
+ * The value for the short option ldifFile.
+ */
+ public static final char OPTION_SHORT_LDIF_FILE = 'l';
+
+ /**
+ * The value for the long option ldifFile.
+ */
+ public static final String OPTION_LONG_LDIF_FILE = "ldifFile";
+
+ /**
+ * The value for the short option useStartTLS.
+ */
+ public static final char OPTION_SHORT_START_TLS = 'q';
+
+ /**
+ * The value for the long option useStartTLS.
+ */
+ public static final String OPTION_LONG_START_TLS = "useStartTLS";
+
+ /**
+ * The value for the short option randomSeed.
+ */
+ public static final char OPTION_SHORT_RANDOM_SEED = 's';
+
+ /**
+ * The value for the long option randomSeed.
+ */
+ public static final String OPTION_LONG_RANDOM_SEED = "randomSeed";
+
+ /**
+ * The value for the short option keyStorePath.
+ */
+ public static final char OPTION_SHORT_KEYSTOREPATH = 'K';
+
+ /**
+ * The value for the long option keyStorePath.
+ */
+ public static final String OPTION_LONG_KEYSTOREPATH = "keyStorePath";
+
+ /**
+ * The value for the short option trustStorePath.
+ */
+ public static final char OPTION_SHORT_TRUSTSTOREPATH = 'P';
+
+ /**
+ * The value for the long option trustStorePath.
+ */
+ public static final String OPTION_LONG_TRUSTSTOREPATH = "trustStorePath";
+
+ /**
+ * The value for the short option keyStorePassword.
+ */
+ public static final char OPTION_SHORT_KEYSTORE_PWD = 'W';
+
+ /**
+ * The value for the long option keyStorePassword.
+ */
+ public static final String OPTION_LONG_KEYSTORE_PWD = "keyStorePassword";
+
+ /**
+ * The value for the short option trustStorePassword.
+ */
+ public static final char OPTION_SHORT_TRUSTSTORE_PWD = 'T';
+
+ /**
+ * The value for the long option trustStorePassword.
+ */
+ public static final String OPTION_LONG_TRUSTSTORE_PWD = "trustStorePassword";
+
+ /**
+ * The value for the short option keyStorePasswordFile .
+ */
+ public static final char OPTION_SHORT_KEYSTORE_PWD_FILE = 'u';
+
+ /**
+ * The value for the long option keyStorePasswordFile .
+ */
+ public static final String OPTION_LONG_KEYSTORE_PWD_FILE = "keyStorePasswordFile";
+
+ /**
+ * The value for the short option keyStorePasswordFile .
+ */
+ public static final char OPTION_SHORT_TRUSTSTORE_PWD_FILE = 'U';
+
+ /**
+ * The value for the long option keyStorePasswordFile .
+ */
+ public static final String OPTION_LONG_TRUSTSTORE_PWD_FILE = "trustStorePasswordFile";
+
+ /**
+ * The value for the short option trustAll .
+ */
+ public static final char OPTION_SHORT_TRUSTALL = 'X';
+
+ /**
+ * The value for the long option trustAll .
+ */
+ public static final String OPTION_LONG_TRUSTALL = "trustAll";
+
+ /**
+ * The value for the short option certNickname .
+ */
+ public static final char OPTION_SHORT_CERT_NICKNAME = 'N';
+
+ /**
+ * The value for the long option certNickname .
+ */
+ public static final String OPTION_LONG_CERT_NICKNAME = "certNickname";
+
+ /**
+ * The value for the long option assertionFilter .
+ */
+ public static final String OPTION_LONG_ASSERTION_FILE = "assertionFilter";
+
+ /**
+ * The value for the short option dry-run.
+ */
+ public static final char OPTION_SHORT_DRYRUN = 'n';
+
+ /**
+ * The value for the long option dry-run.
+ */
+ public static final String OPTION_LONG_DRYRUN = "dry-run";
+
+ /**
+ * The value for the short option help.
+ */
+ public static final char OPTION_SHORT_HELP = 'H';
+
+ /**
+ * The value for the long option help.
+ */
+ public static final String OPTION_LONG_HELP = "help";
+
+ /**
+ * The value for the long option cli.
+ */
+ public static final String OPTION_LONG_CLI = "cli";
+
+ /**
+ * The value for the short option cli.
+ */
+ public static final char OPTION_SHORT_CLI = 'i';
+
+ /**
+ * The value for the short option proxyAs.
+ */
+ public static final char OPTION_SHORT_PROXYAUTHID = 'Y';
+
+ /**
+ * The value for the long option proxyAs.
+ */
+ public static final String OPTION_LONG_PROXYAUTHID = "proxyAs";
+
+ /**
+ * The value for the short option saslOption.
+ */
+ public static final char OPTION_SHORT_SASLOPTION = 'o';
+
+ /**
+ * The value for the long option saslOption.
+ */
+ public static final String OPTION_LONG_SASLOPTION = "saslOption";
+
+ /**
+ * The value for the short option geteffectiverights control authzid.
+ */
+ public static final char OPTION_SHORT_EFFECTIVERIGHTSUSER = 'g';
+
+ /**
+ * The value for the long option geteffectiverights control authzid.
+ */
+ public static final String OPTION_LONG_EFFECTIVERIGHTSUSER = "getEffectiveRightsAuthzid";
+
+ /**
+ * The value for the short option geteffectiveights control attributes.
+ */
+ public static final char OPTION_SHORT_EFFECTIVERIGHTSATTR = 'e';
+
+ /**
+ * The value for the long option geteffectiverights control specific
+ * attribute list.
+ */
+ public static final String OPTION_LONG_EFFECTIVERIGHTSATTR = "getEffectiveRightsAttribute";
+
+ /**
+ * The value for the short option protocol version attributes.
+ */
+ public static final char OPTION_SHORT_PROTOCOL_VERSION = 'V';
+
+ /**
+ * The value for the long option protocol version attribute.
+ */
+ public static final String OPTION_LONG_PROTOCOL_VERSION = "ldapVersion";
+
+ /**
+ * The value for the long option version.
+ */
+ public static final char OPTION_SHORT_PRODUCT_VERSION = 'V';
+
+ /**
+ * The value for the long option version.
+ */
+ public static final String OPTION_LONG_PRODUCT_VERSION = "version";
+
+ /**
+ * The value for the short option description attributes.
+ */
+ public static final char OPTION_SHORT_DESCRIPTION = 'd';
+
+ /**
+ * The value for the long option description attribute.
+ */
+ public static final String OPTION_LONG_DESCRIPTION = "description";
+
+ /**
+ * The value for the short option groupName attributes.
+ */
+ public static final char OPTION_SHORT_GROUPNAME = 'g';
+
+ /**
+ * The value for the long option groupName attribute.
+ */
+ public static final String OPTION_LONG_GROUPNAME = "groupName";
+
+ /**
+ * The value for the short option newGroupName attribute.
+ */
+ public static final char OPTION_SHORT_NEWGROUPNAME = 'n';
+
+ /**
+ * The value for the long option groupName attribute.
+ */
+ public static final String OPTION_LONG_NEWGROUPNAME = "newGroupName";
+
+ /**
+ * The value for the short option member-name attributes.
+ */
+ public static final char OPTION_SHORT_MEMBERNAME = 'm';
+
+ /**
+ * The value for the long member-name version attribute.
+ */
+ public static final String OPTION_LONG_MEMBERNAME = "memberName";
+
+ /**
+ * The value for the short option serverID attributes.
+ */
+ public static final String OPTION_SHORT_SERVERID = null;
+
+ /**
+ * The value for the long option serverID attribute.
+ */
+ public static final String OPTION_LONG_SERVERID = "serverID";
+
+ /**
+ * The value for the short option userID attributes.
+ */
+ public static final String OPTION_SHORT_USERID = null;
+
+ /**
+ * The value for the long option userID attribute.
+ */
+ public static final String OPTION_LONG_USERID = "userID";
+
+ /**
+ * The value for the short option set.
+ */
+ public static final Character OPTION_SHORT_SET = null;
+
+ /**
+ * The value for the long option set.
+ */
+ public static final String OPTION_LONG_SET = "set";
+
+ /**
+ * Value for the quiet option short form.
+ */
+ public static final Character OPTION_SHORT_QUIET = 'Q';
+
+ /**
+ * Value for the quiet option long form.
+ */
+ public static final String OPTION_LONG_QUIET = "quiet";
+
+ /**
+ * Value for non-interactive session short form.
+ */
+ public static final Character OPTION_SHORT_NO_PROMPT = 'n';
+
+ /**
+ * Value for non-interactive session long form.
+ */
+ public static final String OPTION_LONG_NO_PROMPT = "no-prompt";
+
+ /**
+ * Long form of script friendly option.
+ */
+ public static final String OPTION_LONG_SCRIPT_FRIENDLY = "script-friendly";
+
+ /**
+ * Short form of script friendly option.
+ */
+ public static final Character OPTION_SHORT_SCRIPT_FRIENDLY = 's';
+
+ /**
+ * Value for verbose option short form.
+ */
+ public static final Character OPTION_SHORT_VERBOSE = 'v';
+
+ /**
+ * Value for verbose option long form.
+ */
+ public static final String OPTION_LONG_VERBOSE = "verbose";
+
+ /**
+ * The value for the long option propertiesFilePAth .
+ */
+ public static final String OPTION_LONG_PROP_FILE_PATH = "propertiesFilePath";
+
+ /**
+ * The value for the long option propertiesFilePAth .
+ */
+ public static final String OPTION_LONG_NO_PROP_FILE = "noPropertiesFile";
+
+ /**
+ * Long form of referenced host name.
+ */
+ public static final String OPTION_LONG_REFERENCED_HOST_NAME = "referencedHostName";
+
+ /**
+ * Long form of admin UID.
+ */
+ public static final String OPTION_LONG_ADMIN_UID = "adminUID";
+
+ /**
+ * Long form of report authorization ID connection option.
+ */
+ public static final String OPTION_LONG_REPORT_AUTHZ_ID = "reportAuthzID";
+
+ /**
+ * Long form of use password policy control connection option.
+ */
+ public static final String OPTION_LONG_USE_PW_POLICY_CTL = "usePasswordPolicyControl";
+
+ /**
+ * Long form of use SASL external connection option.
+ */
+ public static final String OPTION_LONG_USE_SASL_EXTERNAL = "useSASLExternal";
+
+ /**
+ * Long form of option for the command-line encoding option.
+ */
+ public static final String OPTION_LONG_ENCODING = "encoding";
+
+ /**
+ * Long form of option specifying no wrapping of the command-line.
+ */
+ public static final String OPTION_LONG_DONT_WRAP = "dontWrap";
+
+ /**
+ * The value for the long option targetDN.
+ */
+ public static final String OPTION_LONG_TARGETDN = "targetDN";
+
+ /**
+ * Long form of email notification upon completion option.
+ */
+ public static final String OPTION_LONG_COMPLETION_NOTIFICATION_EMAIL = "completionNotify";
+
+ /**
+ * Short form of email notification upon completion option.
+ */
+ public static final Character OPTION_SHORT_COMPLETION_NOTIFICATION_EMAIL = null;
+
+ /**
+ * Long form of email notification upon error option.
+ */
+ public static final String OPTION_LONG_ERROR_NOTIFICATION_EMAIL = "errorNotify";
+
+ /**
+ * Short form of email notification upon error option.
+ */
+ public static final Character OPTION_SHORT_ERROR_NOTIFICATION_EMAIL = null;
+
+ /**
+ * Long form of dependency option.
+ */
+ public static final String OPTION_LONG_DEPENDENCY = "dependency";
+
+ /**
+ * Short form of dependency option.
+ */
+ public static final Character OPTION_SHORT_DEPENDENCY = null;
+
+ /**
+ * Long form of failed dependency action option.
+ */
+ public static final String OPTION_LONG_FAILED_DEPENDENCY_ACTION = "failedDependencyAction";
+
+ /**
+ * Short form of failed dependency action option.
+ */
+ public static final Character OPTION_SHORT_FAILED_DEPENDENCY_ACTION = null;
+
+ /**
+ * The default separator to be used in tables.
+ */
+ public static final String LIST_TABLE_SEPARATOR = ":";
+
+ /**
+ *
+ * The value for the short option output LDIF filename.
+ */
+ public static final char OPTION_SHORT_OUTPUT_LDIF_FILENAME = 'o';
+
+ /**
+ * The value for the long option output LDIF filename.
+ */
+ public static final String OPTION_LONG_OUTPUT_LDIF_FILENAME = "outputLDIF";
+
+ /**
+ * The value for the long option to automatically accept the license
+ * if present.
+ */
+ public static final String OPTION_LONG_ACCEPT_LICENSE = "acceptLicense";
+
+ /**
+ * The value for the short option rootUserDN.
+ */
+ public static final char OPTION_SHORT_ROOT_USER_DN = 'D';
+
+ /**
+ * The value for the long option rootUserDN.
+ */
+ public static final String OPTION_LONG_ROOT_USER_DN = "rootUserDN";
+
+ /**
+ * The value for the long option connect timeout attribute.
+ */
+ public static final String OPTION_LONG_CONNECT_TIMEOUT = "connectTimeout";
+
+ // Prevent instantiation.
+ private ArgumentConstants() {
+
+ }
+}
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
index 4683791..ca53343 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -27,8 +27,7 @@
package com.forgerock.opendj.cli;
import static com.forgerock.opendj.cli.CliMessages.*;
-import static com.forgerock.opendj.cli.CliConstants.*;
-import static com.forgerock.opendj.cli.Utils.PROPERTY_SCRIPT_NAME;
+import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.util.StaticUtils.EOL;
import static com.forgerock.opendj.util.StaticUtils.getBytes;
@@ -65,6 +64,27 @@
*/
public class ArgumentParser {
/**
+ * The name of the OpenDJ configuration direction in the user home
+ * directory.
+ */
+ public static final String DEFAULT_OPENDJ_CONFIG_DIR = ".opendj";
+
+ /**
+ * The default properties file name.
+ */
+ public static final String DEFAULT_OPENDJ_PROPERTIES_FILE_NAME = "tools";
+
+ /**
+ * The default properties file extension.
+ */
+ public static final String DEFAULT_OPENDJ_PROPERTIES_FILE_EXTENSION = ".properties";
+
+ /**
+ * The name of a command-line script used to launch a tool.
+ */
+ public static final String PROPERTY_SCRIPT_NAME = "com.forgerock.opendj.ldap.tools.scriptName";
+
+ /**
* The argument that will be used to indicate the file properties.
*/
private StringArgument filePropertiesPathArgument;
@@ -313,13 +333,9 @@
if (versionArgument != null) {
if (shortID != null && shortID.equals(versionArgument.getShortIdentifier())) {
- // Update the version argument to not display its short
- // identifier.
+ // Update the version argument to not display its short identifier.
try {
- versionArgument =
- new BooleanArgument(OPTION_LONG_PRODUCT_VERSION, null,
- OPTION_LONG_PRODUCT_VERSION, INFO_DESCRIPTION_PRODUCT_VERSION
- .get());
+ versionArgument = getVersionArgument(false);
this.generalArgGroup.addArgument(versionArgument);
} catch (final ArgumentException e) {
// ignore
@@ -359,6 +375,11 @@
argumentGroups.add(group);
}
+ private BooleanArgument getVersionArgument(final boolean displayShortIdentifier) throws ArgumentException {
+ return new BooleanArgument(OPTION_LONG_PRODUCT_VERSION, displayShortIdentifier ? OPTION_SHORT_PRODUCT_VERSION
+ : null, OPTION_LONG_PRODUCT_VERSION, INFO_DESCRIPTION_PRODUCT_VERSION.get());
+ }
+
/**
* Adds the provided argument to the set of arguments handled by this parser
* and puts the arguement in the default group.
@@ -1451,9 +1472,7 @@
this.argumentGroups.add(ioArgGroup);
try {
- versionArgument =
- new BooleanArgument(OPTION_LONG_PRODUCT_VERSION, OPTION_SHORT_PRODUCT_VERSION,
- OPTION_LONG_PRODUCT_VERSION, INFO_DESCRIPTION_PRODUCT_VERSION.get());
+ versionArgument = getVersionArgument(true);
this.generalArgGroup.addArgument(versionArgument);
} catch (final ArgumentException e) {
// ignore
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java
index 601f3e2..4dc1a78 100755
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java
@@ -27,616 +27,37 @@
package com.forgerock.opendj.cli;
/**
- * This class defines a number of constants used in one or more Directory Server
- * tools.
+ * This class defines a number of constants used by tools.
*/
public final class CliConstants {
- /**
- * The name of the SASL property that can be used to provide the
- * authentication ID for the bind.
- */
- public static final String SASL_PROPERTY_AUTHID = "authid";
- /**
- * The name of the SASL property that can be used to provide the
- * authorization ID for the bind.
- */
- public static final String SASL_PROPERTY_AUTHZID = "authzid";
+ /** Default value for incrementing port number. */
+ public static final int PORT_INCREMENT = 1000;
- /**
- * The name of the SASL property that can be used to provide the digest URI
- * for the bind.
- */
- public static final String SASL_PROPERTY_DIGEST_URI = "digest-uri";
+ /** Default port number for the LDAP port. */
+ public static final int DEFAULT_LDAP_PORT = 389;
- /**
- * The name of the SASL property that can be used to provide the KDC for use
- * in Kerberos authentication.
- */
- public static final String SASL_PROPERTY_KDC = "kdc";
+ /** Default port number for the LDAPS port. */
+ public static final int DEFAULT_LDAPS_PORT = 1636;
- /**
- * The name of the SASL property that can be used to provide the quality of
- * protection for the bind.
- */
- public static final String SASL_PROPERTY_QOP = "qop";
+ /** Default port number for the administrator port. */
+ public static final int DEFAULT_ADMIN_PORT = 1444;
- /**
- * The name of the SASL property that can be used to provide the realm for
- * the bind.
- */
- public static final String SASL_PROPERTY_REALM = "realm";
+ /** Default port number for the SSL Connection. */
+ public static final int DEFAULT_SSL_PORT = 636;
- /**
- * The name of the SASL property that can be used to provide trace
- * information for a SASL ANONYMOUS request.
- */
- public static final String SASL_PROPERTY_TRACE = "trace";
+ /** Default port number for the JMX Connection handler. */
+ public static final int DEFAULT_JMX_PORT = 1689;
- /**
- * The name of the SASL property that can be used to provide the SASL
- * mechanism to use.
- */
- public static final String SASL_PROPERTY_MECH = "mech";
+ /** Default port number for the HTTP Connection handler. */
+ public static final int DEFAULT_HTTP_PORT = 8080;
- /**
- * The name of the opendj configuration direction in the user home
- * directory.
- */
- public static final String DEFAULT_OPENDJ_CONFIG_DIR = ".opendj";
+ /** Default port number for the SNMP Connection handler. */
+ public static final int DEFAULT_SNMP_PORT = 161;
- /**
- * The default properties file name.
- */
- public static final String DEFAULT_OPENDJ_PROPERTIES_FILE_NAME = "tools";
-
- /**
- * The default properties file extension.
- */
- public static final String DEFAULT_OPENDJ_PROPERTIES_FILE_EXTENSION = ".properties";
-
- /**
- * The value for the short option batchFilePath.
- */
- public static final char OPTION_SHORT_BATCH_FILE_PATH = 'F';
-
- /**
- * The value for the long option batchFilePath .
- */
- public static final String OPTION_LONG_BATCH_FILE_PATH = "batchFilePath";
-
- /**
- * The value for the short option host name.
- */
- public static final char OPTION_SHORT_HOST = 'h';
-
- /**
- * The value for the long option host name.
- */
- public static final String OPTION_LONG_HOST = "hostname";
-
- /**
- * The value for the short option port.
- */
- public static final char OPTION_SHORT_PORT = 'p';
-
- /**
- * The value for the long option port.
- */
- public static final String OPTION_LONG_PORT = "port";
-
- /**
- * The value for the short option useSSL.
- */
- public static final char OPTION_SHORT_USE_SSL = 'Z';
-
- /**
- * The value for the long option useSSL.
- */
- public static final String OPTION_LONG_USE_SSL = "useSSL";
-
- /**
- * The value for the short option baseDN.
- */
- public static final char OPTION_SHORT_BASEDN = 'b';
-
- /**
- * The value for the long option baseDN.
- */
- public static final String OPTION_LONG_BASEDN = "baseDN";
-
- /**
- * The value for the short option bindDN.
- */
- public static final char OPTION_SHORT_BINDDN = 'D';
-
- /**
- * The value for the long option bindDN.
- */
- public static final String OPTION_LONG_BINDDN = "bindDN";
-
- /**
- * The value for the short option bindPassword.
- */
- public static final char OPTION_SHORT_BINDPWD = 'w';
-
- /**
- * The value for the long option bindPassword.
- */
- public static final String OPTION_LONG_BINDPWD = "bindPassword";
-
- /**
- * The value for the short option bindPasswordFile.
- */
- public static final char OPTION_SHORT_BINDPWD_FILE = 'j';
-
- /**
- * The value for the long option bindPasswordFile.
- */
- public static final String OPTION_LONG_BINDPWD_FILE = "bindPasswordFile";
-
- /**
- * The value for the short option compress.
- */
- public static final char OPTION_SHORT_COMPRESS = 'c';
-
- /**
- * The value for the long option compress.
- */
- public static final String OPTION_LONG_COMPRESS = "compress";
-
- /**
- * The value for the short option filename.
- */
- public static final char OPTION_SHORT_FILENAME = 'f';
-
- /**
- * The value for the long option filename.
- */
- public static final String OPTION_LONG_FILENAME = "filename";
-
- /**
- * The value for the short option ldifFile.
- */
- public static final char OPTION_SHORT_LDIF_FILE = 'l';
-
- /**
- * The value for the long option ldifFile.
- */
- public static final String OPTION_LONG_LDIF_FILE = "ldifFile";
-
- /**
- * The value for the short option useStartTLS.
- */
- public static final char OPTION_SHORT_START_TLS = 'q';
-
- /**
- * The value for the long option useStartTLS.
- */
- public static final String OPTION_LONG_START_TLS = "useStartTLS";
-
- /**
- * The value for the short option randomSeed.
- */
- public static final char OPTION_SHORT_RANDOM_SEED = 's';
-
- /**
- * The value for the long option randomSeed.
- */
- public static final String OPTION_LONG_RANDOM_SEED = "randomSeed";
-
- /**
- * The value for the short option keyStorePath.
- */
- public static final char OPTION_SHORT_KEYSTOREPATH = 'K';
-
- /**
- * The value for the long option keyStorePath.
- */
- public static final String OPTION_LONG_KEYSTOREPATH = "keyStorePath";
-
- /**
- * The value for the short option trustStorePath.
- */
- public static final char OPTION_SHORT_TRUSTSTOREPATH = 'P';
-
- /**
- * The value for the long option trustStorePath.
- */
- public static final String OPTION_LONG_TRUSTSTOREPATH = "trustStorePath";
-
- /**
- * The value for the short option keyStorePassword.
- */
- public static final char OPTION_SHORT_KEYSTORE_PWD = 'W';
-
- /**
- * The value for the long option keyStorePassword.
- */
- public static final String OPTION_LONG_KEYSTORE_PWD = "keyStorePassword";
-
- /**
- * The value for the short option trustStorePassword.
- */
- public static final char OPTION_SHORT_TRUSTSTORE_PWD = 'T';
-
- /**
- * The value for the long option trustStorePassword.
- */
- public static final String OPTION_LONG_TRUSTSTORE_PWD = "trustStorePassword";
-
- /**
- * The value for the short option keyStorePasswordFile .
- */
- public static final char OPTION_SHORT_KEYSTORE_PWD_FILE = 'u';
-
- /**
- * The value for the long option keyStorePasswordFile .
- */
- public static final String OPTION_LONG_KEYSTORE_PWD_FILE = "keyStorePasswordFile";
-
- /**
- * The value for the short option keyStorePasswordFile .
- */
- public static final char OPTION_SHORT_TRUSTSTORE_PWD_FILE = 'U';
-
- /**
- * The value for the long option keyStorePasswordFile .
- */
- public static final String OPTION_LONG_TRUSTSTORE_PWD_FILE = "trustStorePasswordFile";
-
- /**
- * The value for the short option trustAll .
- */
- public static final char OPTION_SHORT_TRUSTALL = 'X';
-
- /**
- * The value for the long option trustAll .
- */
- public static final String OPTION_LONG_TRUSTALL = "trustAll";
-
- /**
- * The value for the short option certNickname .
- */
- public static final char OPTION_SHORT_CERT_NICKNAME = 'N';
-
- /**
- * The value for the long option certNickname .
- */
- public static final String OPTION_LONG_CERT_NICKNAME = "certNickname";
-
- /**
- * The value for the long option assertionFilter .
- */
- public static final String OPTION_LONG_ASSERTION_FILE = "assertionFilter";
-
- /**
- * The value for the short option dry-run.
- */
- public static final char OPTION_SHORT_DRYRUN = 'n';
-
- /**
- * The value for the long option dry-run.
- */
- public static final String OPTION_LONG_DRYRUN = "dry-run";
-
- /**
- * The value for the short option help.
- */
- public static final char OPTION_SHORT_HELP = 'H';
-
- /**
- * The value for the long option help.
- */
- public static final String OPTION_LONG_HELP = "help";
-
- /**
- * The value for the long option cli.
- */
- public static final String OPTION_LONG_CLI = "cli";
-
- /**
- * The value for the short option cli.
- */
- public static final char OPTION_SHORT_CLI = 'i';
-
- /**
- * The value for the short option proxyAs.
- */
- public static final char OPTION_SHORT_PROXYAUTHID = 'Y';
-
- /**
- * The value for the long option proxyAs.
- */
- public static final String OPTION_LONG_PROXYAUTHID = "proxyAs";
-
- /**
- * The value for the short option saslOption.
- */
- public static final char OPTION_SHORT_SASLOPTION = 'o';
-
- /**
- * The value for the long option saslOption.
- */
- public static final String OPTION_LONG_SASLOPTION = "saslOption";
-
- /**
- * The value for the short option geteffectiverights control authzid.
- */
- public static final char OPTION_SHORT_EFFECTIVERIGHTSUSER = 'g';
-
- /**
- * The value for the long option geteffectiverights control authzid.
- */
- public static final String OPTION_LONG_EFFECTIVERIGHTSUSER = "getEffectiveRightsAuthzid";
-
- /**
- * The value for the short option geteffectiveights control attributes.
- */
- public static final char OPTION_SHORT_EFFECTIVERIGHTSATTR = 'e';
-
- /**
- * The value for the long option geteffectiverights control specific
- * attribute list.
- */
- public static final String OPTION_LONG_EFFECTIVERIGHTSATTR = "getEffectiveRightsAttribute";
-
- /**
- * The value for the short option protocol version attributes.
- */
- public static final char OPTION_SHORT_PROTOCOL_VERSION = 'V';
-
- /**
- * The value for the long option protocol version attribute.
- */
- public static final String OPTION_LONG_PROTOCOL_VERSION = "ldapVersion";
-
- /**
- * The value for the long option version.
- */
- public static final char OPTION_SHORT_PRODUCT_VERSION = 'V';
-
- /**
- * The value for the long option version.
- */
- public static final String OPTION_LONG_PRODUCT_VERSION = "version";
-
- /**
- * The value for the short option description attributes.
- */
- public static final char OPTION_SHORT_DESCRIPTION = 'd';
-
- /**
- * The value for the long option description attribute.
- */
- public static final String OPTION_LONG_DESCRIPTION = "description";
-
- /**
- * The value for the short option groupName attributes.
- */
- public static final char OPTION_SHORT_GROUPNAME = 'g';
-
- /**
- * The value for the long option groupName attribute.
- */
- public static final String OPTION_LONG_GROUPNAME = "groupName";
-
- /**
- * The value for the short option newGroupName attribute.
- */
- public static final char OPTION_SHORT_NEWGROUPNAME = 'n';
-
- /**
- * The value for the long option groupName attribute.
- */
- public static final String OPTION_LONG_NEWGROUPNAME = "newGroupName";
-
- /**
- * The value for the short option member-name attributes.
- */
- public static final char OPTION_SHORT_MEMBERNAME = 'm';
-
- /**
- * The value for the long member-name version attribute.
- */
- public static final String OPTION_LONG_MEMBERNAME = "memberName";
-
- /**
- * The value for the short option serverID attributes.
- */
- public static final String OPTION_SHORT_SERVERID = null;
-
- /**
- * The value for the long option serverID attribute.
- */
- public static final String OPTION_LONG_SERVERID = "serverID";
-
- /**
- * The value for the short option userID attributes.
- */
- public static final String OPTION_SHORT_USERID = null;
-
- /**
- * The value for the long option userID attribute.
- */
- public static final String OPTION_LONG_USERID = "userID";
-
- /**
- * The value for the short option set.
- */
- public static final Character OPTION_SHORT_SET = null;
-
- /**
- * The value for the long option set.
- */
- public static final String OPTION_LONG_SET = "set";
-
- /**
- * Value for the quiet option short form.
- */
- public static final Character OPTION_SHORT_QUIET = 'Q';
-
- /**
- * Value for the quiet option long form.
- */
- public static final String OPTION_LONG_QUIET = "quiet";
-
- /**
- * Value for non-interactive session short form.
- */
- public static final Character OPTION_SHORT_NO_PROMPT = 'n';
-
- /**
- * Value for non-interactive session long form.
- */
- public static final String OPTION_LONG_NO_PROMPT = "no-prompt";
-
- /**
- * Long form of script friendly option.
- */
- public static final String OPTION_LONG_SCRIPT_FRIENDLY = "script-friendly";
-
- /**
- * Short form of script friendly option.
- */
- public static final Character OPTION_SHORT_SCRIPT_FRIENDLY = 's';
-
- /**
- * Value for verbose option short form.
- */
- public static final Character OPTION_SHORT_VERBOSE = 'v';
-
- /**
- * Value for verbose option long form.
- */
- public static final String OPTION_LONG_VERBOSE = "verbose";
-
- /**
- * The value for the long option propertiesFilePAth .
- */
- public static final String OPTION_LONG_PROP_FILE_PATH = "propertiesFilePath";
-
- /**
- * The value for the long option propertiesFilePAth .
- */
- public static final String OPTION_LONG_NO_PROP_FILE = "noPropertiesFile";
-
- /**
- * Long form of referenced host name.
- */
- public static final String OPTION_LONG_REFERENCED_HOST_NAME = "referencedHostName";
-
- /**
- * Long form of admin UID.
- */
- public static final String OPTION_LONG_ADMIN_UID = "adminUID";
-
- /**
- * Long form of report authorization ID connection option.
- */
- public static final String OPTION_LONG_REPORT_AUTHZ_ID = "reportAuthzID";
-
- /**
- * Long form of use password policy control connection option.
- */
- public static final String OPTION_LONG_USE_PW_POLICY_CTL = "usePasswordPolicyControl";
-
- /**
- * Long form of use SASL external connection option.
- */
- public static final String OPTION_LONG_USE_SASL_EXTERNAL = "useSASLExternal";
-
- /**
- * Long form of option for the command-line encoding option.
- */
- public static final String OPTION_LONG_ENCODING = "encoding";
-
- /**
- * Long form of option specifying no wrapping of the command-line.
- */
- public static final String OPTION_LONG_DONT_WRAP = "dontWrap";
-
- /**
- * The value for the long option targetDN.
- */
- public static final String OPTION_LONG_TARGETDN = "targetDN";
-
- /**
- * Long form of email notification upon completion option.
- */
- public static final String OPTION_LONG_COMPLETION_NOTIFICATION_EMAIL = "completionNotify";
-
- /**
- * Short form of email notification upon completion option.
- */
- public static final Character OPTION_SHORT_COMPLETION_NOTIFICATION_EMAIL = null;
-
- /**
- * Long form of email notification upon error option.
- */
- public static final String OPTION_LONG_ERROR_NOTIFICATION_EMAIL = "errorNotify";
-
- /**
- * Short form of email notification upon error option.
- */
- public static final Character OPTION_SHORT_ERROR_NOTIFICATION_EMAIL = null;
-
- /**
- * Long form of dependency option.
- */
- public static final String OPTION_LONG_DEPENDENCY = "dependency";
-
- /**
- * Short form of dependency option.
- */
- public static final Character OPTION_SHORT_DEPENDENCY = null;
-
- /**
- * Long form of failed dependency action option.
- */
- public static final String OPTION_LONG_FAILED_DEPENDENCY_ACTION = "failedDependencyAction";
-
- /**
- * Short form of failed dependency action option.
- */
- public static final Character OPTION_SHORT_FAILED_DEPENDENCY_ACTION = null;
-
- /**
- * The default separator to be used in tables.
- */
- public static final String LIST_TABLE_SEPARATOR = ":";
-
- /**
- *
- * The value for the short option output LDIF filename.
- */
- public static final char OPTION_SHORT_OUTPUT_LDIF_FILENAME = 'o';
-
- /**
- * The value for the long option output LDIF filename.
- */
- public static final String OPTION_LONG_OUTPUT_LDIF_FILENAME = "outputLDIF";
-
- /**
- * The value for the long option to automatically accept the license
- * if present.
- */
- public static final String OPTION_LONG_ACCEPT_LICENSE = "acceptLicense";
-
- /**
- * The value for the short option rootUserDN.
- */
- public static final char OPTION_SHORT_ROOT_USER_DN = 'D';
-
- /**
- * The value for the long option rootUserDN.
- */
- public static final String OPTION_LONG_ROOT_USER_DN = "rootUserDN";
+ /** Default name of root user DN. */
+ public static final String DEFAULT_ROOT_USER_DN = "cn=Directory Manager";
- /**
- * The value for the long option connect timeout attribute.
- */
- public static final String OPTION_LONG_CONNECT_TIMEOUT = "connectTimeout";
// Prevent instantiation.
private CliConstants() {
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
index afddced..e57d835 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -25,8 +25,8 @@
*/
package com.forgerock.opendj.cli;
-import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.cli.CliMessages.*;
+import static com.forgerock.opendj.cli.ArgumentConstants.*;
/**
* This class regroup commons arguments used by the different CLI.
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
index 2ca9dcf..12e753a 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -28,6 +28,7 @@
import static com.forgerock.opendj.util.StaticUtils.toLowerCase;
import static com.forgerock.opendj.util.StaticUtils.EOL;
+import static com.forgerock.opendj.cli.ArgumentConstants.*;
import java.io.IOException;
import java.io.OutputStream;
@@ -46,7 +47,6 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import static com.forgerock.opendj.cli.CliMessages.*;
-import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
/**
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
index bf537fa..c1cbd2e 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -32,6 +32,8 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.StringTokenizer;
import org.forgerock.i18n.LocalizableMessage;
@@ -44,11 +46,6 @@
static public final String LINE_SEPARATOR = System.getProperty("line.separator");
/**
- * The name of a command-line script used to launch a tool.
- */
- public static final String PROPERTY_SCRIPT_NAME = "com.forgerock.opendj.ldap.tools.scriptName";
-
- /**
* The column at which to wrap long lines of output in the command-line
* tools.
*/
@@ -346,6 +343,28 @@
}
}
+ /**
+ * Returns the default host name.
+ *
+ * @return The default host name or empty string if the host name cannot be resolved.
+ */
+ public static String getDefaultHostName() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ // Fails.
+ }
+ String host = System.getenv("COMPUTERNAME"); // Windows.
+ if (host != null) {
+ return host;
+ }
+ host = System.getenv("HOSTNAME"); // Unix.
+ if (host != null) {
+ return host;
+ }
+ return "";
+ }
+
// Prevent instantiation.
private Utils() {
// Do nothing.
--
Gitblit v1.10.0