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
|
# File 'lib/saml/util.rb', line 35
def sign_xml(message, format = :xml, include_nested_prefixlist = false, &block)
message.add_signature
document = Xmldsig::SignedDocument.new(message.send("to_#{format}"))
if Saml::Config.include_nested_prefixlist || include_nested_prefixlist
document.signatures.reverse.each_with_object([]) do |signature, nested_prefixlist|
inclusive_namespaces = signature.signature.at_xpath('descendant::ec:InclusiveNamespaces', Xmldsig::NAMESPACES)
if inclusive_namespaces
nested_prefixlist.concat(inclusive_namespaces.get_attribute('PrefixList').to_s.split(' '))
if signature.unsigned?
inclusive_namespaces.set_attribute('PrefixList', nested_prefixlist.uniq.join(' '))
end
end
end
end
if block_given?
document.sign(&block)
else
document.sign do |data, signature_algorithm|
message.provider.sign(signature_algorithm, data)
end
end
end
|