Class: Mongo::Crypt::KMS::Local::Credentials Private

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

Local KMS Credentials object contains credentials for using local KMS provider.

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.

"Local KMS provider options must be in the format: " +
"{ key: 'MASTER-KEY' }"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations

#validate_param, validate_tls_options

Constructor Details

#initialize(opts) ⇒ Credentials

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 local KMS credentials object form a parameters hash.

Parameters:

  • opts (Hash)

    A hash that contains credentials for local KMS provider

Options Hash (opts):

  • :key (String)

    Master key.

Raises:

  • (ArgumentError)

    If required options are missing or incorrectly formatted.



42
43
44
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/local.rb', line 42

def initialize(opts)
  @key = validate_param(:key, opts, FORMAT_HINT)
end

Instance Attribute Details

#keyString (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 Master key.

Returns:

  • (String)

    Master key.



29
30
31
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/local.rb', line 29

def key
  @key
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.

Returns Local KMS credentials in libmongocrypt format.

Returns:

  • (BSON::Document)

    Local KMS credentials in libmongocrypt format.



47
48
49
50
51
# File 'build/ruby-driver-master/lib/mongo/crypt/kms/local.rb', line 47

def to_document
  BSON::Document.new({
    key: BSON::Binary.new(@key, :generic),
  })
end