13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/onelogin/ruby-saml-nechotech/metadata.rb', line 13
def generate(settings)
meta_doc = REXML::Document.new
root = meta_doc.add_element "md:EntityDescriptor", {
"xmlns:md" => "urn:oasis:names:tc:SAML:2.0:metadata"
}
sp_sso = root.add_element "md:SPSSODescriptor", {
"protocolSupportEnumeration" => "urn:oasis:names:tc:SAML:2.0:protocol",
"AuthnRequestsSigned" => false,
"WantAssertionsSigned" => (!settings.idp_cert_fingerprint.nil? || !settings.idp_cert.nil?)
}
if settings.issuer != nil
root.attributes["entityID"] = settings.issuer
end
if settings.assertion_consumer_logout_service_url != nil
sp_sso.add_element "md:SingleLogoutService", {
"Binding" => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect",
"Location" => settings.assertion_consumer_logout_service_url,
"ResponseLocation" => settings.assertion_consumer_logout_service_url,
"isDefault" => true,
"index" => 0
}
end
if settings.name_identifier_format != nil
name_id = sp_sso.add_element "md:NameIDFormat"
name_id.text = settings.name_identifier_format
end
if settings.assertion_consumer_service_url != nil
sp_sso.add_element "md:AssertionConsumerService", {
"Binding" => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
"Location" => settings.assertion_consumer_service_url,
"isDefault" => true,
"index" => 0
}
end
meta_doc << REXML::XMLDecl.new
ret = ""
meta_doc.write(ret, 1)
Logging.debug "Generated metadata:\n#{ret}"
ret
end
|