Sha256: 73b6ca5b02855aec86970e5b4dd221a410c768d24015fb83e8de464e56d60184

Contents?: true

Size: 814 Bytes

Versions: 8

Compression:

Stored size: 814 Bytes

Contents

require 'addressable/uri'

class CASino::ProxyTicket < ActiveRecord::Base
  attr_accessible :ticket, :service
  validates :ticket, uniqueness: true
  belongs_to :proxy_granting_ticket
  has_many :proxy_granting_tickets, as: :granter, dependent: :destroy

  def self.cleanup_unconsumed
    self.destroy_all(['created_at < ? AND consumed = ?', CASino.config.proxy_ticket[:lifetime_unconsumed].seconds.ago, false])
  end

  def self.cleanup_consumed
    self.destroy_all(['created_at < ? AND consumed = ?', CASino.config.proxy_ticket[:lifetime_consumed].seconds.ago, true])
  end

  def expired?
    lifetime = if consumed?
      CASino.config.proxy_ticket[:lifetime_consumed]
    else
      CASino.config.proxy_ticket[:lifetime_unconsumed]
    end
    (Time.now - (self.created_at || Time.now)) > lifetime
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
casino-2.0.7 app/models/casino/proxy_ticket.rb
casino-2.0.6 app/models/casino/proxy_ticket.rb
casino-2.0.5 app/models/casino/proxy_ticket.rb
casino-2.0.4 app/models/casino/proxy_ticket.rb
casino-2.0.3 app/models/casino/proxy_ticket.rb
casino-2.0.2 app/models/casino/proxy_ticket.rb
casino-2.0.1 app/models/casino/proxy_ticket.rb
casino-2.0.0 app/models/casino/proxy_ticket.rb