Class: XMLSignature
- Inherits:
-
Object
- Object
- XMLSignature
- Defined in:
- lib/xml_signature.rb,
lib/xml_signature/version.rb
Constant Summary collapse
- VERSION =
'0.1'
Instance Method Summary collapse
-
#initialize(xml) ⇒ XMLSignature
constructor
xml - A REXML document.
- #verify(expected_certificate) ⇒ Object
Constructor Details
#initialize(xml) ⇒ XMLSignature
xml - A REXML document
10 11 12 13 14 |
# File 'lib/xml_signature.rb', line 10 def initialize(xml) @xml = xml.dup @ds_signature = xpath(@xml, '//ds:Signature') @ds_signature.remove end |
Instance Method Details
#verify(expected_certificate) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xml_signature.rb', line 16 def verify(expected_certificate) raise "Certificate mismatch" if expected_certificate != given_certificate REXML::XPath.each(@ds_signature, "//ds:Reference") do |ref| raise "Digest mismatch!" if computed_digest_value(ref) != given_digest_value(ref) end raise "Signature mismatch" \ unless certificate.public_key.verify(signature_algorithm_class.new, signature, c14n(xpath(@ds_signature, "//ds:SignedInfo"))) true end |