Class: Xmlenc::EncryptedDocument
- Inherits:
-
Object
- Object
- Xmlenc::EncryptedDocument
- Defined in:
- lib/xmlenc/encrypted_document.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #decrypt(key) ⇒ Object
- #document ⇒ Object
- #encrypted_keys ⇒ Object
-
#initialize(xml) ⇒ EncryptedDocument
constructor
A new instance of EncryptedDocument.
Constructor Details
#initialize(xml) ⇒ EncryptedDocument
Returns a new instance of EncryptedDocument.
5 6 7 |
# File 'lib/xmlenc/encrypted_document.rb', line 5 def initialize(xml) @xml = xml end |
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
3 4 5 |
# File 'lib/xmlenc/encrypted_document.rb', line 3 def xml @xml end |
Instance Method Details
#decrypt(key) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/xmlenc/encrypted_document.rb', line 17 def decrypt(key) encrypted_keys.each do |encrypted_key| encrypted_data = encrypted_key.encrypted_data data_key = encrypted_key.decrypt(key) encrypted_data.decrypt(data_key) end @document.to_xml end |
#document ⇒ Object
9 10 11 |
# File 'lib/xmlenc/encrypted_document.rb', line 9 def document @document ||= Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions::STRICT) end |
#encrypted_keys ⇒ Object
13 14 15 |
# File 'lib/xmlenc/encrypted_document.rb', line 13 def encrypted_keys document.xpath('//xenc:EncryptedKey', NAMESPACES).collect { |n| EncryptedKey.new(n) } end |