Class CommandCredentialSource.Builder

  • Enclosing class:
    CommandCredentialSource

    public static final class CommandCredentialSource.Builder
    extends Object
    A builder for a command credential source.
    • Method Detail

      • addCommand

        public CommandCredentialSource.Builder addCommand​(String commandString)
        Add a command string to the list of command strings.
        Parameters:
        commandString - the literal string to add (must not be null)
        Returns:
        this builder
      • addCommand

        public CommandCredentialSource.Builder addCommand​(Supplier<String> commandStringSupplier)
        Add a command string supplier result to the list of command strings. If the supplier returns null or an empty string, no string is added at that time. The supplier is evaluated every time a command is run.
        Parameters:
        commandStringSupplier - the string supplier to get the string from (must not be null)
        Returns:
        this builder
      • addCommand

        public CommandCredentialSource.Builder addCommand​(Consumer<Consumer<String>> consumer)
        Add a command string provider to the list of command strings. The provider can add multiple strings to the consumer that is provided to it. The provider must not provide null or empty strings.
        Parameters:
        consumer - the consumer which can provide the command strings to add (must not be null)
        Returns:
        this builder
      • addEnvironment

        public CommandCredentialSource.Builder addEnvironment​(String key,
                                                              String value)
        Add an environment value to the process environment.
        Parameters:
        key - the environment variable name (must not be null)
        value - the environment variable value (must not be null)
        Returns:
        this builder
      • addEnvironment

        public CommandCredentialSource.Builder addEnvironment​(Consumer<BiConsumer<String,​String>> consumer)
        Add multiple environment values to the process environment. The consumer is called once for every command execution.
        Parameters:
        consumer - a consumer which can provide key-value pairs to add to the environment (must not be null)
        Returns:
        this builder
      • removeEnvironment

        public CommandCredentialSource.Builder removeEnvironment​(String key)
        Remove an environment variable from the process environment.
        Parameters:
        key - the environment variable name (must not be null)
        Returns:
        this builder
      • setWorkingDirectory

        public CommandCredentialSource.Builder setWorkingDirectory​(File directory)
        Set the working directory of the target process.
        Parameters:
        directory - the directory (must not be null)
        Returns:
        this builder
      • setPasswordFactoryProvider

        public CommandCredentialSource.Builder setPasswordFactoryProvider​(Provider provider)
        Set the provider to use to find the password factory. If this method is not called, the default is used.
        Parameters:
        provider - the provider to use (must not be null)
        Returns:
        this builder
      • setOutputCharset

        public CommandCredentialSource.Builder setOutputCharset​(Charset charset)
        Set the output character set (encoding) to expect from the process. If this method is not called, the system default character set is used.
        Parameters:
        charset - the character set to use (must not be null)
        Returns:
        this builder