Class CommandCredentialSource.Builder
- java.lang.Object
-
- org.wildfly.security.credential.source.CommandCredentialSource.Builder
-
- Enclosing class:
- CommandCredentialSource
public static final class CommandCredentialSource.Builder extends Object
A builder for a command credential source.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Function<ProcessBuilder,ProcessBuilder>builderProcessor(package private) CharsetoutputCharset(package private) SecurityFactory<PasswordFactory>passwordFactoryFactory
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandCredentialSource.BuilderaddCommand(String commandString)Add a command string to the list of command strings.CommandCredentialSource.BuilderaddCommand(Consumer<Consumer<String>> consumer)Add a command string provider to the list of command strings.CommandCredentialSource.BuilderaddCommand(Supplier<String> commandStringSupplier)Add a command string supplier result to the list of command strings.CommandCredentialSource.BuilderaddEnvironment(String key, String value)Add an environment value to the process environment.CommandCredentialSource.BuilderaddEnvironment(Consumer<BiConsumer<String,String>> consumer)Add multiple environment values to the process environment.CommandCredentialSourcebuild()Construct the credential source instance.CommandCredentialSource.BuilderremoveEnvironment(String key)Remove an environment variable from the process environment.CommandCredentialSource.BuildersetOutputCharset(Charset charset)Set the output character set (encoding) to expect from the process.CommandCredentialSource.BuildersetPasswordFactoryProvider(Provider provider)Set the provider to use to find the password factory.CommandCredentialSource.BuildersetWorkingDirectory(File directory)Set the working directory of the target process.
-
-
-
Field Detail
-
outputCharset
Charset outputCharset
-
passwordFactoryFactory
SecurityFactory<PasswordFactory> passwordFactoryFactory
-
builderProcessor
Function<ProcessBuilder,ProcessBuilder> builderProcessor
-
-
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 benull)- 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 returnsnullor 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 benull)- 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 providenullor empty strings.- Parameters:
consumer- the consumer which can provide the command strings to add (must not benull)- 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 benull)value- the environment variable value (must not benull)- 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 benull)- 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 benull)- Returns:
- this builder
-
setWorkingDirectory
public CommandCredentialSource.Builder setWorkingDirectory(File directory)
Set the working directory of the target process.- Parameters:
directory- the directory (must not benull)- 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 benull)- 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 benull)- Returns:
- this builder
-
build
public CommandCredentialSource build() throws GeneralSecurityException
Construct the credential source instance.- Returns:
- the credential source
- Throws:
GeneralSecurityException- if there was a failure constructing the password factory
-
-