Class: OneLogin::RubySaml::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/onelogin/ruby-saml/metadata.rb

Overview

SAML2 Metadata. XML Metadata Builder

Instance Method Summary collapse

Instance Method Details

#generate(settings, pretty_print = false, valid_until = nil, cache_duration = nil) ⇒ String

Return SP metadata based on the settings.

Parameters:

  • settings (OneLogin::RubySaml::Settings|nil)

    Toolkit settings

  • pretty_print (Boolean) (defaults to: false)

    Pretty print or not the response (No pretty print if you gonna validate the signature)

  • valid_until (DateTime) (defaults to: nil)

    Metadata’s valid time

  • cache_duration (Integer) (defaults to: nil)

    Duration of the cache in seconds

Returns:

  • (String)

    XML Metadata of the Service Provider



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/onelogin/ruby-saml/metadata.rb', line 22

def generate(settings, pretty_print=false, valid_until=nil, cache_duration=nil)
  meta_doc = XMLSecurity::Document.new
  add_xml_declaration(meta_doc)
  root = add_root_element(meta_doc, settings, valid_until, cache_duration)
  sp_sso = add_sp_sso_element(root, settings)
  add_sp_certificates(sp_sso, settings)
  add_sp_service_elements(sp_sso, settings)
  add_extras(root, settings)
  embed_signature(meta_doc, settings)
  output_xml(meta_doc, pretty_print)
end