Class: Xmlenc::Builder::EncryptedKey
- Inherits:
-
Object
- Object
- Xmlenc::Builder::EncryptedKey
- Includes:
- ComplexTypes::EncryptedType
- Defined in:
- lib/xmlenc/builder/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 Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #add_data_reference(data_id) ⇒ Object
- #encrypt(key, data = nil) ⇒ Object
-
#initialize(*args) ⇒ EncryptedKey
constructor
A new instance of EncryptedKey.
Methods included from ComplexTypes::EncryptedType
#set_encryption_method, #set_key_name
Constructor Details
#initialize(*args) ⇒ EncryptedKey
Returns a new instance of EncryptedKey.
34 35 36 37 38 39 |
# File 'lib/xmlenc/builder/encrypted_key.rb', line 34 def initialize(*args) = args. @recipient = .delete(:recipient) @id = .delete(:id) super(*(args << )) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
21 22 23 |
# File 'lib/xmlenc/builder/encrypted_key.rb', line 21 def data @data end |
Instance Method Details
#add_data_reference(data_id) ⇒ Object
29 30 31 32 |
# File 'lib/xmlenc/builder/encrypted_key.rb', line 29 def add_data_reference(data_id) self.reference_list ||= ReferenceList.new self.reference_list.add_data_reference(data_id) end |
#encrypt(key, data = nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/xmlenc/builder/encrypted_key.rb', line 23 def encrypt(key, data = nil) encryptor = algorithm.new(key) encrypted = encryptor.encrypt(data || self.data) cipher_data.cipher_value = Base64.encode64(encrypted) end |