Class SecureConnectionCliArgs


  • public final class SecureConnectionCliArgs
    extends Object
    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.
    • Constructor Detail

      • SecureConnectionCliArgs

        public SecureConnectionCliArgs​(boolean alwaysUseSSL)
        Creates a new instance of secure arguments.
        Parameters:
        alwaysUseSSL - Whether to always use the SSL connection type. In this case, the arguments useSSL and startTLS are not present.
    • Method Detail

      • argumentsPresent

        public boolean argumentsPresent()
        Indicates whether any of the arguments are present.
        Returns:
        boolean where true indicates that at least one of the arguments is present
      • getAdministratorUID

        public String getAdministratorUID()
        Get the admin UID which has to be used for the command.
        Returns:
        The admin UID specified by the command line argument, or the default value, if not specified.
      • 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.
      • createGlobalArguments

        public Set<Argument> createGlobalArguments()
                                            throws ArgumentException
        Initialize Global option.
        Returns:
        a new set holding the options created. Callers may add their own arguments to it: the set is a copy, so doing so does not add them to the connection arguments this object reports through argumentsPresent().
        Throws:
        ArgumentException - If there is a problem with any of the parameters used to create this argument.
      • 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.
      • getDefaultHostName

        public String getDefaultHostName()
        Returns the current hostname. If the hostname resolution fails, this method returns "localhost".
        Returns:
        the current hostname
      • 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.
      • alwaysUseSsl

        public boolean alwaysUseSsl()
        Indicate if the SSL mode is always used.
        Returns:
        True if SSL mode is always used.
      • getTrustManager

        public ApplicationTrustManager getTrustManager()
        Handle TrustStore.
        Returns:
        The trustStore manager to be used for the command.
      • getTruststoreFileFromConfig

        public String getTruststoreFileFromConfig()
                                           throws ConfigException
        Returns the absolute path of the trust store file that appears on the config. Returns null if the trust store is not defined or it does not exist.
        Returns:
        the absolute path of the trust store file that appears on the config.
        Throws:
        ConfigException - if there is an error reading the configuration.
      • getAdminPortFromConfig

        public int getAdminPortFromConfig()
                                   throws ConfigException
        Returns the admin port from the configuration.
        Returns:
        the admin port from the configuration.
        Throws:
        ConfigException - if an error occurs reading the configuration.
      • getPortFromConfig

        public int getPortFromConfig()
        Returns the port to be used according to the configuration and the arguments provided by the user. This method should be called after the arguments have been parsed.
        Returns:
        the port to be used according to the configuration and the arguments provided by the user.
      • initArgumentsWithConfiguration

        public void initArgumentsWithConfiguration​(ArgumentParser parser)
        Updates the default values of the port and the trust store with what is read in the configuration.
        Parameters:
        parser - The argument parser where the secure connection arguments were added.
      • createVisibleAdminUidArgument

        public void createVisibleAdminUidArgument​(org.forgerock.i18n.LocalizableMessage description)
        Replace the admin UID argument by a non hidden one.
        Parameters:
        description - The localized description for the non hidden admin UID argument.
      • getKeyStorePathArg

        public StringArgument getKeyStorePathArg()
        Return the 'keyStore' global argument.
        Returns:
        The 'keyStore' global argument.
      • getHostNameArg

        public StringArgument getHostNameArg()
        Return the 'hostName' global argument.
        Returns:
        The 'hostName' global argument.
      • getPortArg

        public IntegerArgument getPortArg()
        Return the 'port' global argument.
        Returns:
        The 'port' global argument.
      • getBindDnArg

        public StringArgument getBindDnArg()
        Return the 'bindDN' global argument.
        Returns:
        The 'bindDN' global argument.
      • getAdminUidArg

        public StringArgument getAdminUidArg()
        Return the 'adminUID' global argument.
        Returns:
        The 'adminUID' global argument.
      • getBindPasswordFileArg

        public FileBasedArgument getBindPasswordFileArg()
        Return the 'bindPasswordFile' global argument.
        Returns:
        The 'bindPasswordFile' global argument.
      • getBindPasswordArg

        public StringArgument getBindPasswordArg()
        Return the 'bindPassword' global argument.
        Returns:
        The 'bindPassword' global argument.
      • getTrustAllArg

        public BooleanArgument getTrustAllArg()
        Return the 'trustAllArg' global argument.
        Returns:
        The 'trustAllArg' global argument.
      • getTrustStorePathArg

        public StringArgument getTrustStorePathArg()
        Return the 'trustStore' global argument.
        Returns:
        The 'trustStore' global argument.
      • getTrustStorePasswordArg

        public StringArgument getTrustStorePasswordArg()
        Return the 'trustStorePassword' global argument.
        Returns:
        The 'trustStorePassword' global argument.
      • getTrustStorePasswordFileArg

        public FileBasedArgument getTrustStorePasswordFileArg()
        Return the 'trustStorePasswordFile' global argument.
        Returns:
        The 'trustStorePasswordFile' global argument.
      • getKeyStorePasswordArg

        public StringArgument getKeyStorePasswordArg()
        Return the 'keyStorePassword' global argument.
        Returns:
        The 'keyStorePassword' global argument.
      • getKeyStorePasswordFileArg

        public FileBasedArgument getKeyStorePasswordFileArg()
        Return the 'keyStorePasswordFile' global argument.
        Returns:
        The 'keyStorePasswordFile' global argument.
      • getCertNicknameArg

        public StringArgument getCertNicknameArg()
        Return the 'certNicknameArg' global argument.
        Returns:
        The 'certNicknameArg' global argument.
      • getUseSSLArg

        public BooleanArgument getUseSSLArg()
        Return the 'useSSLArg' global argument.
        Returns:
        The 'useSSLArg' global argument.
      • getUseStartTLSArg

        public BooleanArgument getUseStartTLSArg()
        Return the 'useStartTLSArg' global argument.
        Returns:
        The 'useStartTLSArg' global argument.
      • getSaslOptionArg

        public StringArgument getSaslOptionArg()
        Return the 'saslOption' argument.
        Returns:
        the 'saslOption' argument.
      • getConnectTimeoutArg

        public IntegerArgument getConnectTimeoutArg()
        Return the 'connectTimeout' argument.
        Returns:
        the 'connectTimeout' argument.
      • setBindDnArgDescription

        public void setBindDnArgDescription​(org.forgerock.i18n.LocalizableMessage description)
        Set the bind DN argument with the provided description. Note that this method will create a new Argument instance replacing the current one.
        Parameters:
        description - The localized description which will be used in help messages.
      • setBindPasswordArgument

        public void setBindPasswordArgument​(StringArgument bindPasswordArg)
        Set the bind password argument.
        Parameters:
        bindPasswordArg - The argument which will replace the current one.
      • setBindPasswordFileArgument

        public void setBindPasswordFileArgument​(FileBasedArgument bindPasswordFileArg)
        Set the bind password file argument.
        Parameters:
        bindPasswordFileArg - The argument which will replace the current one.