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

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

    A hash that contains master key options for KMIP KMS provider

Options Hash (opts):

  • :key_id (String)

    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)

    KMIP endpoint, optional.

Raises:

  • (ArgumentError)

    If required options are missing or incorrectly formatted.



84
85
86
87
88
89
90
91
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/kmip.rb', line 84

def initialize(opts)
  @key_id = validate_param(
    :key_id, opts, FORMAT_HINT, required: false
  ) || SecureRandom.alphanumeric(96)
  @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.



68
69
70
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/kmip.rb', line 68

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.



65
66
67
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/kmip.rb', line 65

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.



96
97
98
99
100
101
102
103
104
105
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/kmip.rb', line 96

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