Class: Xml::Kit::Decryption
- Inherits:
-
Object
- Object
- Xml::Kit::Decryption
- Defined in:
- lib/xml/kit/decryption.rb
Overview
Instance Attribute Summary collapse
-
#cipher_registry ⇒ Object
readonly
The list of private keys to use to attempt to decrypt the document.
-
#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:, cipher_registry: ::Xml::Kit::Crypto) ⇒ Decryption
constructor
A new instance of Decryption.
Constructor Details
#initialize(private_keys:, cipher_registry: ::Xml::Kit::Crypto) ⇒ Decryption
Returns a new instance of Decryption.
10 11 12 13 |
# File 'lib/xml/kit/decryption.rb', line 10 def initialize(private_keys:, cipher_registry: ::Xml::Kit::Crypto) @private_keys = private_keys @cipher_registry = cipher_registry end |
Instance Attribute Details
#cipher_registry ⇒ 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 cipher_registry @cipher_registry end |
#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.
18 19 20 21 |
# File 'lib/xml/kit/decryption.rb', line 18 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.
33 34 35 36 37 38 39 40 |
# File 'lib/xml/kit/decryption.rb', line 33 def decrypt_hash(hash) encrypted_data = hash['EncryptedData'] to_plaintext( Base64.decode64(encrypted_data['CipherData']['CipherValue']), symmetric_key_from(encrypted_data), encrypted_data['EncryptionMethod']['Algorithm'] ) end |
#decrypt_node(node) ⇒ Object
Decrypts an EncryptedData Nokogiri::XML::Element.
45 46 47 48 49 |
# File 'lib/xml/kit/decryption.rb', line 45 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.
26 27 28 |
# File 'lib/xml/kit/decryption.rb', line 26 def decrypt_xml(raw_xml) decrypt_hash(Hash.from_xml(raw_xml)) end |