Class: Mongo::Crypt::DataKeyContext Private
- Defined in:
- lib/mongo/crypt/data_key_context.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 Context object initialized specifically for the purpose of creating a data key in the key managemenet system.
Instance Attribute Summary
Attributes inherited from Context
Instance Method Summary collapse
-
#initialize(mongocrypt, io, kms_provider, options = {}) ⇒ DataKeyContext
constructor
private
Create a new DataKeyContext object.
Methods inherited from Context
Constructor Details
#initialize(mongocrypt, io, kms_provider, options = {}) ⇒ DataKeyContext
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.
Create a new DataKeyContext object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mongo/crypt/data_key_context.rb', line 41 def initialize(mongocrypt, io, kms_provider, ={}) super(mongocrypt, io) case kms_provider when 'local' Binding.ctx_setopt_master_key_local(self) when 'aws' unless raise ArgumentError.new( 'When "aws" is specified as the KMS provider, options cannot be nil' ) end unless .key?(:master_key) raise ArgumentError.new( 'When "aws" is specified as the KMS provider, the options Hash ' + 'must contain a key named :master_key with a Hash value in the ' + '{ region: "AWS-REGION", key: "AWS-KEY-ARN" }' ) end master_key_opts = [:master_key] set_aws_master_key(master_key_opts) set_aws_endpoint(master_key_opts[:endpoint]) if master_key_opts[:endpoint] else raise ArgumentError.new( "#{kms_provider} is an invalid kms provider. " + "Valid options are 'aws' and 'local'" ) end set_key_alt_names([:key_alt_names]) if [:key_alt_names] initialize_ctx end |