io.vertx.ext.mongo.impl.config.SSLSettingsParser Maven / Gradle / Ivy
package io.vertx.ext.mongo.impl.config;
import com.mongodb.ConnectionString;
import com.mongodb.connection.SslSettings;
import io.vertx.core.json.JsonObject;
import java.util.Optional;
/**
* @author Nick Scavelli
*/
class SSLSettingsParser {
private final ConnectionString connectionString;
private final JsonObject config;
SSLSettingsParser(ConnectionString connectionString, JsonObject config) {
this.connectionString = connectionString;
this.config = config;
}
public SslSettings settings() {
return fromConnectionString().orElseGet(this::fromConfiguration);
}
private Optional fromConnectionString() {
return Optional.ofNullable(connectionString).map(cs ->
SslSettings.builder()
.applyConnectionString(cs)
.build()
);
}
private SslSettings fromConfiguration() {
return SslSettings.builder()
.enabled(config.getBoolean("ssl", false))
.invalidHostNameAllowed(config.getBoolean("sslInvalidHostNameAllowed", false))
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy