Package io.umadb.client
Class UmaDbClientBuilder
java.lang.Object
io.umadb.client.UmaDbClientBuilder
Builder for creating
UmaDbClient instances.
This builder supports configuring:
- Target host and port
- TLS using a custom Certificate Authority (CA)
- API key authentication (sent as a Bearer token)
Security model
If an API key is configured, TLS must also be enabled. The client will refuse to send API keys over non-TLS connections.
Typical usage
UmaDbClient client = UmaDbClient.builder()
.withHostAndPort("localhost", 50051)
.withTls("/path/to/ca.pem")
.withApiKey("my-api-key")
.build();
This class is mutable and not thread-safe. It is intended for one-time configuration during client construction.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newUmaDbClientusing the configured settings.withApiKey(String apiKey) Configures API key authentication.Sets the host for the UmaDB server.withHostAndPort(String host, int port) Sets both the host and port for the UmaDB server.withPort(int port) Sets the port for the UmaDB server.Enables TLS using a custom Certificate Authority (CA) certificate.withTlsAndApiKey(String caFilePath, String apiKey) Enables both TLS and API key authentication in a single call.
-
Constructor Details
-
UmaDbClientBuilder
public UmaDbClientBuilder()
-
-
Method Details
-
withHostAndPort
Sets both the host and port for the UmaDB server.- Parameters:
host- the server hostname or IP addressport- the server port- Returns:
- this builder instance
-
withHost
Sets the host for the UmaDB server.- Parameters:
host- the server hostname or IP address- Returns:
- this builder instance
-
withPort
Sets the port for the UmaDB server.- Parameters:
port- the server port- Returns:
- this builder instance
-
withTls
Enables TLS using a custom Certificate Authority (CA) certificate.This is typically required when connecting to servers using self-signed certificates or private PKI setups.
- Parameters:
caFilePath- path to the CA certificate file (PEM format)- Returns:
- this builder instance
-
withApiKey
Configures API key authentication.The API key will be sent as an
Authorization: Bearer <token>header on all gRPC requests.Note: TLS must be enabled when using an API key.
- Parameters:
apiKey- the API key to use for authentication- Returns:
- this builder instance
-
withTlsAndApiKey
Enables both TLS and API key authentication in a single call.- Parameters:
caFilePath- path to the CA certificate file (PEM format)apiKey- the API key to use for authentication- Returns:
- this builder instance
-
build
Builds a newUmaDbClientusing the configured settings.- Returns:
- a fully configured
UmaDbClient - Throws:
IllegalStateException- if required configuration is missing or if an API key is configured without TLS
-