You are here

private function CasValidator::validateVersion1 in CAS 2.x

Same name and namespace in other branches
  1. 8 src/Service/CasValidator.php \Drupal\cas\Service\CasValidator::validateVersion1()

Validation of a service ticket for Version 1 of the CAS protocol.

Parameters

string $data: The raw validation response data from CAS server.

Return value

\Drupal\cas\CasPropertyBag Contains user info from the CAS server.

Throws

\Drupal\cas\Exception\CasValidateException Thrown if there was a problem parsing the validation data.

1 call to CasValidator::validateVersion1()
CasValidator::validateTicket in src/Service/CasValidator.php
Validate the service ticket parameter present in the request.

File

src/Service/CasValidator.php, line 197

Class

CasValidator
The CAS ticket validator service.

Namespace

Drupal\cas\Service

Code

private function validateVersion1($data) {
  if (preg_match('/^no\\n/', $data)) {
    throw new CasValidateException("Ticket did not pass validation.");
  }
  elseif (!preg_match('/^yes\\n/', $data)) {
    throw new CasValidateException("Malformed response from CAS server.");
  }

  // Ticket is valid, need to extract the username.
  $arr = preg_split('/\\n/', $data);
  $user = trim($arr[1]);
  $this->casHelper
    ->log(LogLevel::DEBUG, "Extracted username %user from validation response data.", [
    '%user' => $user,
  ]);
  return new CasPropertyBag($user);
}