class Xmlenc::EncryptedDocument
Attributes
xml[RW]
Public Class Methods
new(xml)
click to toggle source
# File lib/xmlenc/encrypted_document.rb, line 5 def initialize(xml) @xml = xml end
Public Instance Methods
decrypt(key, fail_silent = false)
click to toggle source
# File lib/xmlenc/encrypted_document.rb, line 17 def decrypt(key, fail_silent = false) encrypted_keys.each do |encrypted_key| begin encrypted_data = encrypted_key.encrypted_data data_key = encrypted_key.decrypt(key) encrypted_data.decrypt(data_key) rescue OpenSSL::PKey::RSAError => e raise e unless fail_silent end end @document.to_xml end
document()
click to toggle source
# File lib/xmlenc/encrypted_document.rb, line 9 def document @document ||= Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions::STRICT) end
encrypted_keys()
click to toggle source
# File lib/xmlenc/encrypted_document.rb, line 13 def encrypted_keys document.xpath('//xenc:EncryptedKey', NAMESPACES).collect { |n| EncryptedKey.new(n) } end