Functions | |
| CASClient::getST () | |
| This method returns the Service Ticket provided in the URL of the request. | |
| CASClient::setST ($st) | |
| This method stores the Service Ticket. | |
| CASClient::hasST () | |
| This method tells if a Service Ticket was stored. | |
| CASClient::validateST ($validate_url, &$text_response, &$tree_response) | |
| This method is used to validate a ST; halt on failure, and sets $validate_url, $text_reponse and $tree_response on success. | |
Variables | |
| CASClient::$_st | |
| the Service Ticket provided in the URL of the request if present (empty otherwise). | |
| CASClient::getST | ( | ) | [private, inherited] |
This method returns the Service Ticket provided in the URL of the request.
Definition at line 810 of file client.php.
Referenced by CASClient::isAuthenticated(), and CASClient::validateST().
{ return $this->_st; }
Here is the caller graph for this function:| CASClient::hasST | ( | ) | [private, inherited] |
This method tells if a Service Ticket was stored.
Definition at line 826 of file client.php.
Referenced by CASClient::isAuthenticated().
{ return !empty($this->_st); }
Here is the caller graph for this function:| CASClient::setST | ( | $ | st | ) | [private, inherited] |
This method stores the Service Ticket.
| $st | The Service Ticket. |
Definition at line 818 of file client.php.
Referenced by CASClient::wasPreviouslyAuthenticated().
{ $this->_st = $st; }
Here is the caller graph for this function:| CASClient::validateST | ( | $ | validate_url, | |
| &$ | text_response, | |||
| &$ | tree_response | |||
| ) | [private, inherited] |
This method is used to validate a ST; halt on failure, and sets $validate_url, $text_reponse and $tree_response on success.
These parameters are used later by CASClient::validatePGT() for CAS proxies.
| $validate_url | the URL of the request to the CAS server. | |
| $text_response | the response of the CAS server, as is (XML text). | |
| $tree_response | the response of the CAS server, as a DOM XML tree. |
Definition at line 852 of file client.php.
References $user, CASClient::authError(), domxml_open_mem(), CASClient::getServerServiceValidateURL(), CASClient::getST(), CASClient::isProxy(), n, CASClient::readURL(), and CASClient::setUser().
{
phpCAS::traceBegin();
// build the URL to validate the ticket
$validate_url = $this->getServerServiceValidateURL().'&ticket='.$this->getST();
if ( $this->isProxy() ) {
// pass the callback url for CAS proxies
$validate_url .= '&pgtUrl='.$this->getCallbackURL();
}
// open and read the URL
if ( !$this->readURL($validate_url,''/*cookies*/,$headers,$text_response,$err_msg) ) {
phpCAS::trace('could not open URL \''.$validate_url.'\' to validate ('.$err_msg.')');
$this->authError('ST not validated',
$validate_url,
TRUE/*$no_response*/);
}
// analyze the result depending on the version
switch ($this->getServerVersion()) {
case CAS_VERSION_1_0:
if (preg_match('/^no\n/',$text_response)) {
phpCAS::trace('ST has not been validated');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
FALSE/*$bad_response*/,
$text_response);
}
if (!preg_match('/^yes\n/',$text_response)) {
phpCAS::trace('ill-formed response');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
// ST has been validated, extract the user name
$arr = preg_split('/\n/',$text_response);
$this->setUser(trim($arr[1]));
break;
case CAS_VERSION_2_0:
// read the response of the CAS server into a DOM object
if ( !($dom = domxml_open_mem($text_response))) {
phpCAS::trace('domxml_open_mem() failed');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
// read the root node of the XML tree
if ( !($tree_response = $dom->document_element()) ) {
phpCAS::trace('document_element() failed');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
// insure that tag name is 'serviceResponse'
if ( $tree_response->node_name(true) != 'serviceResponse' ) {
phpCAS::trace('bad XML root node (should be `serviceResponse\' instead of `'.$tree_response->node_name(true).'\'');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
if ( sizeof($success_elements = $tree_response->get_elements_by_tagname("authenticationSuccess")) != 0) {
// authentication succeded, extract the user name
if ( sizeof($user_elements = $success_elements[0]->get_elements_by_tagname("user")) == 0) {
phpCAS::trace('<authenticationSuccess> found, but no <user>');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
$user = trim($user_elements[0]->get_content());
phpCAS::trace('user = `'.$user);
$this->setUser($user);
} else if ( sizeof($failure_elements = $tree_response->get_elements_by_tagname("authenticationFailure")) != 0) {
phpCAS::trace('<authenticationFailure> found');
// authentication failed, extract the error code and message
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
FALSE/*$bad_response*/,
$text_response,
$failure_elements[0]->get_attribute('code')/*$err_code*/,
trim($failure_elements[0]->get_content())/*$err_msg*/);
} else {
phpCAS::trace('neither <authenticationSuccess> nor <authenticationFailure> found');
$this->authError('ST not validated',
$validate_url,
FALSE/*$no_response*/,
TRUE/*$bad_response*/,
$text_response);
}
break;
}
// at this step, ST has been validated and $this->_user has been set,
phpCAS::traceEnd(TRUE);
return TRUE;
}
Here is the call graph for this function:CASClient::$_st [private, inherited] |
the Service Ticket provided in the URL of the request if present (empty otherwise).
Written by CASClient::CASClient(), read by CASClient::getST() and CASClient::hasPGT().
Definition at line 803 of file client.php.
1.7.1