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)


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

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:



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

def algorithm
  @algorithm
end

#key_sizeInteger

Returns:

  • (Integer)


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

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.



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

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)


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

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