Class: CASClient::Tickets::Storage::ActiveRecordTicketStore

Inherits:
AbstractTicketStore show all
Defined in:
lib/casclient/tickets/storage/active_record_ticket_store.rb

Overview

A Ticket Store that keeps it’s ticket in database tables using ActiveRecord.

Services Tickets are stored in an extra column add to the ActiveRecord sessions table. Proxy Granting Tickets and their IOUs are stored in the cas_pgtious table.

This ticket store takes the following config parameters :pgtious_table_name - the name of the table

Instance Attribute Summary

Attributes inherited from AbstractTicketStore

#log

Instance Method Summary collapse

Methods inherited from AbstractTicketStore

#process_single_sign_out

Constructor Details

#initialize(config = {}) ⇒ ActiveRecordTicketStore

Returns a new instance of ActiveRecordTicketStore.



14
15
16
17
18
19
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 14

def initialize(config={})
  config ||= {}
  if config[:pgtious_table_name]
    CasPgtiou.set_table_name = config[:pgtious_table_name]
  end
end

Instance Method Details

#cleanup_service_session_lookup(st) ⇒ Object



36
37
38
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 36

def cleanup_service_session_lookup(st)
  #no cleanup needed for this ticket store
end

#get_session_for_service_ticket(st) ⇒ Object



29
30
31
32
33
34
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 29

def get_session_for_service_ticket(st)
  st = st.ticket if st.kind_of? ServiceTicket
  session = ActiveRecord::SessionStore::Session.find_by_service_ticket(st)
  session_id = session ? session.session_id : nil
  [session_id, session]
end

#retrieve_pgt(pgt_iou) ⇒ Object

Raises:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 44

def retrieve_pgt(pgt_iou)
  raise CASException, "No pgt_iou specified. Cannot retrieve the pgt." unless pgt_iou

  pgtiou = CasPgtiou.find_by_pgt_iou(pgt_iou)
  pgt = pgtiou.pgt_id

  raise CASException, "Invalid pgt_iou specified. Perhaps this pgt has already been retrieved?" unless pgt

  pgtiou.destroy

  pgt

end

#save_pgt_iou(pgt_iou, pgt) ⇒ Object



40
41
42
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 40

def save_pgt_iou(pgt_iou, pgt)
  pgtiou = CasPgtiou.create(:pgt_iou => pgt_iou, :pgt_id => pgt)
end

#store_service_session_lookup(st, controller) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 21

def store_service_session_lookup(st, controller)
  #get the session from the rack env using ActiveRecord::SessionStore::SESSION_RECORD_KEY = 'rack.session.record'

  st = st.ticket if st.kind_of? ServiceTicket
  session = controller.session
  session[:service_ticket] = st
end