class Mongo::Crypt::KMS::Local::Credentials

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

@api private

Constants

FORMAT_HINT

Attributes

key[R]

@return [ String ] Master key.

Public Class Methods

new(opts) click to toggle source

Creates a local KMS credentials object form a parameters hash.

@param [ Hash ] opts A hash that contains credentials for

local KMS provider

@option opts [ String ] :key Master key.

@raise [ ArgumentError ] If required options are missing or incorrectly

formatted.
# File lib/mongo/crypt/kms/local/credentials.rb, line 45
def initialize(opts)
  @opts = opts
  unless empty?
    @key = validate_param(:key, opts, FORMAT_HINT)
  end
end

Public Instance Methods

to_document() click to toggle source

@return [ BSON::Document ] Local KMS credentials in libmongocrypt format.

# File lib/mongo/crypt/kms/local/credentials.rb, line 53
def to_document
  return BSON::Document.new({}) if empty?
  BSON::Document.new({
    key: BSON::Binary.new(@key, :generic),
  })
end