Class: RSAML::Protocol::Response
- Defined in:
- lib/rsaml/protocol/response.rb
Overview
A SAML response
Instance Attribute Summary collapse
-
#in_response_to ⇒ Object
A reference to the identifier of the request to which the response corresponds, if any.
-
#status ⇒ Object
A code representing the status of the corresponding request.
Attributes inherited from Message
#consent, #destination, #id, #issue_instant, #issuer, #signature, #version
Instance Method Summary collapse
-
#assertions ⇒ Object
SAML assertions.
-
#encrypted_assertions ⇒ Object
SAML encrypted assertions.
-
#initialize(status) ⇒ Response
constructor
Initialize the Response instance.
-
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the request.
-
#validate ⇒ Object
Validate the request structure.
Methods inherited from Message
Constructor Details
#initialize(status) ⇒ Response
Initialize the Response instance
16 17 18 19 |
# File 'lib/rsaml/protocol/response.rb', line 16 def initialize(status) super() @status = status end |
Instance Attribute Details
#in_response_to ⇒ Object
A reference to the identifier of the request to which the response corresponds, if any. If the response is not generated in response to a request, or if the ID attribute value of a request cannot be determined (for example, the request is malformed), then this attribute MUST NOT be present. Otherwise, it MUST be present and its value MUST match the value of the corresponding request’s ID attribute.
10 11 12 |
# File 'lib/rsaml/protocol/response.rb', line 10 def in_response_to @in_response_to end |
#status ⇒ Object
A code representing the status of the corresponding request.
13 14 15 |
# File 'lib/rsaml/protocol/response.rb', line 13 def status @status end |
Instance Method Details
#assertions ⇒ Object
SAML assertions
22 23 24 |
# File 'lib/rsaml/protocol/response.rb', line 22 def assertions @assertions ||= [] end |
#encrypted_assertions ⇒ Object
SAML encrypted assertions
27 28 29 |
# File 'lib/rsaml/protocol/response.rb', line 27 def encrypted_assertions @encrypted_assertions ||= [] end |
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the request
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rsaml/protocol/response.rb', line 39 def to_xml(xml=Builder::XmlMarkup.new) attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.xmlschema} attributes['InResponseTo'] = in_response_to unless in_response_to.nil? attributes['Destination'] = destination unless destination.nil? attributes['Consent'] = unless .nil? attributes = add_xmlns(attributes) xml.tag!('samlp:Response', attributes) { xml << issuer.to_xml unless issuer.nil? xml << signature.to_xml unless signature.nil? # TODO: add extensions support xml << status.to_xml unless status.nil? assertions.each { |assertion| xml << assertion.to_xml } encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml } } end |
#validate ⇒ Object
Validate the request structure
32 33 34 35 36 |
# File 'lib/rsaml/protocol/response.rb', line 32 def validate super raise ValidationError, "Status must be specified" if status.nil? raise ValidationError, "Status must be a RSAML::Protocol::Status instance" unless status.is_a?(Status) end |