Class: Samlr::Request
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#body ⇒ Object
The XML payload body.
- #get_attribute_or_element(x_path, attribute = nil) ⇒ Object
-
#initialize(data = nil, options = {}) ⇒ Request
constructor
A new instance of Request.
-
#param ⇒ Object
The encoded SAML request.
- #type ⇒ Object
-
#url(root, params = {}) ⇒ Object
Utility method to get the full redirect destination, Request#url(“idp.example.com/saml”, { :RelayState => “sp.example.com/saml” }).
Constructor Details
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'lib/samlr/request.rb', line 5 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/samlr/request.rb', line 5 def @options end |
Class Method Details
Instance Method Details
#body ⇒ Object
The XML payload body
18 19 20 |
# File 'lib/samlr/request.rb', line 18 def body @body ||= Samlr::Tools::RequestBuilder.build() end |
#get_attribute_or_element(x_path, attribute = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 ⇒ Object
The encoded SAML request
13 14 15 |
# File 'lib/samlr/request.rb', line 13 def param @param ||= Samlr::Tools.encode(body) end |
#type ⇒ Object
22 23 24 |
# File 'lib/samlr/request.rb', line 22 def type "SAMLRequest" end |
#url(root, params = {}) ⇒ Object
Utility method to get the full redirect destination, Request#url(“idp.example.com/saml”, { :RelayState => “sp.example.com/saml” })
27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 |