Class: Saml::Kit::CompositeMetadata

Inherits:
Metadata
  • Object
show all
Includes:
Enumerable
Defined in:
lib/saml/kit/composite_metadata.rb

Overview

This class implements the Composite design pattern to allow client component to work with a metadata that provides an IDPSSODescriptor and SPSSODescriptor element.

Constant Summary

Constants included from XsdValidatable

XsdValidatable::METADATA_XSD, XsdValidatable::PROTOCOL_XSD

Constants included from XmlParseable

XmlParseable::NAMESPACES

Instance Attribute Summary collapse

Attributes inherited from Metadata

#content, #name

Instance Method Summary collapse

Methods inherited from Metadata

builder_class, #contact_person_company, #encryption_certificates, #entity_id, from, #logout_request_for, #matches?, #name_id_formats, #service_for, #signature, #signing_certificates, #single_logout_service_for, #single_logout_services, #verify

Methods included from XmlParseable

#present?, #to_h, #to_s, #to_xhtml, #to_xml

Constructor Details

#initialize(xml) ⇒ CompositeMetadata

Returns a new instance of CompositeMetadata


15
16
17
18
19
20
21
# File 'lib/saml/kit/composite_metadata.rb', line 15

def initialize(xml)
  super('IDPSSODescriptor', xml)
  @metadatum = [
    Saml::Kit::ServiceProviderMetadata.new(xml),
    Saml::Kit::IdentityProviderMetadata.new(xml),
  ]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object


54
55
56
57
58
59
60
# File 'lib/saml/kit/composite_metadata.rb', line 54

def method_missing(name, *args)
  if (target = find { |x| x.respond_to?(name) })
    target.public_send(name, *args)
  else
    super
  end
end

Instance Attribute Details

#identity_providerObject (readonly)

Returns the value of attribute identity_provider


13
14
15
# File 'lib/saml/kit/composite_metadata.rb', line 13

def identity_provider
  @identity_provider
end

#service_providerObject (readonly)

Returns the value of attribute service_provider


13
14
15
# File 'lib/saml/kit/composite_metadata.rb', line 13

def service_provider
  @service_provider
end

Instance Method Details

#certificatesObject


46
47
48
# File 'lib/saml/kit/composite_metadata.rb', line 46

def certificates
  flat_map(&:certificates)
end

#each(&block) ⇒ Object


50
51
52
# File 'lib/saml/kit/composite_metadata.rb', line 50

def each(&block)
  @metadatum.each(&block)
end

#organizationObject


23
24
25
# File 'lib/saml/kit/composite_metadata.rb', line 23

def organization
  find { |x| x.organization.present? }.try(:organization)
end

#organization_nameObject


27
28
29
# File 'lib/saml/kit/composite_metadata.rb', line 27

def organization_name
  organization.name
end

#organization_urlObject


31
32
33
# File 'lib/saml/kit/composite_metadata.rb', line 31

def organization_url
  organization.url
end

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)

62
63
64
# File 'lib/saml/kit/composite_metadata.rb', line 62

def respond_to_missing?(method, *)
  find { |x| x.respond_to?(method) }
end

#services(type) ⇒ Object


35
36
37
38
39
40
41
42
43
44
# File 'lib/saml/kit/composite_metadata.rb', line 35

def services(type)
  xpath = map do |x|
    "//md:EntityDescriptor/md:#{x.name}/md:#{type}"
  end.join('|')
  search(xpath).map do |item|
    binding = item.attribute('Binding').value
    location = item.attribute('Location').value
    Saml::Kit::Bindings.create_for(binding, location)
  end
end