Class: OpenToken::Token
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- OpenToken::Token
- Defined in:
- lib/opentoken-newrelic-rails23/token.rb
Instance Method Summary collapse
- #end_at ⇒ Object
- #expired? ⇒ Boolean
- #start_at ⇒ Object
-
#valid? ⇒ Boolean
verify that the current time is between the not-before and not-on-or-after values.
- #valid_until ⇒ Object
- #validate! ⇒ Object
Instance Method Details
#end_at ⇒ Object
21 22 23 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 21 def end_at payload_date('not-on-or-after') end |
#expired? ⇒ Boolean
15 16 17 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 15 def expired? !valid? end |
#start_at ⇒ Object
18 19 20 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 18 def start_at payload_date('not-before') end |
#valid? ⇒ Boolean
verify that the current time is between the not-before and not-on-or-after values
12 13 14 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 12 def valid? start_at.past? && end_at.future? end |
#valid_until ⇒ Object
24 25 26 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 24 def valid_until payload_date('renew-until') end |
#validate! ⇒ Object
8 9 10 |
# File 'lib/opentoken-newrelic-rails23/token.rb', line 8 def validate! raise OpenToken::TokenExpiredError.new("#{Time.now.utc} is not within token duration: #{self.start_at} - #{self.end_at}") if self.expired? end |