Class: Moxml::Signature::KeyExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/signature/key_extractor.rb

Overview

Extracts an OpenSSL verification key from a Model::KeyInfo.

Strategy (per spec ยง4.5): X509Certificate is preferred for key reconstruction because it carries the certified binding. Falls back to RSAKeyValue / DSAKeyValue / ECKeyValue if no certificate is present. KeyName is resolved via an application-supplied key map.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_map: {}, cert_store: nil) ⇒ KeyExtractor

Returns a new instance of KeyExtractor.



17
18
19
20
# File 'lib/moxml/signature/key_extractor.rb', line 17

def initialize(key_map: {}, cert_store: nil)
  @key_map = key_map || {}
  @cert_store = cert_store
end

Instance Attribute Details

#cert_storeObject (readonly)

Returns the value of attribute cert_store.



15
16
17
# File 'lib/moxml/signature/key_extractor.rb', line 15

def cert_store
  @cert_store
end

#key_mapObject (readonly)

Returns the value of attribute key_map.



15
16
17
# File 'lib/moxml/signature/key_extractor.rb', line 15

def key_map
  @key_map
end

Instance Method Details

#extract(key_info) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/moxml/signature/key_extractor.rb', line 22

def extract(key_info)
  return nil if key_info.nil?

  from_x509_data(key_info.x509_data) ||
    from_key_value(key_info.key_value) ||
    from_key_name(key_info.key_name)
end