class Xmlenc::Builder::EncryptedKey

Constants

ALGORITHMS

Attributes

data[RW]

Public Class Methods

new(*args) click to toggle source
# File lib/xmlenc/builder/encrypted_key.rb, line 34
def initialize(*args)
  options = args.extract_options!
  @recipient = options.delete(:recipient)
  @id = options.delete(:id)
  super(*(args << options))
end

Public Instance Methods

add_data_reference(data_id) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

algorithm() click to toggle source
# File lib/xmlenc/builder/encrypted_key.rb, line 43
def algorithm
  algorithm = encryption_method.algorithm
  ALGORITHMS[algorithm] ||
      raise(UnsupportedError.new("Unsupported encryption method #{algorithm}"))
end