Class: Samlr::Condition

Inherits:
Object show all
Defined in:
lib/samlr/condition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition) ⇒ Condition

Returns a new instance of Condition.



5
6
7
8
# File 'lib/samlr/condition.rb', line 5

def initialize(condition)
  @not_before      = (condition || {})["NotBefore"]
  @not_on_or_after = (condition || {})["NotOnOrAfter"]
end

Instance Attribute Details

#not_beforeObject (readonly)

Returns the value of attribute not_before.



3
4
5
# File 'lib/samlr/condition.rb', line 3

def not_before
  @not_before
end

#not_on_or_afterObject (readonly)

Returns the value of attribute not_on_or_after.



3
4
5
# File 'lib/samlr/condition.rb', line 3

def not_on_or_after
  @not_on_or_after
end

Instance Method Details

#not_before_satisfied?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/samlr/condition.rb', line 22

def not_before_satisfied?
  not_before.nil? || Samlr::Tools::Timestamp.not_before?(Samlr::Tools::Timestamp.parse(not_before))
end

#not_on_or_after_satisfied?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/samlr/condition.rb', line 26

def not_on_or_after_satisfied?
  not_on_or_after.nil? || Samlr::Tools::Timestamp.not_on_or_after?(Samlr::Tools::Timestamp.parse(not_on_or_after))
end

#verify!Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/samlr/condition.rb', line 10

def verify!
  unless not_before_satisfied?
    raise Samlr::ConditionsError.new("Not before violation, now #{Samlr::Tools::Timestamp.stamp} vs. earliest #{not_before}")
  end

  unless not_on_or_after_satisfied?
    raise Samlr::ConditionsError.new("Not on or after violation, now #{Samlr::Tools::Timestamp.stamp} vs. at latest #{not_on_or_after}")
  end

  true
end