You are here

function cas_test_service_validate in CAS 7

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

Validate a ticket using the CAS 2.0 and CAS 3.0 protocols.

1 string reference to 'cas_test_service_validate'
cas_test_menu in tests/cas_test.module
Implements hook_menu().

File

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

Code

function cas_test_service_validate() {

  // Prevent this page from being cached.
  drupal_page_is_cacheable(FALSE);

  // Set content type.
  drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
  $ticket = $_GET['ticket'];
  $service = $_GET['service'];
  if ($cas_user = _cas_test_ticket_validate($service, $ticket)) {
    print theme('cas_service_validate_success', $cas_user);
  }
  else {
    $error_code = !$ticket || !$service ? 'INVALID_REQUEST' : 'INVALID_TICKET';
    print theme('cas_service_validate_failure', array(
      'ticket' => $ticket,
      'error_code' => $error_code,
    ));
  }
  exit;
}