Class: SAML2::Conditions
- Inherits:
-
Array
- Object
- Array
- SAML2::Conditions
- Defined in:
- lib/saml2/conditions.rb
Defined Under Namespace
Classes: AudienceRestriction, Condition, OneTimeUse
Instance Attribute Summary collapse
-
#not_before ⇒ Object
Returns the value of attribute not_before.
-
#not_on_or_after ⇒ Object
Returns the value of attribute not_on_or_after.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#not_before ⇒ Object
Returns the value of attribute not_before.
5 6 7 |
# File 'lib/saml2/conditions.rb', line 5 def not_before @not_before end |
#not_on_or_after ⇒ Object
Returns the value of attribute not_on_or_after.
5 6 7 |
# File 'lib/saml2/conditions.rb', line 5 def not_on_or_after @not_on_or_after end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
6 7 8 |
# File 'lib/saml2/conditions.rb', line 6 def xml @xml end |
Class Method Details
.from_xml(node) ⇒ Object
8 9 10 11 12 |
# File 'lib/saml2/conditions.rb', line 8 def self.from_xml(node) result = new result.from_xml(node) result end |
Instance Method Details
#build(builder) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/saml2/conditions.rb', line 43 def build(builder) builder['saml'].Conditions do |conditions| conditions.parent['NotBefore'] = not_before.iso8601 if not_before conditions.parent['NotOnOrAfter'] = not_on_or_after.iso8601 if not_on_or_after each do |condition| condition.build(conditions) end end end |
#from_xml(node) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/saml2/conditions.rb', line 14 def from_xml(node) @xml = node @not_before = Time.parse(node['NotBefore']) if node['NotBefore'] @not_on_or_after = Time.parse(node['NotOnOrAfter']) if node['NotOnOrAfter'] replace(node.children.map { |restriction| self.class.const_get(restriction.name, false).from_xml(restriction) }) end |
#valid?(options = {}) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/saml2/conditions.rb', line 22 def valid?( = {}) now = [:now] || Time.now return :invalid if not_before && now < not_before return :invalid if not_on_or_after && now >= not_on_or_after result = :valid each do |condition| this_result = condition.valid?() case this_result when :invalid return :invalid when :indeterminate result = :indeterminate when :valid else raise "unknown validity of #{condition}" end end result end |