Class: Xmlenc::EncryptedData
- Inherits:
-
Object
- Object
- Xmlenc::EncryptedData
- Defined in:
- lib/xmlenc/encrypted_data.rb
Constant Summary collapse
- ALGORITHMS =
{ 'http://www.w3.org/2001/04/xmlenc#tripledes-cbc' => Algorithms::DES3CBC, 'http://www.w3.org/2001/04/xmlenc#aes128-cbc' => Algorithms::AESCBC[128], 'http://www.w3.org/2001/04/xmlenc#aes256-cbc' => Algorithms::AESCBC[256] }
Instance Attribute Summary collapse
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #cipher_value ⇒ Object
- #decrypt(key) ⇒ Object
- #document ⇒ Object
- #encryption_method ⇒ Object
-
#initialize(node) ⇒ EncryptedData
constructor
A new instance of EncryptedData.
Constructor Details
#initialize(node) ⇒ EncryptedData
Returns a new instance of EncryptedData.
11 12 13 |
# File 'lib/xmlenc/encrypted_data.rb', line 11 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
9 10 11 |
# File 'lib/xmlenc/encrypted_data.rb', line 9 def node @node end |
Instance Method Details
#cipher_value ⇒ Object
23 24 25 |
# File 'lib/xmlenc/encrypted_data.rb', line 23 def cipher_value at_xpath('./xenc:CipherData/xenc:CipherValue').content.gsub(/[\n\s]/, '') end |
#decrypt(key) ⇒ Object
27 28 29 30 |
# File 'lib/xmlenc/encrypted_data.rb', line 27 def decrypt(key) decryptor = algorithm.setup(key) decryptor.decrypt(Base64.decode64(cipher_value), node: encryption_method) end |
#document ⇒ Object
15 16 17 |
# File 'lib/xmlenc/encrypted_data.rb', line 15 def document @node.document end |
#encryption_method ⇒ Object
19 20 21 |
# File 'lib/xmlenc/encrypted_data.rb', line 19 def encryption_method at_xpath('./xenc:EncryptionMethod') end |