Class: CASClient::Tickets::Storage::ActiveRecordTicketStore
- Inherits:
-
AbstractTicketStore
- Object
- AbstractTicketStore
- CASClient::Tickets::Storage::ActiveRecordTicketStore
- 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
Instance Method Summary collapse
- #cleanup_service_session_lookup(st) ⇒ Object
-
#initialize(config = {}) ⇒ ActiveRecordTicketStore
constructor
A new instance of ActiveRecordTicketStore.
- #read_service_session_lookup(st) ⇒ Object
- #retrieve_pgt(pgt_iou) ⇒ Object
- #save_pgt_iou(pgt_iou, pgt) ⇒ Object
- #store_service_session_lookup(st, controller) ⇒ Object
Methods inherited from AbstractTicketStore
#get_session_for_service_ticket, #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
37 38 39 40 41 |
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 37 def cleanup_service_session_lookup(st) #no cleanup needed for this ticket store #we still raise the exception for API compliance raise CASException, "No service_ticket specified." unless st end |
#read_service_session_lookup(st) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 30 def read_service_session_lookup(st) raise CASException, "No service_ticket specified." unless st st = st.ticket if st.kind_of? ServiceTicket session = ActiveRecord::SessionStore::Session.find_by_service_ticket(st) session ? session.session_id : nil end |
#retrieve_pgt(pgt_iou) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 49 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) raise CASException, "Invalid pgt_iou specified. Perhaps this pgt has already been retrieved?" unless pgtiou pgt = pgtiou.pgt_id pgtiou.destroy pgt end |
#save_pgt_iou(pgt_iou, pgt) ⇒ Object
43 44 45 46 47 |
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 43 def save_pgt_iou(pgt_iou, pgt) raise CASClient::CASException.new("Invalid pgt_iou") if pgt_iou.nil? raise CASClient::CASException.new("Invalid pgt") if pgt.nil? 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 28 |
# File 'lib/casclient/tickets/storage/active_record_ticket_store.rb', line 21 def store_service_session_lookup(st, controller) raise CASException, "No service_ticket specified." unless st raise CASException, "No controller specified." unless controller st = st.ticket if st.kind_of? ServiceTicket session = controller.session session[:service_ticket] = st end |