Class: Xml::Kit::Decryption
- Inherits:
-
Object
- Object
- Xml::Kit::Decryption
- Defined in:
- lib/xml/kit/decryption.rb
Overview
Instance Attribute Summary collapse
-
#private_keys ⇒ Object
readonly
The list of private keys to use to attempt to decrypt the document.
Instance Method Summary collapse
-
#decrypt(data) ⇒ Object
Decrypts an EncryptedData section of an XML document.
-
#decrypt_hash(hash) ⇒ Object
Decrypts an EncryptedData section of an XML document.
-
#decrypt_node(node) ⇒ Object
Decrypts an EncryptedData Nokogiri::XML::Element.
-
#decrypt_xml(raw_xml) ⇒ Object
Decrypts an EncryptedData section of an XML document.
-
#initialize(private_keys:) ⇒ Decryption
constructor
A new instance of Decryption.
Constructor Details
#initialize(private_keys:) ⇒ Decryption
Returns a new instance of Decryption.
10 11 12 |
# File 'lib/xml/kit/decryption.rb', line 10 def initialize(private_keys:) @private_keys = private_keys end |
Instance Attribute Details
#private_keys ⇒ Object (readonly)
The list of private keys to use to attempt to decrypt the document.
8 9 10 |
# File 'lib/xml/kit/decryption.rb', line 8 def private_keys @private_keys end |
Instance Method Details
#decrypt(data) ⇒ Object
Decrypts an EncryptedData section of an XML document.
17 18 19 20 |
# File 'lib/xml/kit/decryption.rb', line 17 def decrypt(data) ::Xml::Kit.deprecate('decrypt is deprecated. Use decrypt_xml or decrypt_hash instead.') decrypt_hash(data) end |
#decrypt_hash(hash) ⇒ Object
Decrypts an EncryptedData section of an XML document.
32 33 34 35 36 37 38 39 |
# File 'lib/xml/kit/decryption.rb', line 32 def decrypt_hash(hash) encrypted_data = hash['EncryptedData'] symmetric_key = symmetric_key_from(encrypted_data) cipher_value = encrypted_data['CipherData']['CipherValue'] cipher_text = Base64.decode64(cipher_value) algorithm = encrypted_data['EncryptionMethod']['Algorithm'] to_plaintext(cipher_text, symmetric_key, algorithm) end |
#decrypt_node(node) ⇒ Object
Decrypts an EncryptedData Nokogiri::XML::Element.
44 45 46 47 48 |
# File 'lib/xml/kit/decryption.rb', line 44 def decrypt_node(node) return node unless !node.nil? && node.name == 'EncryptedData' node.parent.replace(decrypt_xml(node.to_s))[0] end |
#decrypt_xml(raw_xml) ⇒ Object
Decrypts an EncryptedData section of an XML document.
25 26 27 |
# File 'lib/xml/kit/decryption.rb', line 25 def decrypt_xml(raw_xml) decrypt_hash(Hash.from_xml(raw_xml)) end |