class Samlr::Request
Attributes
document[R]
options[R]
Public Class Methods
new(data = nil, options = {})
click to toggle source
# File lib/samlr/request.rb, line 7 def initialize(data = nil, options = {}) @options = options @document = Request.parse(data) end
parse(data)
click to toggle source
# File lib/samlr/request.rb, line 40 def self.parse(data) Samlr::Tools.parse(data, compressed: true) end
Public Instance Methods
body()
click to toggle source
The XML payload body
# File lib/samlr/request.rb, line 18 def body @body ||= Samlr::Tools::RequestBuilder.build(options) end
get_attribute_or_element(x_path,attribute=nil)
click to toggle source
# File lib/samlr/request.rb, line 44 def get_attribute_or_element(x_path,attribute=nil) if document element = document.xpath(x_path) if element.length == 0 nil elsif attribute value = element.attr(attribute) value.to_s if value else element end else raise Samlr::NoDataError.new("Attempting to get attributes of a Request that has no data") end end
param()
click to toggle source
The encoded SAML request
# File lib/samlr/request.rb, line 13 def param @param ||= Samlr::Tools.encode(body) end
type()
click to toggle source
# File lib/samlr/request.rb, line 22 def type "SAMLRequest" end
url(root, params = {})
click to toggle source
Utility method to get the full redirect destination, Request#url
(“idp.example.com/saml”, { :RelayState => “sp.example.com/saml” })
# File lib/samlr/request.rb, line 27 def url(root, params = {}) dest = root.dup dest << (dest.include?("?") ? "&" : "?") dest << "#{type}=#{param}" params.each_pair do |key, value| dest << "&#{key}=#{CGI.escape(value.to_s)}" end dest end