Sha256: 5e5abbd149b49b005d85321d7a9ea2e37c5ddda4015f8879d52ddc80711dfec4

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Xmldsig
  class SignedDocument
    attr_accessor :document

    def initialize(document, options = {})
      @document = Nokogiri::XML::Document.parse(document)
    end

    def validate(certificate = nil, &block)
      signatures.all? { |signature| signature.valid?(certificate, &block) }
    end

    def sign(private_key = nil, &block)
      signatures.each { |signature| signature.sign(private_key, &block) }
      @document.to_s
    end

    def signed_nodes
      signatures.collect(&:referenced_node)
    end

    def signatures
      document.xpath("//ds:Signature", NAMESPACES).collect { |node| Signature.new(node) } || []
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xmldsig-0.0.4 lib/xmldsig/signed_document.rb
xmldsig-0.0.3 lib/xmldsig/signed_document.rb
xmldsig-0.0.2 lib/xmldsig/signed_document.rb
xmldsig-0.0.1 lib/xmldsig/signed_document.rb