Class: TicketGrantingTicket
- Inherits:
-
Object
- Object
- TicketGrantingTicket
- Defined in:
- lib/ticket_granting_ticket.rb
Instance Attribute Summary collapse
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy!(store) ⇒ Object
-
#initialize(user, ticket = nil) ⇒ TicketGrantingTicket
constructor
A new instance of TicketGrantingTicket.
- #save!(store) ⇒ Object
- #ticket ⇒ Object
- #to_cookie(domain, path = "/") ⇒ Object
Constructor Details
#initialize(user, ticket = nil) ⇒ TicketGrantingTicket
Returns a new instance of TicketGrantingTicket.
19 20 21 22 |
# File 'lib/ticket_granting_ticket.rb', line 19 def initialize(user, ticket = nil) @username = user @ticket = ticket end |
Instance Attribute Details
#username ⇒ Object (readonly)
Returns the value of attribute username.
17 18 19 |
# File 'lib/ticket_granting_ticket.rb', line 17 def username @username end |
Class Method Details
.create!(user, store) ⇒ Object
9 10 11 12 13 |
# File 'lib/ticket_granting_ticket.rb', line 9 def create!(user, store) tgt = self.new(user) tgt.save!(store) tgt end |
.validate(ticket, store) ⇒ Object
3 4 5 6 7 |
# File 'lib/ticket_granting_ticket.rb', line 3 def validate(ticket, store) if ticket && username = store[ticket] new(username, ticket) end end |
Instance Method Details
#destroy!(store) ⇒ Object
28 29 30 |
# File 'lib/ticket_granting_ticket.rb', line 28 def destroy!(store) store.del self.ticket end |
#save!(store) ⇒ Object
32 33 34 |
# File 'lib/ticket_granting_ticket.rb', line 32 def save!(store) store[ticket] = username end |
#ticket ⇒ Object
24 25 26 |
# File 'lib/ticket_granting_ticket.rb', line 24 def ticket @ticket ||= "TGC-#{rand(100000000000000000)}".to_s end |
#to_cookie(domain, path = "/") ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/ticket_granting_ticket.rb', line 36 def (domain, path = "/") ["tgt", { :value => ticket, # :domain => domain, :path => path }] end |