Class: Xmlenc::Builder::EncryptedData
- Inherits:
-
Object
- Object
- Xmlenc::Builder::EncryptedData
- Includes:
- ComplexTypes::EncryptedType
- Defined in:
- lib/xmlenc/builder/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] }
- TYPES =
{ 'http://www.w3.org/2001/04/xmlenc#Element' => :element, 'http://www.w3.org/2001/04/xmlenc#Content' => :content, }
Instance Method Summary collapse
- #encrypt(data) ⇒ Object
-
#initialize(attributes = {}) ⇒ EncryptedData
constructor
A new instance of EncryptedData.
- #type ⇒ Object
Methods included from ComplexTypes::EncryptedType
Constructor Details
#initialize(attributes = {}) ⇒ EncryptedData
Returns a new instance of EncryptedData.
26 27 28 29 |
# File 'lib/xmlenc/builder/encrypted_data.rb', line 26 def initialize(attributes = {}) super self.id = SecureRandom.hex(5) end |
Instance Method Details
#encrypt(data) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/xmlenc/builder/encrypted_data.rb', line 31 def encrypt(data) encryptor = algorithm.setup encrypted = encryptor.encrypt(data, node: encryption_method) cipher_data.cipher_value = Base64.encode64(encrypted) encrypted_key = EncryptedKey.new(data: encryptor.key) encrypted_key.add_data_reference(id) encrypted_key end |
#type ⇒ Object
22 23 24 |
# File 'lib/xmlenc/builder/encrypted_data.rb', line 22 def type 'http://www.w3.org/2001/04/xmlenc#Element' end |