Class: Mongo::Crypt::KMS::KMIP::MasterKeyDocument Private

Inherits:
Object
  • Object
show all
Includes:
Validations
Defined in:
build/ruby-driver-v2.19/lib/mongo/crypt/kms/kmip/master_document.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.

KMIP KMS master key document object contains KMS master key parameters.

Constant Summary collapse

FORMAT_HINT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"KMIP KMS key document must be in the format: " +
"{ key_id: 'KEY-ID', endpoint: 'ENDPOINT' }"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations

#validate_param, validate_tls_options

Constructor Details

#initialize(opts = {}) ⇒ MasterKeyDocument

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 master key document object form a parameters hash.

Parameters:

  • opts (Hash) (defaults to: {})

    A hash that contains master key options for KMIP KMS provider

Options Hash (opts):

  • :key_id (String | nil)

    KMIP Unique Identifier to a 96 byte KMIP Secret Data managed object, optional. If key_id is omitted, the driver creates a random 96 byte identifier.

  • :endpoint (String | nil)

    KMIP endpoint, optional.

Raises:

  • (ArgumentError)

    If required options are missing or incorrectly formatted.



49
50
51
52
53
54
55
56
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/kms/kmip/master_document.rb', line 49

def initialize(opts = {})
  @key_id = validate_param(
    :key_id, opts, FORMAT_HINT, required: false
  )
  @endpoint = validate_param(
    :endpoint, opts, FORMAT_HINT, required: false
  )
end

Instance Attribute Details

#endpointString | nil (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 KMIP KMS endpoint with optional port.

Returns:

  • (String | nil)

    KMIP KMS endpoint with optional port.



33
34
35
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/kms/kmip/master_document.rb', line 33

def endpoint
  @endpoint
end

#key_idString | nil (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 The KMIP Unique Identifier to a 96 byte KMIP Secret Data managed object.

Returns:

  • (String | nil)

    The KMIP Unique Identifier to a 96 byte KMIP Secret Data managed object.



30
31
32
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/kms/kmip/master_document.rb', line 30

def key_id
  @key_id
end

Instance Method Details

#to_documentBSON::Document

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.

Convert master key document object to a BSON document in libmongocrypt format.

Returns:

  • (BSON::Document)

    KMIP KMS credentials in libmongocrypt format.



61
62
63
64
65
66
67
68
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/kms/kmip/master_document.rb', line 61

def to_document
  BSON::Document.new({
    provider: 'kmip',
  }).tap do |bson|
    bson.update({ endpoint: endpoint }) unless endpoint.nil?
    bson.update({ keyId: key_id }) unless key_id.nil?
  end
end