You are here

private function CasLogout::getServiceTicketFromData in CAS 8

Same name and namespace in other branches
  1. 2.x src/Service/CasLogout.php \Drupal\cas\Service\CasLogout::getServiceTicketFromData()

Parse the SLO SAML and return the service ticket.

Parameters

string $data: The raw data posted to us from the CAS server.

Return value

string The service ticket to log out.

Throws

\Drupal\cas\Exception\CasSloException If the logout data could not be parsed.

1 call to CasLogout::getServiceTicketFromData()
CasLogout::handleSlo in src/Service/CasLogout.php
Handles a single-log-out request from a CAS server.

File

src/Service/CasLogout.php, line 122

Class

CasLogout
Class CasLogout.

Namespace

Drupal\cas\Service

Code

private function getServiceTicketFromData($data) {
  $dom = new \DOMDocument();
  $dom->preserveWhiteSpace = FALSE;
  $dom->encoding = "utf-8";
  if ($dom
    ->loadXML($data) === FALSE) {
    throw new CasSloException("SLO data from CAS server is not valid.");
  }
  $session_elements = $dom
    ->getElementsByTagName('SessionIndex');
  if ($session_elements->length == 0) {
    throw new CasSloException("SLO data from CAS server is not valid.");
  }
  $session_element = $session_elements
    ->item(0);
  return $session_element->nodeValue;
}