Class: Xmldsig::Signature
- Inherits:
-
Object
- Object
- Xmldsig::Signature
- Defined in:
- lib/xmldsig/signature.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#signature ⇒ Object
Returns the value of attribute signature.
Instance Method Summary collapse
- #digest_value ⇒ Object
- #document ⇒ Object
-
#initialize(signature) ⇒ Signature
constructor
A new instance of Signature.
- #reference_uri ⇒ Object
- #referenced_node ⇒ Object
- #sign(private_key = nil, &block) ⇒ Object
- #signature_value ⇒ Object
- #signed_info ⇒ Object
- #valid?(certificate = nil, &block) ⇒ Boolean
Constructor Details
#initialize(signature) ⇒ Signature
Returns a new instance of Signature.
5 6 7 8 |
# File 'lib/xmldsig/signature.rb', line 5 def initialize(signature) @signature = signature @errors = [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/xmldsig/signature.rb', line 3 def errors @errors end |
#signature ⇒ Object
Returns the value of attribute signature.
3 4 5 |
# File 'lib/xmldsig/signature.rb', line 3 def signature @signature end |
Instance Method Details
#digest_value ⇒ Object
10 11 12 |
# File 'lib/xmldsig/signature.rb', line 10 def digest_value Base64.decode64 signed_info.at_xpath("descendant::ds:DigestValue", NAMESPACES).content end |
#document ⇒ Object
14 15 16 |
# File 'lib/xmldsig/signature.rb', line 14 def document signature.document end |
#reference_uri ⇒ Object
26 27 28 |
# File 'lib/xmldsig/signature.rb', line 26 def reference_uri signature.at_xpath("descendant::ds:Reference", NAMESPACES).get_attribute("URI") end |
#referenced_node ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/xmldsig/signature.rb', line 18 def referenced_node if reference_uri && reference_uri != "" document.dup.at_xpath("//*[@ID='#{reference_uri[1..-1]}']") else document.root end end |
#sign(private_key = nil, &block) ⇒ Object
30 31 32 33 |
# File 'lib/xmldsig/signature.rb', line 30 def sign(private_key = nil, &block) self.digest_value = calculate_digest_value self.signature_value = calculate_signature_value(private_key, &block) end |
#signature_value ⇒ Object
39 40 41 |
# File 'lib/xmldsig/signature.rb', line 39 def signature_value Base64.decode64 signature.at_xpath("descendant::ds:SignatureValue", NAMESPACES).content end |
#signed_info ⇒ Object
35 36 37 |
# File 'lib/xmldsig/signature.rb', line 35 def signed_info signature.at_xpath("descendant::ds:SignedInfo", NAMESPACES) end |
#valid?(certificate = nil, &block) ⇒ Boolean
43 44 45 46 47 48 |
# File 'lib/xmldsig/signature.rb', line 43 def valid?(certificate = nil, &block) @errors = [] validate_digest_value validate_signature_value(certificate, &block) @errors.empty? end |