Class: Saml::Kit::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/kit/parser.rb

Instance Method Summary collapse

Instance Method Details

#metadata_from(content) ⇒ Saml::Kit::Metadata

Creates a `Metadata` object from a raw XML [String].

Parameters:

  • content (String)

    the raw metadata XML.

Returns:


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/saml/kit/parser.rb', line 10

def (content)
  document = Nokogiri::XML(content)
  return unless document.at_xpath('/md:EntityDescriptor', XmlParseable::NAMESPACES)

  xpath = '/md:EntityDescriptor/md:SPSSODescriptor'
  sp = document.at_xpath(xpath, XmlParseable::NAMESPACES)
  xpath = '/md:EntityDescriptor/md:IDPSSODescriptor'
  idp = document.at_xpath(xpath, XmlParseable::NAMESPACES)
  if sp && idp
    Saml::Kit::CompositeMetadata.new(content)
  elsif sp
    Saml::Kit::ServiceProviderMetadata.new(content)
  elsif idp
    Saml::Kit::IdentityProviderMetadata.new(content)
  end
end