Class: SAML2::KeyDescriptor::EncryptionMethod

Inherits:
Base
  • Object
show all
Defined in:
lib/saml2/key.rb

Defined Under Namespace

Modules: Algorithm

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

#decrypt, from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initialize(algorithm = Algorithm::AES128_CBC, key_size = 128) ⇒ EncryptionMethod

Returns a new instance of EncryptionMethod.

Parameters:

  • algorithm (String) (defaults to: Algorithm::AES128_CBC)
  • key_size (Integer) (defaults to: 128)


115
116
117
118
119
# File 'lib/saml2/key.rb', line 115

def initialize(algorithm = Algorithm::AES128_CBC, key_size = 128)
  super()
  @algorithm = algorithm
  @key_size = key_size
end

Instance Attribute Details

#algorithmString

Returns:

  • (String)

See Also:



109
110
111
# File 'lib/saml2/key.rb', line 109

def algorithm
  @algorithm
end

#key_sizeInteger

Returns:

  • (Integer)


111
112
113
# File 'lib/saml2/key.rb', line 111

def key_size
  @key_size
end

Instance Method Details

#build(builder) ⇒ void

This method returns an undefined value.

Serialize this object to XML, as part of a larger document

Parameters:

  • builder (Nokogiri::XML::Builder)

    The builder helper object to serialize to.



128
129
130
131
132
# File 'lib/saml2/key.rb', line 128

def build(builder)
  builder["md"].EncryptionMethod("Algorithm" => algorithm) do |encryption_method|
    encryption_method["xenc"].KeySize(key_size) if key_size
  end
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


122
123
124
125
# File 'lib/saml2/key.rb', line 122

def from_xml(node)
  self.algorithm = node["Algorithm"]
  self.key_size = node.at_xpath("xenc:KeySize", Namespaces::ALL)&.content&.to_i
end