Class: Xml::Kit::EncryptedData

Inherits:
Object
  • Object
show all
Defined in:
lib/xml/kit/encrypted_data.rb

Overview

An implementation of the EncryptedKey element. www.w3.org/TR/xmlenc-core1/#sec-EncryptedData

Since:

  • 0.3.0

Direct Known Subclasses

Encryption

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_xml, symmetric_cipher:, asymmetric_cipher:, key_info: nil) ⇒ EncryptedData

Returns a new instance of EncryptedData.

Since:

  • 0.3.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xml/kit/encrypted_data.rb', line 14

def initialize(
  raw_xml,
  symmetric_cipher:,
  asymmetric_cipher:,
  key_info: nil
)
  @symmetric_cipher = symmetric_cipher
  @symmetric_cipher_value = Base64.strict_encode64(
    symmetric_cipher.encrypt(raw_xml)
  )
  @key_info = key_info || create_key_info_for(
    symmetric_cipher,
    asymmetric_cipher
  )
end

Instance Attribute Details

#key_infoObject (readonly)

Since:

  • 0.3.0



10
11
12
# File 'lib/xml/kit/encrypted_data.rb', line 10

def key_info
  @key_info
end

#symmetric_cipherObject (readonly)

Since:

  • 0.3.0



11
12
13
# File 'lib/xml/kit/encrypted_data.rb', line 11

def symmetric_cipher
  @symmetric_cipher
end

#symmetric_cipher_valueObject (readonly)

Since:

  • 0.3.0



12
13
14
# File 'lib/xml/kit/encrypted_data.rb', line 12

def symmetric_cipher_value
  @symmetric_cipher_value
end

Instance Method Details

#render(model, options) ⇒ Object

Since:

  • 0.3.0



34
35
36
# File 'lib/xml/kit/encrypted_data.rb', line 34

def render(model, options)
  ::Xml::Kit::Template.new(model).to_xml(options)
end

#to_xml(xml: ::Builder::XmlMarkup.new) ⇒ Object

Since:

  • 0.3.0



30
31
32
# File 'lib/xml/kit/encrypted_data.rb', line 30

def to_xml(xml: ::Builder::XmlMarkup.new)
  ::Xml::Kit::Template.new(self).to_xml(xml: xml)
end