Class: Samlr::Condition
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#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.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #audience_satisfied? ⇒ Boolean
-
#initialize(condition, options) ⇒ Condition
constructor
A new instance of Condition.
- #not_before_satisfied? ⇒ Boolean
- #not_on_or_after_satisfied? ⇒ Boolean
- #verify! ⇒ Object
Constructor Details
#initialize(condition, options) ⇒ Condition
Returns a new instance of Condition.
5 6 7 8 9 10 |
# File 'lib/samlr/condition.rb', line 5 def initialize(condition, ) @options = @not_before = (condition || {})["NotBefore"] @not_on_or_after = (condition || {})["NotOnOrAfter"] @audience = extract_audience(condition) end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
3 4 5 |
# File 'lib/samlr/condition.rb', line 3 def audience @audience end |
#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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/samlr/condition.rb', line 3 def @options end |
Instance Method Details
#audience_satisfied? ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/samlr/condition.rb', line 36 def audience_satisfied? [:audience].nil? || audience.nil? || audience.empty? || audience.any? { |a| [:audience] === a } end |
#not_before_satisfied? ⇒ Boolean
28 29 30 |
# File 'lib/samlr/condition.rb', line 28 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
32 33 34 |
# File 'lib/samlr/condition.rb', line 32 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/samlr/condition.rb', line 12 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 unless audience_satisfied? raise Samlr::ConditionsError.new("Audience violation, expected #{[:audience]} vs. #{audience}") end true end |