Sha256: 5628f1bbb47f98c13f8b39ffda7ee4f00ed3c1392ff272c76a47f97aac499d84

Contents?: true

Size: 614 Bytes

Versions: 11

Compression:

Stored size: 614 Bytes

Contents

module Xmlenc
  class EncryptedDocument
    attr_accessor :xml

    def initialize(xml)
      @xml = xml
    end

    def document
      @document ||= Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions::STRICT)
    end

    def encrypted_keys
      document.xpath('//xenc:EncryptedKey', NAMESPACES).collect { |n| EncryptedKey.new(n) }
    end

    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xmlenc-0.6.0 lib/xmlenc/encrypted_document.rb
xmlenc-0.5.0 lib/xmlenc/encrypted_document.rb
xmlenc-0.4.1 lib/xmlenc/encrypted_document.rb
xmlenc-0.4.0 lib/xmlenc/encrypted_document.rb
xmlenc-0.3.0 lib/xmlenc/encrypted_document.rb
xmlenc-0.2.1 lib/xmlenc/encrypted_document.rb
xmlenc-0.2.0 lib/xmlenc/encrypted_document.rb
xmlenc-0.1.7 lib/xmlenc/encrypted_document.rb
xmlenc-0.1.6 lib/xmlenc/encrypted_document.rb
xmlenc-0.1.5 lib/xmlenc/encrypted_document.rb
xmlenc-0.1.4 lib/xmlenc/encrypted_document.rb