org.opends.server.util.args
Class LDAPConnectionArgumentParser

java.lang.Object
  extended by org.opends.server.util.args.ArgumentParser
      extended by org.opends.server.util.args.LDAPConnectionArgumentParser

public class LDAPConnectionArgumentParser
extends ArgumentParser

Creates an argument parser pre-populated with arguments for specifying information for openning and LDAPConnection an LDAP connection.


Field Summary
 
Fields inherited from class org.opends.server.util.args.ArgumentParser
argumentGroups, defaultArgGroup, generalArgGroup, ioArgGroup, ldapArgGroup
 
Constructor Summary
LDAPConnectionArgumentParser(java.lang.String mainClassName, Message toolDescription, boolean longArgumentsCaseSensitive, ArgumentGroup argumentGroup)
          Creates a new instance of this argument parser with no arguments.
LDAPConnectionArgumentParser(java.lang.String mainClassName, Message toolDescription, boolean longArgumentsCaseSensitive, boolean allowsTrailingArguments, int minTrailingArguments, int maxTrailingArguments, java.lang.String trailingArgsDisplayName, ArgumentGroup argumentGroup)
          Creates a new instance of this argument parser with no arguments that may or may not be allowed to have unnamed trailing arguments.
 
Method Summary
 LDAPConnection connect(LDAPConnectionConsoleInteraction ui, java.io.PrintStream out, java.io.PrintStream err)
          Creates a connection using a console interaction that will be used to potientially interact with the user to prompt for necessary information for establishing the connection.
 LDAPConnection connect(java.io.PrintStream out, java.io.PrintStream err)
          Creates a new LDAPConnection and invokes a connect operation using information provided in the parsed set of arguments that were provided by the user.
 LDAPConnection connect(java.lang.String host, int port, java.lang.String bindDN, java.lang.String bindPw, LDAPConnectionOptions options, java.io.PrintStream out, java.io.PrintStream err)
          Creates a connection from information provided.
 boolean connectionArgumentsPresent()
          Indicates whether or not the user has indicated that they would like to perform a remote operation based on the arguments.
 SecureConnectionCliArgs getArguments()
          Gets the arguments associated with this parser.
static java.lang.String getPasswordValue(StringArgument bindPwdArg, FileBasedArgument bindPwdFileArg)
          Commodity method that retrieves the password value analyzing the contents of a string argument and of a file based argument.
 
Methods inherited from class org.opends.server.util.args.ArgumentParser
addArgument, addArgument, addDefaultArgument, addGeneralArgument, addInputOutputArgument, addLdapConnectionArgument, allowsTrailingArguments, checkExternalProperties, getArgument, getArgumentForLongID, getArgumentForShortID, getArgumentList, getArgumentsByLongID, getArgumentsByShortID, getMainClassName, getMaxTrailingArguments, getMinTrailingArguments, getRawArguments, getStandardGroup, getToolDescription, getTrailingArguments, getUsage, getUsage, getUsage, getUsageMessage, isUsageArgumentPresent, isVersionArgumentPresent, parseArguments, parseArguments, parseArguments, printUsageGroupHeaders, setDefaultArgumentGroupDescription, setFilePropertiesArgument, setGeneralArgumentGroupDescription, setInputOutputArgumentGroupDescription, setLdapArgumentGroupDescription, setNoPropertiesFileArgument, setUsageArgument, setUsageArgument, usageOrVersionDisplayed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPConnectionArgumentParser

public LDAPConnectionArgumentParser(java.lang.String mainClassName,
                                    Message toolDescription,
                                    boolean longArgumentsCaseSensitive,
                                    ArgumentGroup argumentGroup)
Creates a new instance of this argument parser with no arguments. Unnamed trailing arguments will not be allowed.

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 long arguments should
argumentGroup - Group to which LDAP arguments will be added to the parser. May be null to indicate that arguments should be added to the default group

LDAPConnectionArgumentParser

public LDAPConnectionArgumentParser(java.lang.String mainClassName,
                                    Message toolDescription,
                                    boolean longArgumentsCaseSensitive,
                                    boolean allowsTrailingArguments,
                                    int minTrailingArguments,
                                    int maxTrailingArguments,
                                    java.lang.String trailingArgsDisplayName,
                                    ArgumentGroup argumentGroup)
Creates a new instance of this argument parser with no arguments that may or may not be allowed to have unnamed trailing 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 long arguments should be treated in a case-sensitive manner.
allowsTrailingArguments - Indicates whether this parser allows unnamed trailing arguments to be provided.
minTrailingArguments - The minimum number of unnamed trailing arguments that must be provided. A value less than or equal to zero indicates that no minimum will be enforced.
maxTrailingArguments - The maximum number of unnamed trailing arguments that may be provided. A value less than or equal to zero indicates that no maximum will be enforced.
trailingArgsDisplayName - The display name that should be used as a placeholder for unnamed trailing arguments in the generated usage information.
argumentGroup - Group to which LDAP arguments will be added to the parser. May be null to indicate that arguments should be added to the default group
Method Detail

connectionArgumentsPresent

public boolean connectionArgumentsPresent()
Indicates whether or not the user has indicated that they would like to perform a remote operation based on the arguments.

Returns:
true if the user wants to perform a remote operation; false otherwise

connect

public LDAPConnection connect(java.io.PrintStream out,
                              java.io.PrintStream err)
                       throws LDAPConnectionException,
                              ArgumentException
Creates a new LDAPConnection and invokes a connect operation using information provided in the parsed set of arguments that were provided by the user.

Parameters:
out - stream to write messages
err - stream to write messages
Returns:
LDAPConnection created by this class from parsed arguments
Throws:
LDAPConnectionException - if there was a problem connecting to the server indicated by the input arguments
ArgumentException - if there was a problem processing the input arguments

connect

public LDAPConnection connect(LDAPConnectionConsoleInteraction ui,
                              java.io.PrintStream out,
                              java.io.PrintStream err)
                       throws LDAPConnectionException
Creates a connection using a console interaction that will be used to potientially interact with the user to prompt for necessary information for establishing the connection.

Parameters:
ui - user interaction for prompting the user
out - stream to write messages
err - stream to write messages
Returns:
LDAPConnection created by this class from parsed arguments
Throws:
LDAPConnectionException - if there was a problem connecting to the server indicated by the input arguments

connect

public LDAPConnection connect(java.lang.String host,
                              int port,
                              java.lang.String bindDN,
                              java.lang.String bindPw,
                              LDAPConnectionOptions options,
                              java.io.PrintStream out,
                              java.io.PrintStream err)
                       throws LDAPConnectionException
Creates a connection from information provided.

Parameters:
host - of the server
port - of the server
bindDN - with which to connect
bindPw - with which to connect
options - with which to connect
out - stream to write messages
err - stream to write messages
Returns:
LDAPConnection created by this class from parsed arguments
Throws:
LDAPConnectionException - if there was a problem connecting to the server indicated by the input arguments

getArguments

public SecureConnectionCliArgs getArguments()
Gets the arguments associated with this parser.

Returns:
arguments for this parser.

getPasswordValue

public static java.lang.String getPasswordValue(StringArgument bindPwdArg,
                                                FileBasedArgument bindPwdFileArg)
Commodity method that retrieves the password value analyzing the contents of a string argument and of a file based argument. It assumes that the arguments have already been parsed and validated.

Parameters:
bindPwdArg - the string argument.
bindPwdFileArg - the file based argument.
Returns:
the password value.