Class: RubyCAS::Server::Core::Tickets::ServiceTicket

Inherits:
TicketGrantingTicket show all
Defined in:
lib/rubycas/server/memory/service_ticket.rb

Instance Attribute Summary collapse

Attributes inherited from TicketGrantingTicket

#extra_attributes, #proxy_tickets, #remember_me, #service_tickets

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Storage

#save, #save!

Constructor Details

#initialize(st = {}) ⇒ ServiceTicket

Returns a new instance of ServiceTicket.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rubycas/server/memory/service_ticket.rb', line 12

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

Instance Attribute Details

#client_hostnameObject

Returns the value of attribute client_hostname.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def client_hostname
  @client_hostname
end

#consumedObject

Returns the value of attribute consumed.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def consumed
  @consumed
end

#created_atObject

Returns the value of attribute created_at.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def id
  @id
end

#proxy_granting_ticketObject

Returns the value of attribute proxy_granting_ticket.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def proxy_granting_ticket
  @proxy_granting_ticket
end

#serviceObject

Returns the value of attribute service.



10
11
12
# File 'lib/rubycas/server/memory/service_ticket.rb', line 10

def service
  @service
end

#ticketObject

Returns the value of attribute ticket.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def ticket
  @ticket
end

#ticket_granting_ticketObject

Returns the value of attribute ticket_granting_ticket.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def ticket_granting_ticket
  @ticket_granting_ticket
end

#updated_atObject

Returns the value of attribute updated_at.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def updated_at
  @updated_at
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/rubycas/server/memory/service_ticket.rb', line 7

def username
  @username
end

Class Method Details

.find_by_ticket(ticket) ⇒ Object



27
28
29
30
31
32
# File 'lib/rubycas/server/memory/service_ticket.rb', line 27

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

Instance Method Details

#consume!Object



38
39
40
41
# File 'lib/rubycas/server/memory/service_ticket.rb', line 38

def consume!
  self.consumed = true
  self.save
end

#consumed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rubycas/server/memory/service_ticket.rb', line 34

def consumed?
  self.consumed
end

#expired?(max_lifetime = 100) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/rubycas/server/memory/service_ticket.rb', line 43

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