Class: RubyCAS::Server::Core::Tickets::ProxyTicket

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Storage

#save, #save!

Constructor Details

#initialize(pt = {}) ⇒ ProxyTicket

Returns a new instance of ProxyTicket.



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

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

Instance Attribute Details

#client_hostnameObject

Returns the value of attribute client_hostname.



7
8
9
# File 'lib/rubycas/server/memory/proxy_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/proxy_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/proxy_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/proxy_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/proxy_ticket.rb', line 7

def proxy_granting_ticket
  @proxy_granting_ticket
end

#serviceObject

Returns the value of attribute service.



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

def service
  @service
end

#ticketObject

Returns the value of attribute ticket.



7
8
9
# File 'lib/rubycas/server/memory/proxy_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/proxy_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/proxy_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/proxy_ticket.rb', line 7

def username
  @username
end

Class Method Details

.find_by_ticket(ticket) ⇒ Object



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

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

Instance Method Details

#consume!Object



37
38
39
40
# File 'lib/rubycas/server/memory/proxy_ticket.rb', line 37

def consume!
  consumed = true
  self.save
end

#consumed?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rubycas/server/memory/proxy_ticket.rb', line 33

def consumed?
  consumed
end

#expired?(max_lifetime = 100) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/rubycas/server/memory/proxy_ticket.rb', line 42

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