Sha256: 3b45d6c7beeea5f7040e2b3f1e31a06fdd1aea189b3f34368dd16ac9165eeaf7

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 KB

Contents

module Castronaut
  module Models

    class TicketGrantingTicket < ActiveRecord::Base
      include Castronaut::Models::Consumeable
      include Castronaut::Models::Dispenser

      has_many :service_tickets, :dependent => :destroy

      before_validation :dispense_ticket, :if => :new_record?
      validates_presence_of :ticket, :username

      def self.validate_cookie(ticket_cookie)
        Castronaut.logger.debug("#{self} - Validating ticket for #{ticket_cookie}")

        return Castronaut::TicketResult.new(nil, "No ticket granting ticket given", 'warn') if ticket_cookie.nil?

        ticket_granting_ticket = find_by_ticket(ticket_cookie)

        if ticket_granting_ticket
          Castronaut.logger.debug("#{self} -[#{ticket_cookie}] for [#{ticket_granting_ticket.username}] successfully validated.")
          return Castronaut::TicketResult.new(ticket_granting_ticket, "Your session has expired. Please log in again.", 'warn') if ticket_granting_ticket.expired?
        else
          Castronaut.logger.debug("#{self} - [#{ticket_cookie}] was not found in the database.")
        end

        Castronaut::TicketResult.new(ticket_granting_ticket)
      end

      def self.generate_for(username, client_host)
        create! :username => username, :client_hostname => client_host
      end
      
      def ticket_prefix
        "TGC"
      end
      
      def proxies
      end

      def to_cookie
        ticket
      end

      def expired? 
        false
      end

    end

  end
end

Version data entries

19 entries across 19 versions & 5 rubygems

Version Path
masover-castronaut-0.4.4.4 lib/castronaut/models/ticket_granting_ticket.rb
p8-castronaut-0.6.1.1 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.1 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.2 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.3 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.4 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.5 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.4.6 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.5.0 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.5.1 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.5.2 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.5.3 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.5.4 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.6.0 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.6.1 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.7.4 lib/castronaut/models/ticket_granting_ticket.rb
relevance-castronaut-0.7.5 lib/castronaut/models/ticket_granting_ticket.rb
nbudin-castronaut-0.7.5 lib/castronaut/models/ticket_granting_ticket.rb
factorylabs-castronaut-0.7.5 lib/castronaut/models/ticket_granting_ticket.rb