org.opends.server.admin.client.cli
Class SecureConnectionCliParser

java.lang.Object
  extended by org.opends.server.util.args.ArgumentParser
      extended by org.opends.server.util.args.SubCommandArgumentParser
          extended by org.opends.server.admin.client.cli.SecureConnectionCliParser
Direct Known Subclasses:
DsFrameworkCliParser

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
static java.lang.String EOL
          End Of Line.
protected  BooleanArgument noPropertiesFileArg
          The argument which should be used to indicate that we will not look for properties file.
protected  StringArgument propertiesFileArg
          Argument indicating a properties file argument.
protected  SecureConnectionCliArgs secureArgsList
          The secure args list object.
protected  BooleanArgument showUsageArg
          The showUsage' global argument.
protected  BooleanArgument verboseArg
          The 'verbose' global argument.
 
Fields inherited from class org.opends.server.util.args.ArgumentParser
argumentGroups, defaultArgGroup, generalArgGroup, ioArgGroup, ldapArgGroup
 
Constructor Summary
protected SecureConnectionCliParser(java.lang.String mainClassName, Message toolDescription, boolean longArgumentsCaseSensitive)
          Creates a new instance of this argument parser with no arguments.
 
Method Summary
protected  java.util.LinkedHashSet<Argument> createGlobalArguments(java.io.OutputStream outStream)
          Initialize Global option.
 java.lang.String getAdministratorUID()
          Returns the Administrator UID provided in the command-line.
 java.lang.String getBindDN()
          Get the bindDN which has to be used for the command.
 java.lang.String getBindPassword()
          Get the password which has to be used for the command without prompting the user.
 java.lang.String getBindPassword(StringArgument clearArg, FileBasedArgument fileArg)
          Get the password which has to be used for the command without prompting the user.
 java.lang.String getBindPassword(java.lang.String dn, java.io.OutputStream out, java.io.OutputStream err)
          Get the password which has to be used for the command.
protected  java.lang.String getBindPassword(java.lang.String dn, java.io.OutputStream out, java.io.OutputStream err, StringArgument clearArg, FileBasedArgument fileArg)
          Get the password which has to be used for the command.
 java.lang.String getHostName()
          Get the host name which has to be used for the command.
 javax.net.ssl.KeyManager getKeyManager()
          Handle KeyStore.
 java.lang.String getPort()
          Get the port which has to be used for the command.
 ApplicationTrustManager getTrustManager()
          Handle TrustStore.
protected  void initializeGlobalArguments(java.util.Collection<Argument> args)
          Initialize the global options with the provided set of arguments.
protected  void initializeGlobalArguments(java.util.Collection<Argument> args, ArgumentGroup argGroup)
          Initialize the global options with the provided set of arguments.
 boolean isVerbose()
          Indicate if the verbose mode is required.
 boolean useSSL()
          Indicate if the SSL mode is required.
 boolean useStartTLS()
          Indicate if the startTLS mode is required.
 int validateGlobalOptions(MessageBuilder buf)
          Indication if provided global options are validate.
 int validateGlobalOptions(java.io.PrintStream err)
          Indication if provided global options are validate.
 
Methods inherited from class org.opends.server.util.args.SubCommandArgumentParser
addGlobalArgument, addGlobalArgument, getGlobalArgument, getGlobalArgumentForLongID, getGlobalArgumentForShortID, getGlobalArgumentList, getGlobalArgumentsByLongID, getGlobalArgumentsByShortID, getHelpUsageReference, getMainClassName, getRawArguments, getSubCommand, getSubCommand, getSubCommands, getSubCommandUsage, getToolDescription, getTrailingArguments, getUsage, getUsage, hasGlobalArgument, hasGlobalArgumentWithLongID, hasGlobalArgumentWithShortID, hasSubCommand, isUsageArgumentPresent, isVersionArgumentPresent, longArgumentsCaseSensitive, parseArguments, parseArguments, parseArguments, removeGlobalArgument, setUsageArgument, setUsageGroupArgument, usageOrVersionDisplayed
 
Methods inherited from class org.opends.server.util.args.ArgumentParser
addArgument, addArgument, addDefaultArgument, addGeneralArgument, addInputOutputArgument, addLdapConnectionArgument, allowsTrailingArguments, checkExternalProperties, getArgument, getArgumentForLongID, getArgumentForShortID, getArgumentList, getArgumentsByLongID, getArgumentsByShortID, getMaxTrailingArguments, getMinTrailingArguments, getStandardGroup, getUsage, getUsageMessage, printUsageGroupHeaders, setDefaultArgumentGroupDescription, setFilePropertiesArgument, setGeneralArgumentGroupDescription, setInputOutputArgumentGroupDescription, setLdapArgumentGroupDescription, setNoPropertiesFileArgument, setUsageArgument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

showUsageArg

protected BooleanArgument showUsageArg
The showUsage' global argument.


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.


EOL

public static java.lang.String EOL
End Of Line.

Constructor Detail

SecureConnectionCliParser

protected SecureConnectionCliParser(java.lang.String mainClassName,
                                    Message 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 java.lang.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 java.lang.String getAdministratorUID()
Returns the Administrator UID provided in the command-line.

Returns:
the Administrator UID provided in the command-line.

getBindPassword

protected java.lang.String getBindPassword(java.lang.String dn,
                                           java.io.OutputStream out,
                                           java.io.OutputStream err,
                                           StringArgument clearArg,
                                           FileBasedArgument fileArg)
Get the password which has to be used for the command.

Parameters:
dn - The user DN for which to password could be asked.
out - The input stream to used if we have to prompt to the user.
err - The error stream to used if we have to prompt to the user.
clearArg - The password StringArgument argument.
fileArg - The password FileBased argument.
Returns:
The password stored into the specified file on by the command line argument, or prompts it if not specified.

getBindPassword

public java.lang.String getBindPassword(java.lang.String dn,
                                        java.io.OutputStream out,
                                        java.io.OutputStream err)
Get the password which has to be used for the command.

Parameters:
dn - The user DN for which to password could be asked.
out - The input stream to used if we have to prompt to the user.
err - The error stream to used if we have to prompt to the user.
Returns:
The password stored into the specified file on by the command line argument, or prompts it if not specified.

getBindPassword

public java.lang.String getBindPassword(StringArgument clearArg,
                                        FileBasedArgument fileArg)
Get the password which has to be used for the command without prompting the user. If no password was specified, return null.

Parameters:
clearArg - The password StringArgument argument.
fileArg - The password FileBased argument.
Returns:
The password stored into the specified file on by the command line argument, or null it if not specified.

getBindPassword

public java.lang.String getBindPassword()
Get 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 java.util.LinkedHashSet<Argument> createGlobalArguments(java.io.OutputStream outStream)
                                                           throws ArgumentException
Initialize Global option.

Parameters:
outStream - The output stream used for the usage.
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(java.util.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(java.util.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 java.lang.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 java.lang.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(MessageBuilder buf)
Indication if provided global options are validate.

Parameters:
buf - the MessageBuilder to write the error messages.
Returns:
return code.

validateGlobalOptions

public int validateGlobalOptions(java.io.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

useSSL

public boolean useSSL()
Indicate if the SSL mode is required.

Returns:
True if SSL mode is required

useStartTLS

public boolean useStartTLS()
Indicate if the startTLS mode is required.

Returns:
True if startTLS mode is required

getTrustManager

public ApplicationTrustManager getTrustManager()
Handle TrustStore.

Returns:
The trustStore manager to be used for the command.

getKeyManager

public javax.net.ssl.KeyManager getKeyManager()
Handle KeyStore.

Returns:
The keyStore manager to be used for the command.