Package com.couchbase.client.dcp
Class SecurityConfig.Builder
java.lang.Object
com.couchbase.client.dcp.SecurityConfig.Builder
- Enclosing class:
- SecurityConfig
This builder allows to customize the default security configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds theSecurityConfigout of this builder.enableHostnameVerification(boolean hostnameVerificationEnabled) Allows to enable or disable hostname verification (enabled by default).enableNativeTls(boolean nativeTlsEnabled) Enables/disables native TLS (enabled by default).enableTls(boolean tlsEnabled) Enables TLS for all client/server communication (disabled by default).trustCertificate(Path certificatePath) Loads a X.509 trust certificate from the given path and uses it.trustCertificates(List<X509Certificate> certificates) Loads the given list of X.509 certificates into the trust store.trustManagerFactory(TrustManagerFactory trustManagerFactory) Allows to provide a trust manager factory directly for maximum flexibility.trustStore(Path trustStorePath, String trustStorePassword) Loads a trust store from a file path and password and initializes theTrustManagerFactory.trustStore(Path trustStorePath, String trustStorePassword, String trustStoreType) Loads a trust store from a file path and password and initializes theTrustManagerFactory.trustStore(KeyStore trustStore) Initializes theTrustManagerFactorywith the given trust store.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds theSecurityConfigout of this builder.- Returns:
- the built security config.
-
enableTls
Enables TLS for all client/server communication (disabled by default).- Parameters:
tlsEnabled- true if enabled, false otherwise.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
enableHostnameVerification
Allows to enable or disable hostname verification (enabled by default).Note that disabling hostname verification will cause the TLS connection to not verify that the hostname/ip is actually part of the certificate and as a result not detect certain kinds of attacks. Only disable if you understand the impact and risks!
- Parameters:
hostnameVerificationEnabled- set to true if it should be enabled, false for disabled.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
enableNativeTls
Enables/disables native TLS (enabled by default).- Parameters:
nativeTlsEnabled- true if it should be enabled, false otherwise.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustCertificates
Loads the given list of X.509 certificates into the trust store.- Parameters:
certificates- the list of certificates to load.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustCertificate
Loads a X.509 trust certificate from the given path and uses it.- Parameters:
certificatePath- the path to load the certificate from.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustManagerFactory
Allows to provide a trust manager factory directly for maximum flexibility.While providing the most flexibility, most users will find the other overloads more convenient, like passing in a
trustStore(KeyStore)directly or via filepathtrustStore(Path, String, String).- Parameters:
trustManagerFactory- the trust manager factory to use.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustStore
Initializes theTrustManagerFactorywith the given trust store.- Parameters:
trustStore- the loaded trust store to use.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustStore
Loads a trust store from a file path and password and initializes theTrustManagerFactory.Assumes the file format is readable by
KeyStore.getDefaultType()(this typically includes JKS and PKCS12).- Parameters:
trustStorePath- the path to the truststore.trustStorePassword- the password (can be null if not password protected).- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-
trustStore
public SecurityConfig.Builder trustStore(Path trustStorePath, String trustStorePassword, String trustStoreType) Loads a trust store from a file path and password and initializes theTrustManagerFactory.- Parameters:
trustStorePath- the path to the truststore.trustStorePassword- the password (can be null if not password protected).trustStoreType- (nullable) the type of the trust store. If null, theKeyStore.getDefaultType()will be used.- Returns:
- this
SecurityConfig.Builderfor chaining purposes.
-