Class: SAML2::Conditions

Inherits:
Array
  • Object
show all
Defined in:
lib/saml2/conditions.rb

Defined Under Namespace

Classes: AudienceRestriction, Condition, OneTimeUse

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#not_beforeObject

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_afterObject

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

Instance Method Details

#build(builder) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/saml2/conditions.rb', line 28

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

#valid?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/saml2/conditions.rb', line 7

def valid?(options = {})
  now = options[: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?(options)
    case this_result
    when :invalid
      return :invalid
    when :indeterminate
      result = :indeterminate
      when :valid
    else
      raise "unknown validity of #{condition}"
    end
  end
  result
end