Class: SAML2::Conditions::AudienceRestriction
- Defined in:
- lib/saml2/conditions.rb
Instance Attribute Summary collapse
-
#audience ⇒ Array<String>
Allowed audiences.
Attributes inherited from Base
Instance Method Summary collapse
-
#build(builder) ⇒ void
Serialize this object to XML, as part of a larger document.
-
#from_xml(node) ⇒ void
Parse an XML element into this object.
-
#initialize(audience = []) ⇒ AudienceRestriction
constructor
A new instance of AudienceRestriction.
- #validate(audience: nil, ignore_audience_condition: false, **_) ⇒ Object
Methods inherited from Condition
Methods inherited from Base
#decrypt, from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml
Constructor Details
#initialize(audience = []) ⇒ AudienceRestriction
Returns a new instance of AudienceRestriction.
97 98 99 100 |
# File 'lib/saml2/conditions.rb', line 97 def initialize(audience = []) super() @audience = audience end |
Instance Attribute Details
#audience ⇒ Array<String>
Returns Allowed audiences.
109 110 111 |
# File 'lib/saml2/conditions.rb', line 109 def audience @audience ||= load_string_array(xml, "saml:Audience") end |
Instance Method Details
#build(builder) ⇒ void
This method returns an undefined value.
Serialize this object to XML, as part of a larger document
125 126 127 128 129 130 131 |
# File 'lib/saml2/conditions.rb', line 125 def build(builder) builder["saml"].AudienceRestriction do |audience_restriction| Array.wrap(audience).each do |single_audience| audience_restriction["saml"].Audience(single_audience) end end end |
#from_xml(node) ⇒ void
This method returns an undefined value.
Parse an XML element into this object.
103 104 105 106 |
# File 'lib/saml2/conditions.rb', line 103 def from_xml(node) super @audience = nil end |
#validate(audience: nil, ignore_audience_condition: false, **_) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/saml2/conditions.rb', line 114 def validate(audience: nil, ignore_audience_condition: false, **_) return [] if ignore_audience_condition unless Array.wrap(self.audience).include?(audience) return ["audience #{audience} not in allowed list of #{Array.wrap(self.audience).join(", ")}"] end [] end |