Class: RubyCAS::Server::Core::Tickets::TicketGrantingTicket

Inherits:
Storage
  • Object
show all
Defined in:
lib/rubycas/server/memory/ticket_granting_ticket.rb

Direct Known Subclasses

ServiceTicket

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Storage

#save, #save!

Constructor Details

#initialize(tgt = {}) ⇒ TicketGrantingTicket

Returns a new instance of TicketGrantingTicket.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 10

def initialize(tgt = {})
  @id = SecureRandom.uuid
  @ticket = tgt[:ticket]
  @client_hostname = tgt[:client_hostname]
  @username = tgt[:username]
  @extra_attributes = tgt[:extra_attributes]
  @service_tickets = tgt[:service_tickets]
  @proxy_tickets = tgt[:proxy_tickets]
  @remember_me = tgt[:remember_me]
  @created_at = DateTime.now
  @updated_at = DateTime.now
  super()
end

Instance Attribute Details

#client_hostnameObject

Returns the value of attribute client_hostname.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def client_hostname
  @client_hostname
end

#created_atObject

Returns the value of attribute created_at.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def created_at
  @created_at
end

#extra_attributesObject

Returns the value of attribute extra_attributes.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def extra_attributes
  @extra_attributes
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def id
  @id
end

#proxy_ticketsObject

Returns the value of attribute proxy_tickets.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def proxy_tickets
  @proxy_tickets
end

#remember_meObject

Returns the value of attribute remember_me.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def remember_me
  @remember_me
end

#service_ticketsObject

Returns the value of attribute service_tickets.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def service_tickets
  @service_tickets
end

#ticketObject

Returns the value of attribute ticket.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def ticket
  @ticket
end

#updated_atObject

Returns the value of attribute updated_at.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def updated_at
  @updated_at
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 6

def username
  @username
end

Class Method Details

.find_by_ticket(ticket) ⇒ Object



24
25
26
27
28
29
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 24

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

Instance Method Details

#expired?(max_lifetime) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/rubycas/server/memory/ticket_granting_ticket.rb', line 31

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