Class: SAML2::ServiceProvider

Inherits:
SSO show all
Defined in:
lib/saml2/service_provider.rb

Instance Attribute Summary collapse

Attributes inherited from Role

#fingerprints, #keys, #private_keys, #supported_protocols

Attributes included from OrganizationAndContacts

#contacts, #organization

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from SSO

#name_id_formats, #single_logout_services

Methods inherited from Role

#encryption_keys, #signing_keys

Methods included from Signable

#sign, #signature, #signed?, #signing_key, #valid_signature?, #validate_signature

Methods inherited from Base

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

Constructor Details

#initializeServiceProvider

Returns a new instance of ServiceProvider.



12
13
14
15
16
17
18
# File 'lib/saml2/service_provider.rb', line 12

def initialize
  super
  @authn_requests_signed = nil
  @want_assertions_signed = nil
  @assertion_consumer_services = Endpoint::Indexed::Array.new
  @attribute_consuming_services = AttributeConsumingService::Array.new
end

Instance Attribute Details

#authn_requests_signed=(value) ⇒ Object (writeonly)

Sets the attribute authn_requests_signed

Parameters:

  • value

    the value to set the attribute authn_requests_signed to.



10
11
12
# File 'lib/saml2/service_provider.rb', line 10

def authn_requests_signed=(value)
  @authn_requests_signed = value
end

#want_assertions_signed=(value) ⇒ Object (writeonly)

Sets the attribute want_assertions_signed

Parameters:

  • value

    the value to set the attribute want_assertions_signed to.



10
11
12
# File 'lib/saml2/service_provider.rb', line 10

def want_assertions_signed=(value)
  @want_assertions_signed = value
end

Instance Method Details

#assertion_consumer_servicesEndpoint::Indexed::Array



46
47
48
49
50
51
# File 'lib/saml2/service_provider.rb', line 46

def assertion_consumer_services
  @assertion_consumer_services ||= begin
    nodes = xml.xpath("md:AssertionConsumerService", Namespaces::ALL)
    Endpoint::Indexed::Array.from_xml(nodes)
  end
end

#attribute_consuming_servicesAttributeConsumingService::Array



54
55
56
57
58
59
# File 'lib/saml2/service_provider.rb', line 54

def attribute_consuming_services
  @attribute_consuming_services ||= begin
    nodes = xml.xpath("md:AttributeConsumingService", Namespaces::ALL)
    AttributeConsumingService::Array.from_xml(nodes)
  end
end

#authn_requests_signed?Boolean?

Returns:

  • (Boolean, nil)


30
31
32
33
34
35
# File 'lib/saml2/service_provider.rb', line 30

def authn_requests_signed?
  unless instance_variable_defined?(:@authn_requests_signed)
    @authn_requests_signed = xml["AuthnRequestsSigned"] && xml["AuthnRequestsSigned"] == "true"
  end
  @authn_requests_signed
end

#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.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/saml2/service_provider.rb', line 62

def build(builder)
  builder["md"].SPSSODescriptor do |sp_sso_descriptor|
    super(sp_sso_descriptor)

    sp_sso_descriptor.parent["AuthnRequestsSigned"] = authn_requests_signed? unless authn_requests_signed?.nil?
    sp_sso_descriptor.parent["WantAssertionsSigned"] = want_assertions_signed? unless want_assertions_signed?.nil?

    assertion_consumer_services.each do |acs|
      acs.build(sp_sso_descriptor, "AssertionConsumerService")
    end

    attribute_consuming_services.each do |acs|
      acs.build(sp_sso_descriptor)
    end
  end
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


21
22
23
24
25
26
27
# File 'lib/saml2/service_provider.rb', line 21

def from_xml(node)
  super
  remove_instance_variable(:@authn_requests_signed)
  remove_instance_variable(:@want_assertions_signed)
  @assertion_consumer_services = nil
  @attribute_consuming_services = nil
end

#want_assertions_signed?Boolean?

Returns:

  • (Boolean, nil)


38
39
40
41
42
43
# File 'lib/saml2/service_provider.rb', line 38

def want_assertions_signed?
  unless instance_variable_defined?(:@want_assertions_signed)
    @want_assertions_signed = xml["WantAssertionsSigned"] && xml["WantAssertionsSigned"] == "true"
  end
  @want_assertions_signed
end