Class: RSAML::Protocol::Query::AuthzDecisionQuery

Inherits:
SubjectQuery show all
Defined in:
lib/rsaml/protocol/query/authz_decision_query.rb

Overview

Used to make the query “Should these actions on this resource be allowed for this subject, given this evidence?” A successful response will be in the form of assertions containing authorization decision statements.

Instance Attribute Summary collapse

Attributes inherited from SubjectQuery

#subject

Attributes inherited from Message

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

Instance Method Summary collapse

Methods inherited from SubjectQuery

#initialize

Methods inherited from Request

#respond

Methods inherited from Message

#extensions, #initialize

Constructor Details

This class inherits a constructor from RSAML::Protocol::Query::SubjectQuery

Instance Attribute Details

#evidenceObject

A set of assertions that the SAML authority MAY rely on in making its authorization decision.



19
20
21
# File 'lib/rsaml/protocol/query/authz_decision_query.rb', line 19

def evidence
  @evidence
end

#resourceObject

A URI reference indicating the resource for which authorization is requested.



11
12
13
# File 'lib/rsaml/protocol/query/authz_decision_query.rb', line 11

def resource
  @resource
end

Instance Method Details

#actionsObject

The actions for which authorization is requested.



14
15
16
# File 'lib/rsaml/protocol/query/authz_decision_query.rb', line 14

def actions
  @actions ||= []
end

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

Construct an XML fragment representing the authorization decision query



29
30
31
32
33
34
35
36
# File 'lib/rsaml/protocol/query/authz_decision_query.rb', line 29

def to_xml(xml=Builder::XmlMarkup.new)
  attributes = {'Resource' => resource}
  xml.tag!('samlp:AuthzDecisionQuery', attributes) {
    xml << subject.to_xml unless subject.nil?
    actions.each { |action| xml << action.to_xml }
    xml << evidence.to_xml unless evidence.nil?
  }
end

#validateObject

Validate the query structure.

Raises:



22
23
24
25
26
# File 'lib/rsaml/protocol/query/authz_decision_query.rb', line 22

def validate
  raise ValidationError, "Resource is required" if resource.nil?
  raise ValidationError, "At least one action is required" if actions.empty?
  actions.each { |action| action.validate }
end