类:Mongo::Crypt::KMS::MasterKeyDocument Private

继承:
对象
  • 对象
显示全部
定义于:
lib/ Mongo/crypt/ KMS/master_key_document.rb

Overview

此类是私有 API 的一部分。 应尽可能避免使用此类,因为它将来可能会被删除或更改。

KMS 主密钥文档对象包含用于创建数据密钥的 KMS 主密钥参数。

常量摘要折叠

KMS_PROVIDERS =

此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。

已知的 KMS 提供商名称。

%w[AWS AZURE GCP KMIP local].冻结

实例方法摘要折叠

构造函数详情

#initialize (kms_provider, options) ⇒ MasterKeyDocument

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

从参数哈希创建主密钥文档对象。

参数:

  • kms_provider。 ( string )

    KMS 提供商名称。

  • 选项 (哈希)

    包含KMS提供商的主密钥选项的哈希值。 Mongo::Crypt:: KMS模块内的相应类描述了KMS提供程序所需的参数。

引发:

  • ( ArgumentError )

    如果所需选项缺失或不正确。



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ Mongo/crypt/ KMS/master_key_document.rb', line 37

def 初始化(kms_provider, 选项)
  提高 ArgumentError.new('关键文档选项不得为 nil ') if 选项.nil?

  master_key = 选项.获取(:master_key, {})
  @key_document = 案例 kms_provider.to_s
                  when 'aws' then KMS::AWS::MasterKeyDocument.new(master_key)
                  when 'azure' then KMS::AZURE::MasterKeyDocument.new(master_key)
                  when 'gcp' then KMS::GCP::MasterKeyDocument.new(master_key)
                  when ' kmip ' then KMS::KMIP::MasterKeyDocument.new(master_key)
                  when ' local ' then KMS::local::MasterKeyDocument.new(master_key)
                  else
                    提高 ArgumentError.new(" KMS提供商必须是#{ KMS_PROVIDERS }之一")
                  end
end

实例方法详细信息

# to_documentBSON::Document

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

将主密钥文档对象转换为 libmongocrypt 格式的 BSON 文档。

返回:

  • ( BSON::Document )

    主密钥文档为BSON文档。



55
56
57
# File 'lib/ Mongo/crypt/ KMS/master_key_document.rb', line 55

def to_document
  @key_document.to_document
end