Class: Samlr::Condition
Instance Attribute Summary collapse
-
#not_before ⇒ Object
readonly
Returns the value of attribute not_before.
-
#not_on_or_after ⇒ Object
readonly
Returns the value of attribute not_on_or_after.
Instance Method Summary collapse
-
#initialize(condition) ⇒ Condition
constructor
A new instance of Condition.
- #not_before_satisfied? ⇒ Boolean
- #not_on_or_after_satisfied? ⇒ Boolean
- #verify! ⇒ Object
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_before ⇒ Object (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_after ⇒ Object (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
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
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 |