Package org.opends.server.util.cli
Class LDAPConnectionArgumentParser
- java.lang.Object
-
- com.forgerock.opendj.cli.ArgumentParser
-
- org.opends.server.util.cli.LDAPConnectionArgumentParser
-
- All Implemented Interfaces:
ToolRefDocContainer
public class LDAPConnectionArgumentParser extends ArgumentParser
Creates an argument parser pre-populated with arguments for specifying information for opening and LDAPConnection an LDAP connection.
-
-
Field Summary
-
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 Constructor Description LDAPConnectionArgumentParser(String mainClassName, org.forgerock.i18n.LocalizableMessage toolDescription, boolean longArgumentsCaseSensitive, ArgumentGroup argumentGroup, boolean alwaysSSL)Creates a new instance of this argument parser with no arguments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LDAPConnectionconnect(PrintStream out, 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.LDAPConnectionconnect(LDAPConnectionConsoleInteraction ui, PrintStream out, PrintStream err)Creates a connection using a console interaction that will be used to potentially interact with the user to prompt for necessary information for establishing the connection.SecureConnectionCliArgsgetArguments()Gets the arguments associated with this parser.static StringgetPasswordValue(StringArgument bindPwdArg, FileBasedArgument bindPwdFileArg, StringArgument bindDnArg, PrintStream out, PrintStream err)Commodity method that retrieves the password value analyzing the contents of a string argument and of a file based argument.static StringgetPasswordValue(StringArgument bindPassword, FileBasedArgument bindPasswordFile, String bindDNValue, PrintStream out, PrintStream err)Commodity method that retrieves the password value analyzing the contents of a string argument and of a file based argument.-
Methods inherited from class com.forgerock.opendj.cli.ArgumentParser
addArgument, addArgument, addDefaultArgument, addLdapConnectionArgument, displayMessageAndUsageReference, getArgumentForLongID, getArgumentList, getBindPassword, getDocSubcommandsDescriptionSupplement, getDocToolDescriptionSupplement, getHelpUsageReference, getOptionsRefSect1, getShortToolDescription, getTrailingArguments, getUsage, isUsageArgumentPresent, isVersionArgumentPresent, parseArguments, parseArguments, parseArguments, replaceArgument, setDocSubcommandsDescriptionSupplement, setDocToolDescriptionSupplement, setFilePropertiesArgument, setNoPropertiesFileArgument, setShortToolDescription, setUsageArgument, setUsageArgument, setUsageOrVersionDisplayed, setVersionHandler, usageOrVersionDisplayed
-
-
-
-
Constructor Detail
-
LDAPConnectionArgumentParser
public LDAPConnectionArgumentParser(String mainClassName, org.forgerock.i18n.LocalizableMessage toolDescription, boolean longArgumentsCaseSensitive, ArgumentGroup argumentGroup, boolean alwaysSSL)
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 shouldargumentGroup- Group to which LDAP arguments will be added to the parser. May be null to indicate that arguments should be added to the default groupalwaysSSL- If true, always use the SSL connection type. In this case, the arguments useSSL and startTLS are not present.
-
-
Method Detail
-
connect
public LDAPConnection connect(PrintStream out, 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 messageserr- stream to write error 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 argumentsArgumentException- if there was a problem processing the input arguments
-
connect
public LDAPConnection connect(LDAPConnectionConsoleInteraction ui, PrintStream out, PrintStream err) throws LDAPConnectionException, SSLConnectionException, ArgumentException
Creates a connection using a console interaction that will be used to potentially interact with the user to prompt for necessary information for establishing the connection.- Parameters:
ui- user interaction for prompting the userout- stream to write messageserr- stream to write error messages- Returns:
- LDAPConnection created by this class from parsed arguments
- Throws:
SSLConnectionException- if there was a problem connecting with SSL to the serverLDAPConnectionException- if there was any other problem connecting to the serverArgumentException- if there was a problem indicated by the input arguments
-
getArguments
public SecureConnectionCliArgs getArguments()
Gets the arguments associated with this parser.- Returns:
- arguments for this parser.
-
getPasswordValue
public static String getPasswordValue(StringArgument bindPwdArg, FileBasedArgument bindPwdFileArg, StringArgument bindDnArg, PrintStream out, PrintStream err)
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. If the string is a dash, or no password is available, it will prompt for it on the command line.- Parameters:
bindPwdArg- the string argument for the password.bindPwdFileArg- the file based argument for the password.bindDnArg- the string argument for the bindDN.out- stream to write message.err- stream to write error message.- Returns:
- the password value.
-
getPasswordValue
public static String getPasswordValue(StringArgument bindPassword, FileBasedArgument bindPasswordFile, String bindDNValue, PrintStream out, PrintStream err) throws ClientException
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. If the string is a dash, or no password is available, it will prompt for it on the command line.- Parameters:
bindPassword- the string argument for the password.bindPasswordFile- the file based argument for the password.bindDNValue- the string value for the bindDN.out- stream to write message.err- stream to write error message.- Returns:
- the password value.
- Throws:
ClientException- if the password cannot be read
-
-