模块:Mongo::Crypt::KMS::Validations Private
- 包含在:
- AWS::Credentials 、 AWS::MasterKeyDocument 、 Azure::Credentials 、 Azure::MasterKeyDocument 、 GCP::Credentials 、 GCP::MasterKeyDocument 、 KMIP::Credentials 、 KMIP::MasterKeyDocument 、 Local::Credentials
- 定义于:
- lib/ Mongo/crypt/kms.rb
Overview
该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。
此模块包含用于验证 KMS 参数的辅助方法。
类方法摘要折叠
-
.validate_tls_options(options) ⇒ Hash
private
验证KMS TLS 选项。
实例方法摘要折叠
-
# validate_param (key, opts, format_hint, required: true) ⇒ string | nil
private
验证KMS参数是否有效。
类方法详细信息
.validate_tls_options(options) ⇒ Hash
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
验证KMS TLS 选项。
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ Mongo/crypt/kms.rb', line 85 def () opts = || {} opts.每 do |provider, provider_opts| if provider_opts[:ssl] == false || opts[:tls] == false 提高 ArgumentError.new( " #{ 提供商} 的 TLS 选项不正确 :需要 TLS " ) end %i[ ssl_verify_certificate ssl_verify_hostname ].每 do |opt| 来年 除非 provider_opts[opt] == false 提高 ArgumentError.new( " #{ provider } 的 TLS 选项不正确 : " + '禁止不安全的 TLS 选项, ' + " KMS 的#{ opt }不能设置为 false " ) end end opts end |
实例方法详细信息
# validate_param (key, opts, format_hint, required: true) ⇒ string | nil
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
验证KMS参数是否有效。
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ Mongo/crypt/kms.rb', line 42 def validate_param(key, opts, format_hint, 必需: true) 值 = opts.获取(key) return nil if 值.nil? && !必需 if 值.nil? 提高 ArgumentError.new( " #{ key } 选项必须是至少有一个字符的字符串; " \ 'currently have nil ' ) endunless 值。 is_a? ( String ) 引发 ArgumentError。 new (" #{ key } 选项必须是至少有一个字符的字符串; " \ " 当前具有 #{ value } " ) end if 值。空?引发 ArgumentError。new("The #{key} option must be a String with at least one character; " \ 'it is currently an empty string' ) end value rescue KeyError if required raise ArgumentError.new(" 指定的KMS提供商程序选项无效: #{ opts }. " + format_hint ) end end |