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
deprecated
Deprecated.
Use #decrypt_hash instead of this
-
#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
Use #decrypt_hash instead of this
Decrypts an EncryptedData section of an XML document.
19 20 21 22 23 24 |
# File 'lib/xml/kit/decryption.rb', line 19 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.
36 37 38 39 40 41 42 43 |
# File 'lib/xml/kit/decryption.rb', line 36 def decrypt_hash(hash) data = hash['EncryptedData'] to_plaintext( Base64.decode64(data['CipherData']['CipherValue']), symmetric_key_from(data['KeyInfo']['EncryptedKey']), data['EncryptionMethod']['Algorithm'] ) end |
#decrypt_node(node) ⇒ Object
Decrypts an EncryptedData Nokogiri::XML::Element.
48 49 50 51 52 |
# File 'lib/xml/kit/decryption.rb', line 48 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.
29 30 31 |
# File 'lib/xml/kit/decryption.rb', line 29 def decrypt_xml(raw_xml) decrypt_hash(Hash.from_xml(raw_xml)) end |