You are here

function cas_test_single_sign_out in CAS 6.3

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

Sign out the specified CAS user.

Parameters

$cas_user:

2 calls to cas_test_single_sign_out()
CasSingleSignOutTestCase::testSingleSignOut in ./cas.test
CasSingleSignOutTestCase::testSingleSignOutDoubleEncode in ./cas.test

File

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

Code

function cas_test_single_sign_out($cas_name, $double_encode = FALSE) {
  $sso = variable_get('cas_test_sso', array());
  foreach ($sso[$cas_name] as $service => $tickets) {
    foreach ($tickets as $ticket) {

      // Generate posting:
      $data = array(
        'logoutRequest' => t("<samlp:LogoutRequest ID=\"!id\" Version=\"2.0\" IssueInstant=\"!time\">\n<saml:NameID>@NOT_USED@</saml:NameID>\n<samlp:SessionIndex>!ticket</samlp:SessionIndex>\n</samlp:LogoutRequest>", array(
          '!id' => user_password(10),
          '!time' => time(),
          '!ticket' => $ticket,
        )),
      );
      if ($double_encode) {

        // Certain CAS servers urlencode the logoutRequest.
        $data['logoutRequest'] = urlencode($data['logoutRequest']);
      }

      // Sign out the user.
      $headers = array(
        'Content-Type' => 'application/x-www-form-urlencoded',
      );
      drupal_http_request($service, $headers, 'POST', http_build_query($data, '', '&'));
    }
  }
  unset($sso[$cas_name]);
  variable_set('cas_test_sso', $sso);
}