Package com.mongodb.connection
Class SslSettings.Builder
- java.lang.Object
-
- com.mongodb.connection.SslSettings.Builder
-
- Enclosing class:
- SslSettings
@NotThreadSafe public static final class SslSettings.Builder extends Object
A builder for creating SSLSettings.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SslSettings.BuilderapplyConnectionString(ConnectionString connectionString)Takes the settings from the givenConnectionStringand applies them to the builderSslSettings.BuilderapplySettings(SslSettings sslSettings)Applies the sslSettings to the builderSslSettingsbuild()Create a new SSLSettings from the settings in this builder.SslSettings.Buildercontext(SSLContext context)Sets the SSLContext for use when SSL is enabled.SslSettings.Builderenabled(boolean enabled)Define whether SSL should be enabled.SslSettings.BuilderinvalidHostNameAllowed(boolean invalidHostNameAllowed)Define whether invalid host names should be allowed.
-
-
-
Method Detail
-
applySettings
public SslSettings.Builder applySettings(SslSettings sslSettings)
Applies the sslSettings to the builderNote: Overwrites all existing settings
- Parameters:
sslSettings- the sslSettings- Returns:
- this
- Since:
- 3.7
-
enabled
public SslSettings.Builder enabled(boolean enabled)
Define whether SSL should be enabled.- Parameters:
enabled- should be true if SSL is to be enabled.- Returns:
- this
-
invalidHostNameAllowed
public SslSettings.Builder invalidHostNameAllowed(boolean invalidHostNameAllowed)
Define whether invalid host names should be allowed. Defaults to false. Take care before setting this to true, as it makes the application susceptible to man-in-the-middle attacks.- Parameters:
invalidHostNameAllowed- whether invalid host names are allowed.- Returns:
- this
-
context
public SslSettings.Builder context(SSLContext context)
Sets the SSLContext for use when SSL is enabled.- Parameters:
context- the SSLContext to use for connections. Ignored if TLS/SSL is not enabled, or if aStreamFactorycreated by the specifiedStreamFactoryFactorydoes not useSSLContext.- Returns:
- this
- Since:
- 3.5
-
applyConnectionString
public SslSettings.Builder applyConnectionString(ConnectionString connectionString)
Takes the settings from the givenConnectionStringand applies them to the builder- Parameters:
connectionString- the connection string containing details of how to connect to MongoDB- Returns:
- this
-
build
public SslSettings build()
Create a new SSLSettings from the settings in this builder.- Returns:
- a new SSL settings
-
-