module Samlr::Tools::LogoutResponseBuilder
Use this for building the SAML logout response XML
Public Class Methods
build(options = {})
click to toggle source
# File lib/samlr/tools/logout_response_builder.rb, line 7 def self.build(options = {}) status_code = options[:status_code] || "urn:oasis:names:tc:SAML:2.0:status:Success" builder = Nokogiri::XML::Builder.new do |xml| xml.LogoutResponse(logout_response_options(options)) do xml.doc.root.namespace = xml.doc.root.namespace_definitions.find { |ns| ns.prefix == "samlp" } xml["saml"].Issuer(options[:issuer]) if options[:issuer] xml["samlp"].Status { |xml| xml["samlp"].StatusCode("Value" => status_code) } end end builder.to_xml(COMPACT) end
logout_response_options(options)
click to toggle source
# File lib/samlr/tools/logout_response_builder.rb, line 19 def self.logout_response_options(options) result = { "xmlns:samlp" => NS_MAP["samlp"], "xmlns:saml" => NS_MAP["saml"], "ID" => Samlr::Tools.uuid, "IssueInstant" => Samlr::Tools::Timestamp.stamp, "Version" => "2.0" } result["InResponseTo"] = options[:in_response_to] if options[:in_response_to] result["Destination"] = options[:destination] if options[:destination] result end