Class: RSAML::Protocol::Request

Inherits:
Message
  • Object
show all
Defined in:
lib/rsaml/protocol/request.rb

Overview

A SAML request

Direct Known Subclasses

AuthnRequest, Query::SubjectQuery

Instance Attribute Summary

Attributes inherited from Message

#consent, #destination, #id, #issue_instant, #issuer, #signature, #version

Instance Method Summary collapse

Methods inherited from Message

#extensions, #initialize, #validate

Constructor Details

This class inherits a constructor from RSAML::Protocol::Message

Instance Method Details

#respond(status) ⇒ Object

Generate a Response instance with the given status code. The response’s in_response_to attribute will be set to the ID of the request.



7
8
9
10
11
# File 'lib/rsaml/protocol/request.rb', line 7

def respond(status)
  response = Response.new(status)
  response.in_response_to = id
  response
end

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object

Construct an XML fragment representing the request



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rsaml/protocol/request.rb', line 14

def to_xml(xml=Builder::XmlMarkup.new)
  attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.xmlschema}
  attributes['Destination'] = destination unless destination.nil?
  attributes['Consent'] = consent unless consent.nil?
  attributes = add_xmlns(attributes)
  xml.tag!('samlp:Request', attributes) {
    xml << issuer.to_xml unless issuer.nil?
    xml << signature.to_xml unless signature.nil?
    # TODO: add extensions support
  }
end