ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CAS Basic client features (CAS 1.0, Service Tickets)
+ Collaboration diagram for CAS Basic client features (CAS 1.0, Service Tickets):

Functions

 CAS_Client::getTicket ()
 This method returns the Service Ticket provided in the URL of the request. More...
 
 CAS_Client::setTicket ($st)
 This method stores the Service Ticket. More...
 
 CAS_Client::hasTicket ()
 This method tells if a Service Ticket was stored. More...
 
 CAS_Client::setCasServerCACert ($cert, $validate_cn)
 Set the CA certificate of the CAS server. More...
 
 CAS_Client::setNoCasServerValidation ()
 Set no SSL validation for the CAS server. More...
 
 CAS_Client::validateCAS10 (&$validate_url, &$text_response, &$tree_response, $renew=false)
 This method is used to validate a CAS 1,0 ticket; halt on failure, and sets $validate_url, $text_reponse and $tree_response on success. More...
 

Variables

 CAS_Client::$_ticket
 The Ticket provided in the URL of the request if present (empty otherwise). More...
 
 CAS_Client::$_cas_server_ca_cert
 the certificate of the CAS server CA. More...
 
 CAS_Client::$_cas_server_cn_validate
 validate CN of the CAS server certificate More...
 
 CAS_Client::$_no_cas_server_validation
 Set to true not to validate the CAS server. More...
 

Detailed Description

Function Documentation

◆ getTicket()

CAS_Client::getTicket ( )

This method returns the Service Ticket provided in the URL of the request.

Returns
string service ticket.

Definition at line 1905 of file Client.php.

References CAS_Client\$_ticket.

Referenced by CAS_Client\_buildSAMLPayload(), CAS_Client\isAuthenticated(), CAS_Client\validateCAS10(), CAS_Client\validateCAS20(), and CAS_Client\validateSA().

1906  {
1907  return $this->_ticket;
1908  }
$_ticket
The Ticket provided in the URL of the request if present (empty otherwise).
Definition: Client.php:1898
+ Here is the caller graph for this function:

◆ hasTicket()

CAS_Client::hasTicket ( )

This method tells if a Service Ticket was stored.

Returns
bool if a Service Ticket has been stored.

Definition at line 1927 of file Client.php.

Referenced by CAS_Client\isAuthenticated().

1928  {
1929  return !empty($this->_ticket);
1930  }
+ Here is the caller graph for this function:

◆ setCasServerCACert()

CAS_Client::setCasServerCACert (   $cert,
  $validate_cn 
)

Set the CA certificate of the CAS server.

Parameters
string$certthe PEM certificate file name of the CA that emited the cert of the server
bool$validate_cnvaliate CN of the CAS server certificate
Returns
void

Definition at line 1979 of file Client.php.

1980  {
1981  // Argument validation
1982  if (gettype($cert) != 'string') {
1983  throw new CAS_TypeMismatchException($cert, '$cert', 'string');
1984  }
1985  if (gettype($validate_cn) != 'boolean') {
1986  throw new CAS_TypeMismatchException($validate_cn, '$validate_cn', 'boolean');
1987  }
1988  if (!file_exists($cert) && $this->_requestImplementation !== 'CAS_TestHarness_DummyRequest') {
1989  throw new CAS_InvalidArgumentException("Certificate file does not exist " . $this->_requestImplementation);
1990  }
1991  $this->_cas_server_ca_cert = $cert;
1992  $this->_cas_server_cn_validate = $validate_cn;
1993  }
Exception that denotes invalid arguments were passed.

◆ setNoCasServerValidation()

CAS_Client::setNoCasServerValidation ( )

Set no SSL validation for the CAS server.

Returns
void

Definition at line 2000 of file Client.php.

2001  {
2002  $this->_no_cas_server_validation = true;
2003  }

◆ setTicket()

CAS_Client::setTicket (   $st)

This method stores the Service Ticket.

Parameters
string$stThe Service Ticket.
Returns
void

Definition at line 1917 of file Client.php.

Referenced by CAS_Client\_wasPreviouslyAuthenticated().

1918  {
1919  $this->_ticket = $st;
1920  }
+ Here is the caller graph for this function:

◆ validateCAS10()

CAS_Client::validateCAS10 ( $validate_url,
$text_response,
$tree_response,
  $renew = false 
)

This method is used to validate a CAS 1,0 ticket; halt on failure, and sets $validate_url, $text_reponse and $tree_response on success.

Parameters
string&$validate_urlreference to the the URL of the request to the CAS server.
string&$text_responsereference to the response of the CAS server, as is (XML text).
string&$tree_responsereference to the response of the CAS server, as a DOM XML tree.
bool$renewtrue to force the authentication with the CAS server
Returns
bool true when successfull and issue a CAS_AuthenticationException and false on an error

Definition at line 2020 of file Client.php.

References $result, CAS_Client\_readURL(), CAS_Client\getServerServiceValidateURL(), CAS_Client\getTicket(), n, phpCAS\trace(), and phpCAS\traceBegin().

2021  {
2023  $result = false;
2024  // build the URL to validate the ticket
2025  $validate_url = $this->getServerServiceValidateURL()
2026  . '&ticket=' . urlencode($this->getTicket());
2027 
2028  if ($renew) {
2029  // pass the renew
2030  $validate_url .= '&renew=true';
2031  }
2032 
2033  // open and read the URL
2034  if (!$this->_readURL($validate_url, $headers, $text_response, $err_msg)) {
2035  phpCAS::trace(
2036  'could not open URL \'' . $validate_url . '\' to validate (' . $err_msg . ')'
2037  );
2038  throw new CAS_AuthenticationException(
2039  $this,
2040  'CAS 1.0 ticket not validated',
2041  $validate_url,
2042  true/*$no_response*/
2043  );
2044  $result = false;
2045  }
2046 
2047  if (preg_match('/^no\n/', $text_response)) {
2048  phpCAS::trace('Ticket has not been validated');
2049  throw new CAS_AuthenticationException(
2050  $this,
2051  'ST not validated',
2052  $validate_url,
2053  false/*$no_response*/,
2054  false/*$bad_response*/,
2055  $text_response
2056  );
2057  $result = false;
2058  } elseif (!preg_match('/^yes\n/', $text_response)) {
2059  phpCAS::trace('ill-formed response');
2060  throw new CAS_AuthenticationException(
2061  $this,
2062  'Ticket not validated',
2063  $validate_url,
2064  false/*$no_response*/,
2065  true/*$bad_response*/,
2066  $text_response
2067  );
2068  $result = false;
2069  }
2070  // ticket has been validated, extract the user name
2071  $arr = preg_split('/\n/', $text_response);
2072  $this->_setUser(trim($arr[1]));
2073  $result = true;
2074 
2075  if ($result) {
2076  $this->_renameSession($this->getTicket());
2077  }
2078  // at this step, ticket has been validated and $this->_user has been set,
2079  phpCAS::traceEnd(true);
2080  return true;
2081  }
$result
if(! $in) print Initializing normalization quick check tables n
getTicket()
This method returns the Service Ticket provided in the URL of the request.
Definition: Client.php:1905
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
getServerServiceValidateURL()
This method is used to retrieve the service validating URL of the CAS server.
Definition: Client.php:439
_readURL($url, &$headers, &$body, &$err_msg)
This method is used to acces a remote URL.
Definition: Client.php:2875
Licensed to Jasig under one or more contributor license agreements.
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:611
+ Here is the call graph for this function:

Variable Documentation

◆ $_cas_server_ca_cert

CAS_Client::$_cas_server_ca_cert
private

the certificate of the CAS server CA.

Definition at line 1947 of file Client.php.

◆ $_cas_server_cn_validate

CAS_Client::$_cas_server_cn_validate
private

validate CN of the CAS server certificate

Definition at line 1960 of file Client.php.

◆ $_no_cas_server_validation

CAS_Client::$_no_cas_server_validation
private

Set to true not to validate the CAS server.

Definition at line 1967 of file Client.php.

◆ $_ticket

CAS_Client::$_ticket
private

The Ticket provided in the URL of the request if present (empty otherwise).

Written by CAS_Client::CAS_Client(), read by CAS_Client::getTicket() and CAS_Client::_hasPGT().

Definition at line 1898 of file Client.php.

Referenced by CAS_Client\getTicket().