Sha256: ef2400be5331acbdc398e59e45a79036e42f76f62787ad4efcbe41188662bb57

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

# This processor should be used for API calls: POST /cas/v1/tickets
class CASino::API::LoginCredentialAcceptorProcessor < CASino::Processor
  include CASino::ProcessorConcern::ServiceTickets
  include CASino::ProcessorConcern::Authentication
  include CASino::ProcessorConcern::TicketGrantingTickets

  # Use this method to process the request. It expects the username in the parameter "username" and the password
  # in "password".
  #
  # The method will call one of the following methods on the listener:
  # * `#user_logged_in_via_api`: First and only argument is a String with the TGT-id
  # * `#invalid_login_credentials_via_api`: No argument
  #
  # @param [Hash] login_data parameters supplied by user (username and password)
  def process(login_data, user_agent = nil)
    @login_data = login_data
    @user_agent = user_agent

    validate_login_data

    unless @authentication_result.nil?
      generate_ticket_granting_ticket
      callback_user_logged_in
    else
      callback_invalid_login_credentials
    end
  end

  private
  def validate_login_data
    @authentication_result = validate_login_credentials(@login_data[:username], @login_data[:password])
  end

  def callback_user_logged_in
    @listener.user_logged_in_via_api @ticket_granting_ticket.ticket
  end

  def generate_ticket_granting_ticket
    @ticket_granting_ticket = acquire_ticket_granting_ticket(@authentication_result, @user_agent)
  end

  def callback_invalid_login_credentials
    @listener.invalid_login_credentials_via_api
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
casino-3.0.4 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.7 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.3 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.2 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.1 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.0 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.0.pre.2 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-3.0.0.pre.1 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.6 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.5 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.4 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.3 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.2 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.1 app/processors/casino/api/login_credential_acceptor_processor.rb
casino-2.0.0 app/processors/casino/api/login_credential_acceptor_processor.rb