Class: Xmlenc::EncryptedKey
- Inherits:
-
Object
- Object
- Xmlenc::EncryptedKey
- Defined in:
- lib/xmlenc/encrypted_key.rb
Constant Summary collapse
- ALGORITHMS =
{ 'http://www.w3.org/2001/04/xmlenc#rsa-1_5' => Algorithms::RSA15, 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p' => Algorithms::RsaOaepMgf1p }
Instance Method Summary collapse
- #cipher_value ⇒ Object
- #cipher_value=(value) ⇒ Object
- #decrypt(key) ⇒ Object
- #document ⇒ Object
- #encrypt(key, data) ⇒ Object
- #encrypted_data ⇒ Object
- #encryption_method ⇒ Object
-
#initialize(node) ⇒ EncryptedKey
constructor
A new instance of EncryptedKey.
Constructor Details
#initialize(node) ⇒ EncryptedKey
Returns a new instance of EncryptedKey.
8 9 10 |
# File 'lib/xmlenc/encrypted_key.rb', line 8 def initialize(node) @node = node end |
Instance Method Details
#cipher_value ⇒ Object
24 25 26 |
# File 'lib/xmlenc/encrypted_key.rb', line 24 def cipher_value at_xpath('./xenc:CipherData/xenc:CipherValue').content.gsub(/[\n\s]/, '') end |
#cipher_value=(value) ⇒ Object
28 29 30 |
# File 'lib/xmlenc/encrypted_key.rb', line 28 def cipher_value=(value) at_xpath('./xenc:CipherData/xenc:CipherValue').content = value end |
#decrypt(key) ⇒ Object
32 33 34 35 |
# File 'lib/xmlenc/encrypted_key.rb', line 32 def decrypt(key) decryptor = algorithm.new(key) decryptor.decrypt(Base64.decode64(cipher_value), :node => encryption_method) end |
#document ⇒ Object
12 13 14 |
# File 'lib/xmlenc/encrypted_key.rb', line 12 def document @node.document end |
#encrypt(key, data) ⇒ Object
37 38 39 40 41 |
# File 'lib/xmlenc/encrypted_key.rb', line 37 def encrypt(key, data) encryptor = algorithm.new(key) encrypted = encryptor.encrypt(data, :node => encryption_method) self.cipher_value = Base64.encode64(encrypted) end |
#encrypted_data ⇒ Object
20 21 22 |
# File 'lib/xmlenc/encrypted_key.rb', line 20 def encrypted_data EncryptedData.new(referenced_node) end |
#encryption_method ⇒ Object
16 17 18 |
# File 'lib/xmlenc/encrypted_key.rb', line 16 def encryption_method at_xpath('./xenc:EncryptionMethod') end |