Class: RSAML::Protocol::Query::AttributeQuery
- Inherits:
-
SubjectQuery
- Object
- Message
- Request
- SubjectQuery
- RSAML::Protocol::Query::AttributeQuery
- Defined in:
- lib/rsaml/protocol/query/attribute_query.rb
Overview
used to make the query “Return the requested attributes for this subject.” A successful response will be in the form of assertions containing attribute statements, to the extent allowed by policy.
Instance Attribute Summary
Attributes inherited from SubjectQuery
Attributes inherited from Message
#consent, #destination, #id, #issue_instant, #issuer, #signature, #version
Class Method Summary collapse
-
.from_xml(element) ⇒ Object
Construct an AttributeQuery instance from the XML Element.
Instance Method Summary collapse
-
#attributes ⇒ Object
Each attribute element specifies an attribute whose value(s) are to be returned.
-
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the attribute query.
-
#validate ⇒ Object
Validate the structure of the attribute query.
Methods inherited from SubjectQuery
Methods inherited from Request
Methods inherited from Message
Constructor Details
This class inherits a constructor from RSAML::Protocol::Query::SubjectQuery
Class Method Details
.from_xml(element) ⇒ Object
Construct an AttributeQuery instance from the XML Element.
44 45 46 47 48 49 50 51 52 |
# File 'lib/rsaml/protocol/query/attribute_query.rb', line 44 def self.from_xml(element) element = REXML::Document.new(element).root if element.is_a?(String) subject = Subject.from_xml(element.get_elements('saml:Subject').first) attribute_query = AttributeQuery.new(subject) element.get_elements('saml:Attribute').each do |attribute_element| attribute_query.attributes << Attribute.from_xml(attribute_element) end attribute_query end |
Instance Method Details
#attributes ⇒ Object
Each attribute element specifies an attribute whose value(s) are to be returned. If no attributes are specified, it indicates that all attributes allowed by policy are requested. If a given attribute element contains one or more AttributeValue elements, then if that attribute is returned in the response, it MUST NOT contain any values that are not equal to the values specified in the query. In the absence of equality rules specified by particular profiles or attributes, equality is defined as an identical XML representation of the value. Each value in the array MUST be an Attribute instance.
14 15 16 |
# File 'lib/rsaml/protocol/query/attribute_query.rb', line 14 def attributes @attributes ||= [] end |
#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object
Construct an XML fragment representing the attribute query
35 36 37 38 39 40 41 |
# File 'lib/rsaml/protocol/query/attribute_query.rb', line 35 def to_xml(xml=Builder::XmlMarkup.new) xml_attributes = {} xml.tag!('samlp:AttributeQuery', xml_attributes) { xml << subject.to_xml unless subject.nil? attributes.each { |attribute| xml << attribute.to_xml } } end |
#validate ⇒ Object
Validate the structure of the attribute query.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rsaml/protocol/query/attribute_query.rb', line 19 def validate matched = {} duplicated_attributes = [] attributes.each do |attribute| if matched.has_key?(attribute.name) && matched[attribute.name] == attribute.name_format duplicated_attributes << attribute.name unless duplicated_attributes.include?(attribute.name) else matched[attribute.name] = attribute.name_format end end if !duplicated_attributes.empty? raise ValidationError, "An attribute with the same name and name format may only be specified once. The following attributes were specified multiple times: #{duplicated_attributes.join(',')}" end end |