Class: Mongo::Crypt::Handle Private
- Inherits:
-
Object
- Object
- Mongo::Crypt::Handle
- Defined in:
- lib/mongo/crypt/handle.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A handle to the libmongocrypt library that wraps a mongocrypt_t object, allowing clients to set options on that object or perform operations such as encryption and decryption
Instance Attribute Summary collapse
-
#kms_providers ⇒ Crypt::KMS::Credentials
readonly
private
Credentials for KMS providers.
Instance Method Summary collapse
- #crypt_shared_lib_available? ⇒ Boolean private
- #crypt_shared_lib_version ⇒ Object private
-
#initialize(kms_providers, kms_tls_options, options = {}) ⇒ Handle
constructor
private
Creates a new Handle object and initializes it with options.
-
#kms_tls_options(provider) ⇒ Hash
private
Return TLS options for KMS provider.
-
#ref ⇒ FFI::Pointer
private
Return the reference to the underlying @mongocrypt object.
Constructor Details
#initialize(kms_providers, kms_tls_options, options = {}) ⇒ Handle
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Handle object and initializes it with options
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/mongo/crypt/handle.rb', line 69 def initialize(kms_providers, , = {}) # FFI::AutoPointer uses a custom release strategy to automatically free # the pointer once this object goes out of scope @mongocrypt = FFI::AutoPointer.new( Binding.mongocrypt_new, Binding.method(:mongocrypt_destroy) ) Binding.kms_ctx_setopt_retry_kms(self, true) @kms_providers = kms_providers @kms_tls_options = maybe_set_schema_map() @encrypted_fields_map = [:encrypted_fields_map] set_encrypted_fields_map if @encrypted_fields_map @bypass_query_analysis = [:bypass_query_analysis] set_bypass_query_analysis if @bypass_query_analysis @crypt_shared_lib_path = [:crypt_shared_lib_path] @explicit_encryption_only = [:explicit_encryption_only] @disable_crypt_shared_lib_search = [:disable_crypt_shared_lib_search] if @crypt_shared_lib_path Binding.setopt_set_crypt_shared_lib_path_override(self, @crypt_shared_lib_path) elsif !@bypass_query_analysis && !@explicit_encryption_only && !@disable_crypt_shared_lib_search Binding.setopt_append_crypt_shared_lib_search_path(self, '$SYSTEM') end @logger = [:logger] set_logger_callback if @logger set_crypto_hooks Binding.setopt_kms_providers(self, @kms_providers.to_document) if @kms_providers.aws&.empty? || @kms_providers.gcp&.empty? || @kms_providers.azure&.empty? Binding.setopt_use_need_kms_credentials_state(self) end initialize_mongocrypt @crypt_shared_lib_required = !![:crypt_shared_lib_required] return unless @crypt_shared_lib_required && crypt_shared_lib_version == 0 raise Mongo::Error::CryptError.new( 'Crypt shared library is required, but cannot be loaded according to libmongocrypt' ) end |
Instance Attribute Details
#kms_providers ⇒ Crypt::KMS::Credentials (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Credentials for KMS providers.
29 30 31 |
# File 'lib/mongo/crypt/handle.rb', line 29 def kms_providers @kms_providers end |
Instance Method Details
#crypt_shared_lib_available? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 |
# File 'lib/mongo/crypt/handle.rb', line 139 def crypt_shared_lib_available? crypt_shared_lib_version != 0 end |
#crypt_shared_lib_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 |
# File 'lib/mongo/crypt/handle.rb', line 135 def crypt_shared_lib_version Binding.crypt_shared_lib_version(self) end |
#kms_tls_options(provider) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return TLS options for KMS provider. If there are no TLS options set, empty hash is returned.
131 132 133 |
# File 'lib/mongo/crypt/handle.rb', line 131 def (provider) @kms_tls_options.fetch(provider, {}) end |
#ref ⇒ FFI::Pointer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the reference to the underlying @mongocrypt object
121 122 123 |
# File 'lib/mongo/crypt/handle.rb', line 121 def ref @mongocrypt end |