Class: Xmldsign::Signature
- Inherits:
-
XML::Node
- Object
- XML::Node
- Xmldsign::Signature
- Defined in:
- lib/xmldsign/signature.rb
Constant Summary collapse
- XML_C14N_1_0 =
0
- XML_C14N_EXCLUSIVE_1_0 =
1
- XML_C14N_1_1 =
2
Instance Method Summary collapse
- #c14n_signed_info ⇒ Object
- #calculate_digest ⇒ Object
- #canonicalization_method ⇒ Object
- #clear_certificate! ⇒ Object
- #clear_signature_value! ⇒ Object
- #digest_method ⇒ Object
- #fill_digest! ⇒ Object
- #sign ⇒ Object
- #signed_info ⇒ Object
- #transforms ⇒ Object
Instance Method Details
#c14n_signed_info ⇒ Object
11 12 13 14 15 16 |
# File 'lib/xmldsign/signature.rb', line 11 def c14n_signed_info sign doc = LibXML::XML::Document.new doc.root = signed_info.copy(true) doc.canonicalize mode: XML_C14N_EXCLUSIVE_1_0 end |
#calculate_digest ⇒ Object
59 60 61 |
# File 'lib/xmldsign/signature.rb', line 59 def calculate_digest digest_method.execute transforms.execute end |
#canonicalization_method ⇒ Object
18 19 20 21 |
# File 'lib/xmldsign/signature.rb', line 18 def canonicalization_method node = find_first('.//ds:CanonicalizationMethod') Algorithms.factory node['Algorithm'], node end |
#clear_certificate! ⇒ Object
45 46 47 48 49 |
# File 'lib/xmldsign/signature.rb', line 45 def clear_certificate! if (node = find_first('.//ds:X509Certificate')) node.content = '' end end |
#clear_signature_value! ⇒ Object
39 40 41 42 43 |
# File 'lib/xmldsign/signature.rb', line 39 def clear_signature_value! if (node = find_first('.//ds:SignatureValue')) node.content = '' end end |
#digest_method ⇒ Object
23 24 25 26 |
# File 'lib/xmldsign/signature.rb', line 23 def digest_method node = find_first('.//ds:DigestMethod') Algorithms.factory node['Algorithm'], node end |
#fill_digest! ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/xmldsign/signature.rb', line 51 def fill_digest! if (node = find_first('.//ds:DigestValue')) node.content = calculate_digest else raise Xmldsign::NodeError, 'node ds:DigestValue is not found in document' end end |
#sign ⇒ Object
32 33 34 35 36 37 |
# File 'lib/xmldsign/signature.rb', line 32 def sign fill_digest! clear_signature_value! clear_certificate! doc end |
#signed_info ⇒ Object
7 8 9 |
# File 'lib/xmldsign/signature.rb', line 7 def signed_info SignedInfo.new find_first('.//ds:SignedInfo') end |
#transforms ⇒ Object
28 29 30 |
# File 'lib/xmldsign/signature.rb', line 28 def transforms signed_info.transforms end |