public class DatabaseClientBuilder
extends java.lang.Object
DatabaseClient
via chained "with" methods for setting
each possible input allowed for connecting to and authenticating
with MarkLogic. While the DatabaseClientFactory.Bean
class is intended for use in a context such as a Spring container,
it requires that a user have already assembled the appropriate
DatabaseClientFactory.SecurityContext
. This builder
instead is intended for a more dynamic environment - in particular,
one where the desired authentication strategy is not known until
runtime. A client can then collect inputs from a user at runtime
and call the appropriate methods on this builder. The builder will
handle constructing the correct
DatabaseClientFactory.SecurityContext
and using that
to construct a DatabaseClient
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTH_TYPE_BASIC |
static java.lang.String |
AUTH_TYPE_CERTIFICATE |
static java.lang.String |
AUTH_TYPE_DIGEST |
static java.lang.String |
AUTH_TYPE_KERBEROS |
static java.lang.String |
AUTH_TYPE_MARKLOGIC_CLOUD |
static java.lang.String |
AUTH_TYPE_OAUTH |
static java.lang.String |
AUTH_TYPE_SAML |
static java.lang.String |
PREFIX |
Constructor and Description |
---|
DatabaseClientBuilder() |
DatabaseClientBuilder(java.util.Map<java.lang.String,java.lang.Object> props)
Initialize the builder with the given set of
properties.
|
Modifier and Type | Method and Description |
---|---|
DatabaseClient |
build() |
DatabaseClientFactory.Bean |
buildBean() |
DatabaseClientBuilder |
withAuthType(java.lang.String type) |
DatabaseClientBuilder |
withBasePath(java.lang.String basePath) |
DatabaseClientBuilder |
withBasicAuth(java.lang.String username,
java.lang.String password) |
DatabaseClientBuilder |
withCertificateAuth(javax.net.ssl.SSLContext sslContext,
javax.net.ssl.X509TrustManager trustManager) |
DatabaseClientBuilder |
withCertificateAuth(java.lang.String file,
java.lang.String password) |
DatabaseClientBuilder |
withCertificateFile(java.lang.String file) |
DatabaseClientBuilder |
withCertificatePassword(java.lang.String password) |
DatabaseClientBuilder |
withCloudApiKey(java.lang.String cloudApiKey) |
DatabaseClientBuilder |
withCloudAuth(java.lang.String apiKey,
java.lang.String basePath) |
DatabaseClientBuilder |
withCloudAuth(java.lang.String apiKey,
java.lang.String basePath,
java.lang.Integer tokenDuration) |
DatabaseClientBuilder |
withCloudTokenDuration(java.lang.String tokenDuration) |
DatabaseClientBuilder |
withConnectionType(DatabaseClient.ConnectionType type) |
DatabaseClientBuilder |
withDatabase(java.lang.String database) |
DatabaseClientBuilder |
withDigestAuth(java.lang.String username,
java.lang.String password) |
DatabaseClientBuilder |
withGzippedResponsesDisabled()
Prevents the underlying OkHttp library from
sending an "Accept-Encoding-gzip" request header on each
request.
|
DatabaseClientBuilder |
withHost(java.lang.String host) |
DatabaseClientBuilder |
withKerberosAuth(java.lang.String principal) |
DatabaseClientBuilder |
withKerberosPrincipal(java.lang.String principal) |
DatabaseClientBuilder |
withKeyStoreAlgorithm(java.lang.String algorithm) |
DatabaseClientBuilder |
withKeyStorePassword(java.lang.String password) |
DatabaseClientBuilder |
withKeyStorePath(java.lang.String path)
Enables 2-way SSL by creating an SSL context
based on the given key store path.
|
DatabaseClientBuilder |
withKeyStoreType(java.lang.String type) |
DatabaseClientBuilder |
withOAuth(java.lang.String token) |
DatabaseClientBuilder |
withOAuthToken(java.lang.String token) |
DatabaseClientBuilder |
withPassword(java.lang.String password) |
DatabaseClientBuilder |
withPort(int port) |
DatabaseClientBuilder |
withSAMLAuth(java.lang.String token) |
DatabaseClientBuilder |
withSAMLToken(java.lang.String token) |
DatabaseClientBuilder |
withSecurityContext(DatabaseClientFactory.SecurityContext securityContext) |
DatabaseClientBuilder |
withSSLContext(javax.net.ssl.SSLContext sslContext) |
DatabaseClientBuilder |
withSSLHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier sslHostnameVerifier) |
DatabaseClientBuilder |
withSSLProtocol(java.lang.String sslProtocol) |
DatabaseClientBuilder |
withTrustManager(javax.net.ssl.X509TrustManager trustManager) |
DatabaseClientBuilder |
withTrustStoreAlgorithm(java.lang.String algorithm) |
DatabaseClientBuilder |
withTrustStorePassword(java.lang.String password) |
DatabaseClientBuilder |
withTrustStorePath(java.lang.String path)
Supports constructing an
X509TrustManager based on the given file path, which
should point to a Java key store or trust store. |
DatabaseClientBuilder |
withTrustStoreType(java.lang.String type) |
DatabaseClientBuilder |
withUsername(java.lang.String username) |
public static final java.lang.String PREFIX
public static final java.lang.String AUTH_TYPE_BASIC
public static final java.lang.String AUTH_TYPE_DIGEST
public static final java.lang.String AUTH_TYPE_MARKLOGIC_CLOUD
public static final java.lang.String AUTH_TYPE_KERBEROS
public static final java.lang.String AUTH_TYPE_CERTIFICATE
public static final java.lang.String AUTH_TYPE_SAML
public static final java.lang.String AUTH_TYPE_OAUTH
public DatabaseClientBuilder()
public DatabaseClientBuilder(java.util.Map<java.lang.String,java.lang.Object> props)
props
-public DatabaseClient build()
DatabaseClient
based on the inputs that have
been provided via the "with" builder methods and any inputs
provided via this instance's constructorpublic DatabaseClientFactory.Bean buildBean()
DatabaseClientFactory.Bean
based on
the inputs that have been provided via the "with" builder methods
and any inputs provided via this instance's constructorpublic DatabaseClientBuilder withHost(java.lang.String host)
public DatabaseClientBuilder withPort(int port)
public DatabaseClientBuilder withBasePath(java.lang.String basePath)
public DatabaseClientBuilder withDatabase(java.lang.String database)
public DatabaseClientBuilder withUsername(java.lang.String username)
public DatabaseClientBuilder withPassword(java.lang.String password)
public DatabaseClientBuilder withSecurityContext(DatabaseClientFactory.SecurityContext securityContext)
public DatabaseClientBuilder withAuthType(java.lang.String type)
type
- must be one of "basic", "digest", "cloud",
"kerberos", "certificate", or "saml"public DatabaseClientBuilder withBasicAuth(java.lang.String username, java.lang.String password)
public DatabaseClientBuilder withDigestAuth(java.lang.String username, java.lang.String password)
public DatabaseClientBuilder withCloudAuth(java.lang.String apiKey, java.lang.String basePath)
public DatabaseClientBuilder withCloudAuth(java.lang.String apiKey, java.lang.String basePath, java.lang.Integer tokenDuration)
apiKey
-basePath
-tokenDuration
- length in minutes until the
generated access token expirespublic DatabaseClientBuilder withKerberosAuth(java.lang.String principal)
public DatabaseClientBuilder withCertificateAuth(java.lang.String file, java.lang.String password)
public DatabaseClientBuilder withCertificateAuth(javax.net.ssl.SSLContext sslContext, javax.net.ssl.X509TrustManager trustManager)
sslContext
-trustManager
-public DatabaseClientBuilder withSAMLAuth(java.lang.String token)
public DatabaseClientBuilder withOAuth(java.lang.String token)
token
-public DatabaseClientBuilder withOAuthToken(java.lang.String token)
token
-public DatabaseClientBuilder withConnectionType(DatabaseClient.ConnectionType type)
public DatabaseClientBuilder withCloudApiKey(java.lang.String cloudApiKey)
public DatabaseClientBuilder withCloudTokenDuration(java.lang.String tokenDuration)
tokenDuration
- length in minutes until the
generated access token expirespublic DatabaseClientBuilder withCertificateFile(java.lang.String file)
public DatabaseClientBuilder withCertificatePassword(java.lang.String password)
public DatabaseClientBuilder withKerberosPrincipal(java.lang.String principal)
public DatabaseClientBuilder withSAMLToken(java.lang.String token)
public DatabaseClientBuilder withSSLContext(javax.net.ssl.SSLContext sslContext)
public DatabaseClientBuilder withSSLProtocol(java.lang.String sslProtocol)
public DatabaseClientBuilder withTrustManager(javax.net.ssl.X509TrustManager trustManager)
public DatabaseClientBuilder withSSLHostnameVerifier(DatabaseClientFactory.SSLHostnameVerifier sslHostnameVerifier)
public DatabaseClientBuilder withGzippedResponsesDisabled()
public DatabaseClientBuilder withKeyStorePath(java.lang.String path)
path
-public DatabaseClientBuilder withKeyStorePassword(java.lang.String password)
password
- optional password for a key storepublic DatabaseClientBuilder withKeyStoreType(java.lang.String type)
type
- e.g. "JKS"public DatabaseClientBuilder withKeyStoreAlgorithm(java.lang.String algorithm)
algorithm
- e.g. "SunX509"public DatabaseClientBuilder withTrustStorePath(java.lang.String path)
X509TrustManager
based on the given file path, which
should point to a Java key store or trust store.path
-public DatabaseClientBuilder withTrustStorePassword(java.lang.String password)
password
- optional password for a trust
storepublic DatabaseClientBuilder withTrustStoreType(java.lang.String type)
type
- e.g. "JKS"public DatabaseClientBuilder withTrustStoreAlgorithm(java.lang.String algorithm)
algorithm
- e.g. "SunX509"Copyright © 2024 MarkLogic Corporation. All Rights Reserved.