Sha256: 41c959afb10e56bdec5100d352836ae673f3bbf4d599ae8008c3c85810c8ca1b

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

class TicketGrantingTicket
  class << self
    def validate(ticket, store)
      if ticket && username = store[ticket]
        new(username, ticket)
      end
    end
    
    def create!(user, store)
      tgt = self.new(user)
      tgt.save!(store)
      tgt
    end
    
  end
  
  attr_reader :username
  
  def initialize(user, ticket = nil)
    @username = user
    @ticket = ticket
  end
    
  def ticket
    @ticket ||= "TGC-#{rand(100000000000000000)}".to_s
  end
  
  def destroy!(store)
    store.del self.ticket
  end
  
  def save!(store)
    store[ticket] = username
  end
    
  def to_cookie(domain, path = "/")
    ["tgt", {
      :value => ticket,
      # :domain => domain,
      :path => path
    }]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
classy_cas-0.9.3 lib/ticket_granting_ticket.rb
classy_cas-0.9.2 lib/ticket_granting_ticket.rb