public class SecurityConfig extends Object
SecurityConfig
allows to enable transport encryption between the client and the servers.Modifier and Type | Class and Description |
---|---|
static class |
SecurityConfig.Builder
This builder allows to customize the default security configuration.
|
Modifier and Type | Method and Description |
---|---|
static SecurityConfig.Builder |
builder()
Creates a builder to customize the
SecurityConfig configuration. |
static SecurityConfig |
create()
Creates a
SecurityConfig with the default configuration. |
static List<X509Certificate> |
decodeCertificates(List<String> certificates)
Helper method to decode string-encoded certificates into their x.509 format.
|
static SecurityConfig.Builder |
enableNativeTls(boolean nativeTlsEnabled)
Enables/disables native TLS (enabled by default).
|
static SecurityConfig.Builder |
enableTls(boolean tlsEnabled)
Enables TLS for all client/server communication (disabled by default).
|
boolean |
nativeTlsEnabled()
Returns whether native TLS is enabled.
|
boolean |
tlsEnabled()
True if TLS is enabled, false otherwise.
|
static SecurityConfig.Builder |
trustCertificate(Path certificatePath)
Loads a X.509 trust certificate from the given path and uses it.
|
List<X509Certificate> |
trustCertificates()
The list of trust certificates that should be used, if present.
|
static SecurityConfig.Builder |
trustCertificates(List<X509Certificate> certificates)
Loads the given list of X.509 certificates into the trust store.
|
TrustManagerFactory |
trustManagerFactory()
The currently configured trust manager factory, if present.
|
static SecurityConfig.Builder |
trustManagerFactory(TrustManagerFactory trustManagerFactory)
Allows to provide a trust manager factory directly for maximum flexibility.
|
static SecurityConfig.Builder |
trustStore(KeyStore trustStore)
Initializes the
TrustManagerFactory with the given trust store. |
static SecurityConfig.Builder |
trustStore(Path trustStorePath,
String trustStorePassword,
Optional<String> trustStoreType)
Loads a trust store from a file path and password and initializes the
TrustManagerFactory . |
public static SecurityConfig.Builder builder()
SecurityConfig
configuration.public static SecurityConfig create()
SecurityConfig
with the default configuration.public static SecurityConfig.Builder enableTls(boolean tlsEnabled)
tlsEnabled
- true if enabled, false otherwise.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder enableNativeTls(boolean nativeTlsEnabled)
nativeTlsEnabled
- true if it should be enabled, false otherwise.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder trustCertificates(List<X509Certificate> certificates)
certificates
- the list of certificates to load.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder trustCertificate(Path certificatePath)
certificatePath
- the path to load the certificate from.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder trustStore(KeyStore trustStore)
TrustManagerFactory
with the given trust store.trustStore
- the loaded trust store to use.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder trustStore(Path trustStorePath, String trustStorePassword, Optional<String> trustStoreType)
TrustManagerFactory
.trustStorePath
- the path to the truststore.trustStorePassword
- the password (can be null if not password protected).trustStoreType
- the type of the trust store. If empty, the KeyStore.getDefaultType()
will be used.SecurityConfig.Builder
for chaining purposes.public static SecurityConfig.Builder trustManagerFactory(TrustManagerFactory trustManagerFactory)
While providing the most flexibility, most users will find the other overloads more convenient, like passing
in a trustStore(KeyStore)
directly or via filepath trustStore(Path, String, Optional)
.
trustManagerFactory
- the trust manager factory to use.SecurityConfig.Builder
for chaining purposes.public boolean tlsEnabled()
public List<X509Certificate> trustCertificates()
public TrustManagerFactory trustManagerFactory()
public boolean nativeTlsEnabled()
public static List<X509Certificate> decodeCertificates(List<String> certificates)
certificates
- the string-encoded certificates.Copyright © 2020 Couchbase, Inc.. All rights reserved.