Sha256: 93ccbe0adb979de98010db8b8d45ebbd78b6f8ce0fb4c6b9dcc63a4aa4c5e4a8

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module RubyCAS
  module Server
    module Core
      module Tickets
        class ProxyTicket < Storage

          attr_accessor :id, :ticket, :service, :consumed, :client_hostname,
                        :username, :created_at, :updated_at, :proxy_granting_ticket,
                        :ticket_granting_ticket

          def initialize(pt = {})
            @id = SecureRandom.uuid
            @ticket = pt[:ticket]
            @service = pt[:service]
            @consumed = pt[:consumed]
            @client_hostname = pt[:client_hostname]
            @username = pt[:username]
            @created_at = DateTime.now
            @updated_at = DateTime.now
            @proxy_granting_ticket = pt[:proxy_granting_ticket]
            @ticket_granting_ticket = pt[:ticket_granting_ticket]
            super()
          end


          def self.find_by_ticket(ticket)
            @storage.each do |id,pt|
              return pt if pt.ticket == ticket
            end
            return nil
          end

          def consumed?
            consumed
          end

          def consume!
            consumed = true
            self.save
          end

          def expired?(max_lifetime = 100)
            lifetime = Time.now.to_i - created_at.to_time.to_i
            lifetime > max_lifetime
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubycas-server-memory-0.0.2 lib/rubycas/server/memory/proxy_ticket.rb
rubycas-server-memory-0.0.1 lib/rubycas/server/memory/proxy_ticket.rb