xml-kit 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 763d302952d50ea00aad995aed62996708732c266e32e3fafeea3cc4e9db6c05
4
- data.tar.gz: 537a44ee7c79ba0edd4a32d850320845395aa4d1499b2c7138891d20dfe71970
3
+ metadata.gz: 99b69beb8838a1d4df81f5f634041e58ac6552e7564f9ef644fd3658b3c05c1e
4
+ data.tar.gz: f324dba7ceda0c3c5a4802c990baa1e56c8e502e47131459b60dc13247d3d578
5
5
  SHA512:
6
- metadata.gz: '01894af70c7d56882b04968eec80650acc3263e98633a8a04f4727d434b860197d6d39bf266f1750b13f8b66aebdc94c4bd3e917244c9def16f55f73e1d296d9'
7
- data.tar.gz: ecf023714655c4293064ce8656aa6e65e115b264be25f2d240ddfe5e37f3a2e532fa13f2137d99c6473350b3a98325491e307e42f52a10cf47c1eb0495e6646c
6
+ metadata.gz: 7a5a0e12f0042f17f367f8e51725013d28db9db0efdf3280dd59d812604fa93ba567fcf6973058ef0a04c9f2bf22517649be27e58bad0e098a9bfc26fdc35073
7
+ data.tar.gz: 047cc7d2cc323ba170028a767120e89085f1397e72843b7b4035cef26c54a01cb816a5fc48f3d37d030c36afcd9e5e379e4280d573079ca238ce249a374ede2d
@@ -26,7 +26,7 @@ module Xml
26
26
 
27
27
  # Decrypts an EncryptedData section of an XML document.
28
28
  #
29
- # @param data [Hash] the XML document converted to a [Hash] using Hash.from_xml.
29
+ # @param hash [Hash] the XML document converted to a [Hash] using Hash.from_xml.
30
30
  def decrypt_hash(hash)
31
31
  encrypted_data = hash['EncryptedData']
32
32
  symmetric_key = symmetric_key_from(encrypted_data)
@@ -34,6 +34,18 @@ module Xml
34
34
  to_plaintext(cipher_text, symmetric_key, encrypted_data["EncryptionMethod"]['Algorithm'])
35
35
  end
36
36
 
37
+ # Decrypts an EncryptedData Nokogiri::XML::Element.
38
+ #
39
+ # @param node [Nokogiri::XML::Element.] the XML node to decrypt.
40
+ def decrypt_node(node)
41
+ return node unless !node.nil? && "EncryptedData" == node.name
42
+
43
+ parent = node.parent
44
+ grand_parent = parent.parent
45
+ parent.swap(decrypt_xml(node.to_s))
46
+ grand_parent
47
+ end
48
+
37
49
  private
38
50
 
39
51
  def symmetric_key_from(encrypted_data)
@@ -44,8 +56,7 @@ module Xml
44
56
  begin
45
57
  attempts -= 1
46
58
  return to_plaintext(cipher_text, private_key, encrypted_key["EncryptionMethod"]['Algorithm'])
47
- rescue OpenSSL::PKey::RSAError => error
48
- ::Xml::Kit.logger.error(error)
59
+ rescue OpenSSL::PKey::RSAError
49
60
  raise if attempts.zero?
50
61
  end
51
62
  end
@@ -33,7 +33,7 @@ module Xml
33
33
  return raw_xml if key_pair.nil?
34
34
 
35
35
  private_key = key_pair.private_key
36
- Xmldsig::SignedDocument.new(raw_xml).sign(private_key)
36
+ Xmldsig::SignedDocument.new(raw_xml).sign(private_key, false)
37
37
  end
38
38
 
39
39
  # @!visibility private
@@ -1,5 +1,5 @@
1
1
  module Xml
2
2
  module Kit
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan