Class SecureConnectionCliParser
- java.lang.Object
-
- com.forgerock.opendj.cli.ArgumentParser
-
- com.forgerock.opendj.cli.SubCommandArgumentParser
-
- org.opends.server.admin.client.cli.SecureConnectionCliParser
-
- All Implemented Interfaces:
ToolRefDocContainer
- Direct Known Subclasses:
ReplicationCliArgumentParser,StatusCliArgumentParser,UninstallerArgumentParser
public abstract class SecureConnectionCliParser extends SubCommandArgumentParser
This is a commodity class that can be used to check the arguments required to establish a secure connection in the command line. It can be used to generate an ApplicationTrustManager object based on the options provided by the user in the command line.
-
-
Field Summary
Fields Modifier and Type Field Description protected BooleanArgumentnoPropertiesFileArgThe argument which should be used to indicate that we will not look for properties file.protected StringArgumentpropertiesFileArgArgument indicating a properties file argument.protected SecureConnectionCliArgssecureArgsListThe secure args list object.protected BooleanArgumentverboseArgThe 'verbose' global argument.-
Fields inherited from class com.forgerock.opendj.cli.ArgumentParser
argumentGroups, DEFAULT_OPENDJ_CONFIG_DIR, DEFAULT_OPENDJ_PROPERTIES_FILE_EXTENSION, DEFAULT_OPENDJ_PROPERTIES_FILE_NAME, ioArgGroup, PROPERTY_SCRIPT_NAME, PROPERTY_SCRIPT_NAME_LEGACY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSecureConnectionCliParser(String mainClassName, org.forgerock.i18n.LocalizableMessage toolDescription, boolean longArgumentsCaseSensitive)Creates a new instance of this argument parser with no arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<Argument>createGlobalArguments(OutputStream outStream, boolean alwaysSSL)Initialize Global option.StringgetAdministratorUID()Returns the Administrator UID provided in the command-line.StringgetBindDN()Get the bindDN which has to be used for the command.StringgetBindPassword()Gets the password which has to be used for the command without prompting the user.intgetConnectTimeout()Returns the timeout to be used to connect in milliseconds.StringgetHostName()Get the host name which has to be used for the command.StringgetPort()Get the port which has to be used for the command.ApplicationTrustManagergetTrustManager()Handle TrustStore.protected voidinitializeGlobalArguments(Collection<Argument> args)Initialize the global options with the provided set of arguments.protected voidinitializeGlobalArguments(Collection<Argument> args, ArgumentGroup argGroup)Initialize the global options with the provided set of arguments.booleanisVerbose()Indicate if the verbose mode is required.intvalidateGlobalOptions(PrintStream err)Indication if provided global options are validate.intvalidateGlobalOptions(org.forgerock.i18n.LocalizableMessageBuilder buf)Indication if provided global options are validate.-
Methods inherited from class com.forgerock.opendj.cli.SubCommandArgumentParser
addGlobalArgument, addGlobalArgument, addLdapConnectionArgument, getGlobalArgumentForLongID, getGlobalArgumentForShortID, getSubCommand, getSubCommand, getSubCommandUsage, getUsage, hasGlobalArgument, hasSubCommand, parseArguments, replaceArgument, setUsageArgument, setUsageGroupArgument, setUsageHandler
-
Methods inherited from class com.forgerock.opendj.cli.ArgumentParser
addArgument, addArgument, addDefaultArgument, displayMessageAndUsageReference, getArgumentForLongID, getArgumentList, getBindPassword, getDocSubcommandsDescriptionSupplement, getDocToolDescriptionSupplement, getHelpUsageReference, getOptionsRefSect1, getShortToolDescription, getTrailingArguments, isUsageArgumentPresent, isVersionArgumentPresent, parseArguments, parseArguments, setDocSubcommandsDescriptionSupplement, setDocToolDescriptionSupplement, setFilePropertiesArgument, setNoPropertiesFileArgument, setShortToolDescription, setUsageArgument, setUsageOrVersionDisplayed, setVersionHandler, usageOrVersionDisplayed
-
-
-
-
Field Detail
-
verboseArg
protected BooleanArgument verboseArg
The 'verbose' global argument.
-
secureArgsList
protected SecureConnectionCliArgs secureArgsList
The secure args list object.
-
propertiesFileArg
protected StringArgument propertiesFileArg
Argument indicating a properties file argument.
-
noPropertiesFileArg
protected BooleanArgument noPropertiesFileArg
The argument which should be used to indicate that we will not look for properties file.
-
-
Constructor Detail
-
SecureConnectionCliParser
protected SecureConnectionCliParser(String mainClassName, org.forgerock.i18n.LocalizableMessage toolDescription, boolean longArgumentsCaseSensitive)
Creates a new instance of this argument parser with no arguments.- Parameters:
mainClassName- The fully-qualified name of the Java class that should be invoked to launch the program with which this argument parser is associated.toolDescription- A human-readable description for the tool, which will be included when displaying usage information.longArgumentsCaseSensitive- Indicates whether subcommand and long argument names should be treated in a case-sensitive manner.
-
-
Method Detail
-
getBindDN
public String getBindDN()
Get the bindDN which has to be used for the command.- Returns:
- The bindDN specified by the command line argument, or the default value, if not specified.
-
getAdministratorUID
public String getAdministratorUID()
Returns the Administrator UID provided in the command-line.- Returns:
- the Administrator UID provided in the command-line.
-
getBindPassword
public String getBindPassword()
Gets the password which has to be used for the command without prompting the user. If no password was specified, return null.- Returns:
- The password stored into the specified file on by the command line argument, or null it if not specified.
-
createGlobalArguments
protected Set<Argument> createGlobalArguments(OutputStream outStream, boolean alwaysSSL) throws ArgumentException
Initialize Global option.- Parameters:
outStream- The output stream used for the usage.alwaysSSL- If true, always use the SSL connection type. In this case, the arguments useSSL and startTLS are not present.- Returns:
- a ArrayList with the options created.
- Throws:
ArgumentException- If there is a problem with any of the parameters used to create this argument.
-
initializeGlobalArguments
protected void initializeGlobalArguments(Collection<Argument> args) throws ArgumentException
Initialize the global options with the provided set of arguments.- Parameters:
args- the arguments to use to initialize the global options.- Throws:
ArgumentException- if there is a conflict with the provided arguments.
-
initializeGlobalArguments
protected void initializeGlobalArguments(Collection<Argument> args, ArgumentGroup argGroup) throws ArgumentException
Initialize the global options with the provided set of arguments.- Parameters:
args- the arguments to use to initialize the global options.argGroup- to which args will be added- Throws:
ArgumentException- if there is a conflict with the provided arguments.
-
getHostName
public String getHostName()
Get the host name which has to be used for the command.- Returns:
- The host name specified by the command line argument, or the default value, if not specified.
-
getPort
public String getPort()
Get the port which has to be used for the command.- Returns:
- The port specified by the command line argument, or the default value, if not specified.
-
validateGlobalOptions
public int validateGlobalOptions(org.forgerock.i18n.LocalizableMessageBuilder buf)
Indication if provided global options are validate.- Parameters:
buf- TheLocalizableMessageBuilderto write the error message.- Returns:
- return code.
-
validateGlobalOptions
public int validateGlobalOptions(PrintStream err)
Indication if provided global options are validate.- Parameters:
err- The stream to be used to print error message.- Returns:
- return code.
-
isVerbose
public boolean isVerbose()
Indicate if the verbose mode is required.- Returns:
- True if verbose mode is required
-
getTrustManager
public ApplicationTrustManager getTrustManager()
Handle TrustStore.- Returns:
- The trustStore manager to be used for the command.
-
getConnectTimeout
public int getConnectTimeout() throws IllegalStateExceptionReturns the timeout to be used to connect in milliseconds. The method must be called after parsing the arguments.- Returns:
- the timeout to be used to connect in milliseconds or
0if there is no timeout. - Throws:
IllegalStateException- if the method is called before parsing the arguments.
-
-