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)


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

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

Instance Attribute Details

#algorithmString

Returns:

  • (String)

See Also:



104
105
106
# File 'lib/saml2/key.rb', line 104

def algorithm
  @algorithm
end

#key_sizeInteger

Returns:

  • (Integer)


106
107
108
# File 'lib/saml2/key.rb', line 106

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.



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

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)


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

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