Module de.stklcode.jvault.connector
Package de.stklcode.jvault.connector
Class HTTPVaultConnectorBuilder
java.lang.Object
de.stklcode.jvault.connector.HTTPVaultConnectorBuilder
Vault Connector Builder implementation for HTTP Vault connectors.
- Since:
- 0.8.0, 0.9.5 Package
de.stklcode.jvault.connector
- Author:
- Stefan Kalscheuer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build command, produces connector after initialization.Build connector and authenticate with token set in factory or from environment.fromEnv()
Build connector based on the VAULT_ADDR} andVAULT_CACERT
(optional) environment variables.withBaseURL
(String baseURL) Set base URL, e.g.withBaseURL
(URI baseURL) Set base URL, e.g.Set hostname (default: 127.0.0.1).withNumberOfRetries
(int numberOfRetries) Define the number of retries to attempt on 5xx errors.Convenience Method for NOT using TLS.Set port (default: 8200).withPrefix
(String prefix) Set API prefix.withTimeout
(int milliseconds) Define a custom timeout for the HTTP connection.withTLS()
Convenience Method for TLS usage (enabled by default).withTLS
(boolean useTLS) Set TLS usage (default: TRUE).Set TLS usage (default: TRUE).Convenience Method for TLS usage (enabled by default).Set token for automatic authentication, usingbuildAndAuth()
.withTrustedCA
(Path cert) Add a trusted CA certificate for HTTPS connections.withTrustedCA
(X509Certificate cert) Add a trusted CA certificate for HTTPS connections.
-
Field Details
-
DEFAULT_HOST
- See Also:
-
DEFAULT_PORT
-
DEFAULT_TLS
public static final boolean DEFAULT_TLS- See Also:
-
DEFAULT_TLS_VERSION
- See Also:
-
DEFAULT_PREFIX
- See Also:
-
DEFAULT_NUMBER_OF_RETRIES
public static final int DEFAULT_NUMBER_OF_RETRIES- See Also:
-
-
Method Details
-
withBaseURL
Set base URL, e.g. "protocol://host:port/prefix".- Parameters:
baseURL
- Base URL- Returns:
- self
- Throws:
URISyntaxException
- Invalid URI syntax.- Since:
- 1.0
-
withBaseURL
Set base URL, e.g. "protocol://host:port/prefix".- Parameters:
baseURL
- Base URL- Returns:
- self
- Since:
- 1.0
-
withHost
Set hostname (default: 127.0.0.1).- Parameters:
host
- Hostname or IP address- Returns:
- self
-
withPort
Set port (default: 8200). A value ofnull
or-1
indicates that no port is specified, i.e. the protocol default is used. Otherwise, a valid port number between 1 and 65535 is expected.- Parameters:
port
- Vault TCP port- Returns:
- self
-
withTLS
Set TLS usage (default: TRUE).- Parameters:
useTLS
- use TLS or not- Returns:
- self
-
withTLS
Set TLS usage (default: TRUE).- Parameters:
useTLS
- Use TLS or not.version
- Supported TLS version (TLSv1.2
,TLSv1.1
,TLSv1.0
,TLS
).- Returns:
- self
- Since:
- 0.8 Added version parameter (#22).
-
withTLS
Convenience Method for TLS usage (enabled by default).- Parameters:
version
- Supported TLS version (TLSv1.2
,TLSv1.1
,TLSv1.0
,TLS
).- Returns:
- self
- Since:
- 0.8 Added version parameter (#22).
-
withTLS
Convenience Method for TLS usage (enabled by default).- Returns:
- self
-
withoutTLS
Convenience Method for NOT using TLS.- Returns:
- self
-
withPrefix
Set API prefix. Default is "/v1/" and changes should not be necessary for current state of development.- Parameters:
prefix
- Vault API prefix (default: "/v1/")- Returns:
- self
-
withTrustedCA
Add a trusted CA certificate for HTTPS connections.- Parameters:
cert
- path to certificate file- Returns:
- self
- Throws:
VaultConnectorException
- on error- Since:
- 0.4.0
-
withTrustedCA
Add a trusted CA certificate for HTTPS connections.- Parameters:
cert
- path to certificate file- Returns:
- self
- Since:
- 0.8.0
-
withToken
Set token for automatic authentication, usingbuildAndAuth()
.- Parameters:
token
- Vault token- Returns:
- self
- Since:
- 0.6.0
-
fromEnv
Build connector based on the VAULT_ADDR} andVAULT_CACERT
(optional) environment variables.- Returns:
- self
- Throws:
VaultConnectorException
- if Vault address from environment variables is malformed- Since:
- 0.6.0
-
withNumberOfRetries
Define the number of retries to attempt on 5xx errors.- Parameters:
numberOfRetries
- The number of retries to attempt on 5xx errors (default: 0)- Returns:
- self
- Since:
- 0.6.0
-
withTimeout
Define a custom timeout for the HTTP connection.- Parameters:
milliseconds
- Timeout value in milliseconds.- Returns:
- self
- Since:
- 0.6.0
-
build
Build command, produces connector after initialization.- Returns:
- Vault Connector instance.
-
buildAndAuth
Build connector and authenticate with token set in factory or from environment.- Returns:
- Authenticated Vault connector instance.
- Throws:
VaultConnectorException
- if authentication failed- Since:
- 0.6.0
-