public final class HTTPVaultConnectorFactory extends VaultConnectorFactory
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_HOST |
static int |
DEFAULT_NUMBER_OF_RETRIES |
static Integer |
DEFAULT_PORT |
static String |
DEFAULT_PREFIX |
static boolean |
DEFAULT_TLS |
Constructor and Description |
---|
HTTPVaultConnectorFactory()
Default empty constructor.
|
Modifier and Type | Method and Description |
---|---|
HTTPVaultConnector |
build()
Build command, produces connector after initialization.
|
HTTPVaultConnector |
buildAndAuth()
Build connector and authenticate with token set in factory or from environment.
|
HTTPVaultConnectorFactory |
fromEnv()
Build connector based on the VAULT_ADDR} and
VAULT_CACERT (optional) environment variables. |
HTTPVaultConnectorFactory |
withHost(String host)
Set hostname (default: 127.0.0.1).
|
HTTPVaultConnectorFactory |
withNumberOfRetries(int numberOfRetries)
Define the number of retries to attempt on 5xx errors.
|
HTTPVaultConnectorFactory |
withoutTLS()
Convenience Method for NOT using TLS.
|
HTTPVaultConnectorFactory |
withPort(Integer port)
Set port (default: 8200).
|
HTTPVaultConnectorFactory |
withPrefix(String prefix)
Set API prefix.
|
HTTPVaultConnectorFactory |
withSslContext(SSLContext sslContext)
Add a custom SSL context.
|
HTTPVaultConnectorFactory |
withTimeout(int milliseconds)
Define a custom timeout for the HTTP connection.
|
HTTPVaultConnectorFactory |
withTLS()
Convenience Method for TLS usage (enabled by default).
|
HTTPVaultConnectorFactory |
withTLS(boolean useTLS)
Set TLS usage (default: TRUE).
|
HTTPVaultConnectorFactory |
withToken(String token)
Set token for automatic authentication, using
buildAndAuth() . |
HTTPVaultConnectorFactory |
withTrustedCA(Path cert)
Add a trusted CA certifiate for HTTPS connections.
|
httpFactory
public static final String DEFAULT_HOST
public static final Integer DEFAULT_PORT
public static final boolean DEFAULT_TLS
public static final String DEFAULT_PREFIX
public static final int DEFAULT_NUMBER_OF_RETRIES
public HTTPVaultConnectorFactory()
public HTTPVaultConnectorFactory withHost(String host)
host
- Hostname or IP addresspublic HTTPVaultConnectorFactory withPort(Integer port)
port
- Vault TCP portpublic HTTPVaultConnectorFactory withTLS(boolean useTLS)
useTLS
- use TLS or notpublic HTTPVaultConnectorFactory withTLS()
public HTTPVaultConnectorFactory withoutTLS()
public HTTPVaultConnectorFactory withPrefix(String prefix)
prefix
- Vault API prefix (default: "/v1/"public HTTPVaultConnectorFactory withTrustedCA(Path cert) throws VaultConnectorException
cert
- path to certificate fileVaultConnectorException
- on errorpublic HTTPVaultConnectorFactory withSslContext(SSLContext sslContext)
withTrustedCA(java.nio.file.Path)
.sslContext
- the SSL contextpublic HTTPVaultConnectorFactory withToken(String token)
buildAndAuth()
.token
- Vault tokenpublic HTTPVaultConnectorFactory fromEnv() throws VaultConnectorException
VAULT_CACERT
(optional) environment variables.VaultConnectorException
- if Vault address from environment variables is malformedpublic HTTPVaultConnectorFactory withNumberOfRetries(int numberOfRetries)
numberOfRetries
- The number of retries to attempt on 5xx errors (default: 0)public HTTPVaultConnectorFactory withTimeout(int milliseconds)
milliseconds
- Timeout value in milliseconds.public HTTPVaultConnector build()
VaultConnectorFactory
build
in class VaultConnectorFactory
public HTTPVaultConnector buildAndAuth() throws VaultConnectorException
VaultConnectorFactory
buildAndAuth
in class VaultConnectorFactory
VaultConnectorException
- if authentication failedCopyright © 2016–2018. All rights reserved.