Class 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.
    • 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 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
        alwaysSSL - 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 messages
        err - 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 arguments
        ArgumentException - if there was a problem processing 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