use of com.mongodb.crypt.capi.MongoKeyDecryptor in project mongo-java-driver by mongodb.
the class KeyManagementService method decryptKey.
Mono<Void> decryptKey(final MongoKeyDecryptor keyDecryptor) {
SocketSettings socketSettings = SocketSettings.builder().connectTimeout(timeoutMillis, MILLISECONDS).readTimeout(timeoutMillis, MILLISECONDS).build();
StreamFactory streamFactory = tlsChannelStreamFactoryFactory.create(socketSettings, SslSettings.builder().enabled(true).context(kmsProviderSslContextMap.get(keyDecryptor.getKmsProvider())).build());
ServerAddress serverAddress = new ServerAddress(keyDecryptor.getHostName());
LOGGER.info("Connecting to KMS server at " + serverAddress);
return Mono.<Void>create(sink -> {
Stream stream = streamFactory.create(serverAddress);
stream.openAsync(new AsyncCompletionHandler<Void>() {
@Override
public void completed(final Void ignored) {
streamWrite(stream, keyDecryptor, sink);
}
@Override
public void failed(final Throwable t) {
stream.close();
sink.error(t);
}
});
}).onErrorMap(this::unWrapException);
}
use of com.mongodb.crypt.capi.MongoKeyDecryptor in project mongo-java-driver by mongodb.
the class Crypt method decryptKeys.
private void decryptKeys(final MongoCryptContext cryptContext) {
try {
MongoKeyDecryptor keyDecryptor = cryptContext.nextKeyDecryptor();
while (keyDecryptor != null) {
decryptKey(keyDecryptor);
keyDecryptor = cryptContext.nextKeyDecryptor();
}
cryptContext.completeKeyDecryptors();
} catch (Throwable t) {
throw wrapInClientException(t);
}
}
Aggregations