Class: SAML2::KeyDescriptor

Inherits:
KeyInfo show all
Defined in:
lib/saml2/key.rb

Defined Under Namespace

Modules: Type Classes: EncryptionMethod

Instance Attribute Summary collapse

Attributes inherited from KeyInfo

#key, #x509

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from KeyInfo

#certificate, #fingerprint, format_fingerprint, #public_key

Methods inherited from Base

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

Constructor Details

#initialize(x509 = nil, use = nil, encryption_methods = []) ⇒ KeyDescriptor

Returns a new instance of KeyDescriptor.

Parameters:

  • x509 (String) (defaults to: nil)

    The PEM encoded certificate.

  • use (defaults to: nil)

    optional [String] See Type

  • encryption_methods (Array<EncryptionMethod>) (defaults to: [])


151
152
153
154
155
156
# File 'lib/saml2/key.rb', line 151

def initialize(x509 = nil, use = nil, encryption_methods = [])
  super()
  @use = use
  self.x509 = x509
  @encryption_methods = encryption_methods
end

Instance Attribute Details

#encryption_methodsArray<EncryptionMethod>

Returns:



139
140
141
# File 'lib/saml2/key.rb', line 139

def encryption_methods
  @encryption_methods
end

#useString

Returns:

  • (String)

See Also:



137
138
139
# File 'lib/saml2/key.rb', line 137

def use
  @use
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.



167
168
169
170
171
172
173
174
175
# File 'lib/saml2/key.rb', line 167

def build(builder)
  builder["md"].KeyDescriptor do |key_descriptor|
    key_descriptor.parent["use"] = use if use
    super(key_descriptor)
    encryption_methods.each do |method|
      method.build(key_descriptor)
    end
  end
end

#encryption?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/saml2/key.rb', line 158

def encryption?
  use.nil? || use == Type::ENCRYPTION
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


142
143
144
145
146
# File 'lib/saml2/key.rb', line 142

def from_xml(node)
  super(node.at_xpath("dsig:KeyInfo", Namespaces::ALL))
  self.use = node["use"]
  self.encryption_methods = load_object_array(node, "md:EncryptionMethod", EncryptionMethod)
end

#signing?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/saml2/key.rb', line 162

def signing?
  use.nil? || use == Type::SIGNING
end