Class: OmniAuth::Strategies::Latvija::SignedDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/omniauth/strategies/latvija/signed_document.rb

Constant Summary collapse

DSIG =
'http://www.w3.org/2000/09/xmldsig#'.freeze
XENC =
'http://www.w3.org/2001/04/xmlenc#'.freeze
CANON_MODE =
Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0

Instance Method Summary collapse

Constructor Details

#initialize(response, **opts) ⇒ SignedDocument

Returns a new instance of SignedDocument.


32
33
34
35
36
37
38
# File 'lib/omniauth/strategies/latvija/signed_document.rb', line 32

def initialize(response, **opts)
  @response = Nokogiri::XML.parse(response, &:noblanks)
  return unless encrypted?
  decryptor = OmniAuth::Strategies::Latvija::Decryptor.new(response, opts[:private_key])
  decrypted_response = decryptor.decrypt
  @response = Nokogiri::XML.parse(decrypted_response, &:noblanks)
end

Instance Method Details

#nokogiri_xmlObject


49
50
51
# File 'lib/omniauth/strategies/latvija/signed_document.rb', line 49

def nokogiri_xml
  @response
end

#validate!(idp_cert_fingerprint) ⇒ Object


40
41
42
43
44
45
46
47
# File 'lib/omniauth/strategies/latvija/signed_document.rb', line 40

def validate!(idp_cert_fingerprint)
  validate_fingerprint!(idp_cert_fingerprint)
  sig_element = @response.xpath('//xmlns:Signature', xmlns: DSIG)

  validate_digest!(sig_element)
  validate_signature!(sig_element)
  true
end