Class: Mongo::Crypt::ExplicitEncryptionContext Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
Mongo::Crypt::ExplicitEncryptionExpressionContext
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Context ,
Forwardable
|
|
Instance Chain:
self,
Context
|
|
Inherits: |
Mongo::Crypt::Context
|
Defined in: | lib/mongo/crypt/explicit_encryption_context.rb |
Overview
A Context object initialized for explicit encryption
Class Method Summary
-
.new(mongocrypt, io, doc, options = {}) ⇒ ExplicitEncryptionContext
constructor
Internal use only
Create a new
ExplicitEncryptionContext
object.
Context
- Inherited
Instance Attribute Summary
Instance Method Summary
- #init(doc) Internal use only
- #convert_range_opts(range_opts) private Internal use only
- #set_algorithm_opts(options) private Internal use only
- #set_key_alt_name(key_alt_name) private Internal use only
- #set_key_id(key_id) private Internal use only
- #set_key_opts(options) private Internal use only
Context
- Inherited
#run_state_machine | Runs the mongocrypt_ctx_t state machine and handles all I/O on behalf of. |
#state | Returns the state of the mongocrypt_ctx_t. |
#azure_access_token | Returns an Azure access token, retrieving it if necessary. |
#feed_kms, | |
#gcp_access_token | Retrieves a GCP access token. |
#mongocrypt_done | Indicate that state machine is done feeding I/O responses back to libmongocrypt. |
#mongocrypt_feed | Feeds the result of a |
#provide_collection_info, #provide_keys, #provide_markings, | |
#retrieve_kms_credentials | Retrieves KMS credentials for providers that are configured for automatic credentials retrieval. |
Instance Method Details
#convert_range_opts(range_opts) (private)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 140
def convert_range_opts(range_opts) range_opts.dup.tap do |opts| if opts[:sparsity] && !opts[:sparsity].is_a?(BSON::Int64) opts[:sparsity] = BSON::Int64.new(opts[:sparsity]) end if opts[:trim_factor] opts[:trimFactor] = opts.delete(:trim_factor) end end end
#init(doc)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 74
def init(doc) Binding.ctx_explicit_encrypt_init(self, doc) end
#set_algorithm_opts(options) (private)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 118
def set_algorithm_opts( ) Binding.ctx_setopt_algorithm(self, [:algorithm]) if %w(Indexed Range).include?( [:algorithm]) if [:contention_factor] Binding.ctx_setopt_contention_factor(self, [:contention_factor]) end if [:query_type] Binding.ctx_setopt_query_type(self, [:query_type]) end else if [:contention_factor] raise ArgumentError.new(':contention_factor is allowed only for "Indexed" or "Range" algorithms') end if [:query_type] raise ArgumentError.new(':query_type is allowed only for "Indexed" or "Range" algorithms') end end if [:algorithm] == 'Range' Binding.ctx_setopt_algorithm_range(self, convert_range_opts( [:range_opts])) end end
#set_key_alt_name(key_alt_name) (private)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 111
def set_key_alt_name(key_alt_name) unless key_alt_name.is_a?(String) raise ArgumentError.new(':key_alt_name option must be a String') end Binding.ctx_setopt_key_alt_names(self, [key_alt_name]) end
#set_key_id(key_id) (private)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 100
def set_key_id(key_id) unless key_id.is_a?(BSON::Binary) && key_id.type == :uuid raise ArgumentError.new( "Expected the :key_id option to be a BSON::Binary object with " + "type :uuid. #{key_id} is an invalid :key_id option" ) end Binding.ctx_setopt_key_id(self, key_id.data) end
#set_key_opts(options) (private)
[ GitHub ]# File 'lib/mongo/crypt/explicit_encryption_context.rb', line 79
def set_key_opts( ) if [:key_id].nil? && [:key_alt_name].nil? raise ArgumentError.new( 'The :key_id and :key_alt_name options cannot both be nil. ' + 'Specify a :key_id option or :key_alt_name option (but not both)' ) end if [:key_id] && [:key_alt_name] raise ArgumentError.new( 'The :key_id and :key_alt_name options cannot both be present. ' + 'Identify the data key by specifying its id with the :key_id ' + 'option or specifying its alternate name with the :key_alt_name option' ) end if [:key_id] set_key_id( [:key_id]) elsif [:key_alt_name] set_key_alt_name( [:key_alt_name]) end end