You are here

function _cas_test_ticket_generate in CAS 6.3

Same name and namespace in other branches
  1. 7 tests/cas_test.module \_cas_test_ticket_generate()

Generate a login ticket.

Parameters

$service: The service URL.

$cas_user: An associative array containing the following keys:

  • 'name': The CAS username.
  • 'attributes': Any other key-value pairs the CAS server should return.

Return value

A login ticket which may be used to authenticate the CAS username at the service URL.

1 call to _cas_test_ticket_generate()
cas_test_login in tests/cas_test.module
Initiate a login request.

File

tests/cas_test.module, line 204
Dummy module implementing a CAS Server.

Code

function _cas_test_ticket_generate($service, $cas_user) {

  // Generate a one-time ticket.
  $ticket = 'ST-' . user_password(32);

  // Save the ticket in the database.
  $tickets = variable_get('cas_test_tickets', array());
  $tickets[$service][$ticket] = $cas_user;
  variable_set('cas_test_tickets', $tickets);

  // Save the name in the database for single sign-out.
  $sso = variable_get('cas_test_sso', array());
  $sso[$cas_user['name']][$service][] = $ticket;
  variable_set('cas_test_sso', $sso);
  return $ticket;
}