Module: CASino::ControllerConcern::TicketValidator

Extended by:
ActiveSupport::Concern
Includes:
ProxyGrantingTicketProcessor, ServiceTicketProcessor
Included in:
ProxyTicketsController, ServiceTicketsController
Defined in:
app/controllers/casino/controller_concern/ticket_validator.rb

Constant Summary

Constants included from ServiceTicketProcessor

ServiceTicketProcessor::RESERVED_CAS_PARAMETER_KEYS

Instance Method Summary collapse

Methods included from ProxyGrantingTicketProcessor

#acquire_proxy_granting_ticket

Methods included from ServiceTicketProcessor

#acquire_service_ticket, #clean_service_url, #service_allowed?, #ticket_valid_for_service?, #validate_ticket_for_service

Instance Method Details

#build_ticket_validation_response(success, options = {}) ⇒ Object


19
20
21
# File 'app/controllers/casino/controller_concern/ticket_validator.rb', line 19

def build_ticket_validation_response(success, options = {})
  render xml: CASino::TicketValidationResponseBuilder.new(success, options).build
end

#ensure_service_ticket_parameters_presentObject


23
24
25
26
27
28
29
# File 'app/controllers/casino/controller_concern/ticket_validator.rb', line 23

def ensure_service_ticket_parameters_present
  if params[:ticket].nil? || params[:service].nil?
    build_ticket_validation_response(false,
                                     error_code: 'INVALID_REQUEST',
                                     error_message: '"ticket" and "service" parameters are both required')
  end
end

#validate_ticket(ticket) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/casino/controller_concern/ticket_validator.rb', line 6

def validate_ticket(ticket)
  validation_result = validate_ticket_for_service(ticket, params[:service], renew: params[:renew])
  if validation_result.success?
    options = { ticket: ticket }
    options[:proxy_granting_ticket] = acquire_proxy_granting_ticket(params[:pgtUrl], ticket) unless params[:pgtUrl].nil?
    build_ticket_validation_response(true, options)
  else
    build_ticket_validation_response(false,
                                     error_code: validation_result.error_code,
                                     error_message: validation_result.error_message)
  end
end