Class: Xmlenc::Builder::EncryptedKey

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from ComplexTypes::EncryptedType

#initialize, #set_encryption_method

Instance Attribute Details

#dataObject

Returns the value of attribute data.



16
17
18
# File 'lib/xmlenc/builder/encrypted_key.rb', line 16

def data
  @data
end

Instance Method Details

#add_data_reference(data_id) ⇒ Object



24
25
26
27
# File 'lib/xmlenc/builder/encrypted_key.rb', line 24

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



18
19
20
21
22
# File 'lib/xmlenc/builder/encrypted_key.rb', line 18

def encrypt(key, data = nil)
  encryptor = algorithm.new(key)
  encrypted = encryptor.encrypt(data || self.data)
  cipher_data.cipher_value = Base64.encode64(encrypted)
end