123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Forwardable
Instance Chain:
Inherits: Object
Defined in: lib/mongo/crypt/kms/local/credentials.rb

Overview

::Mongo::Crypt::KMS::Local KMS Credentials object contains credentials for using local ::Mongo::Crypt::KMS provider.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Mongo::Crypt::KMS::Validations - Included

#validate_param

Validate if a ::Mongo::Crypt::KMS parameter is valid.

#validate_tls_options

Validate KMS TLS options.

Constructor Details

.new(opts) ⇒ Credentials

Creates a local ::Mongo::Crypt::KMS credentials object form a parameters hash.

Parameters:

Options Hash (opts):

  • :key (String)

    Master key.

Raises:

  • (ArgumentError)

    If required options are missing or incorrectly formatted.

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/local/credentials.rb', line 45

def initialize(opts)
  @opts = opts
  return if empty?

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

Instance Attribute Details

#keyString (readonly)

Returns:

  • (String)

    Master key.

[ GitHub ]

  
# File 'lib/mongo/crypt/kms/local/credentials.rb', line 29

attr_reader :key

Instance Method Details

#to_documentBSON::Document

Returns:

[ GitHub ]

  
# 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