ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 1870 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().

1871  {
1872  return $this->_ticket;
1873  }
$_ticket
The Ticket provided in the URL of the request if present (empty otherwise).
Definition: Client.php:1863
+ 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 1892 of file Client.php.

Referenced by CAS_Client\isAuthenticated().

1893  {
1894  return !empty($this->_ticket);
1895  }
+ 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 1944 of file Client.php.

1945  {
1946  // Argument validation
1947  if (gettype($cert) != 'string') {
1948  throw new CAS_TypeMismatchException($cert, '$cert', 'string');
1949  }
1950  if (gettype($validate_cn) != 'boolean') {
1951  throw new CAS_TypeMismatchException($validate_cn, '$validate_cn', 'boolean');
1952  }
1953  if ( !file_exists($cert) && $this->_requestImplementation !== 'CAS_TestHarness_DummyRequest'){
1954  throw new CAS_InvalidArgumentException("Certificate file does not exist " . $this->_requestImplementation);
1955  }
1956  $this->_cas_server_ca_cert = $cert;
1957  $this->_cas_server_cn_validate = $validate_cn;
1958  }
Exception that denotes invalid arguments were passed.

◆ setNoCasServerValidation()

CAS_Client::setNoCasServerValidation ( )

Set no SSL validation for the CAS server.

Returns
void

Definition at line 1965 of file Client.php.

1966  {
1967  $this->_no_cas_server_validation = true;
1968  }

◆ setTicket()

CAS_Client::setTicket (   $st)

This method stores the Service Ticket.

Parameters
string$stThe Service Ticket.
Returns
void

Definition at line 1882 of file Client.php.

Referenced by CAS_Client\_wasPreviouslyAuthenticated().

1883  {
1884  $this->_ticket = $st;
1885  }
+ 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 1985 of file Client.php.

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

1986  {
1988  $result = false;
1989  // build the URL to validate the ticket
1990  $validate_url = $this->getServerServiceValidateURL()
1991  .'&ticket='.urlencode($this->getTicket());
1992 
1993  if ( $renew ) {
1994  // pass the renew
1995  $validate_url .= '&renew=true';
1996  }
1997 
1998  // open and read the URL
1999  if ( !$this->_readURL($validate_url, $headers, $text_response, $err_msg) ) {
2000  phpCAS::trace(
2001  'could not open URL \''.$validate_url.'\' to validate ('.$err_msg.')'
2002  );
2003  throw new CAS_AuthenticationException(
2004  $this, 'CAS 1.0 ticket not validated', $validate_url,
2005  true/*$no_response*/
2006  );
2007  $result = false;
2008  }
2009 
2010  if (preg_match('/^no\n/', $text_response)) {
2011  phpCAS::trace('Ticket has not been validated');
2012  throw new CAS_AuthenticationException(
2013  $this, 'ST not validated', $validate_url, false/*$no_response*/,
2014  false/*$bad_response*/, $text_response
2015  );
2016  $result = false;
2017  } else if (!preg_match('/^yes\n/', $text_response)) {
2018  phpCAS::trace('ill-formed response');
2019  throw new CAS_AuthenticationException(
2020  $this, 'Ticket not validated', $validate_url,
2021  false/*$no_response*/, true/*$bad_response*/, $text_response
2022  );
2023  $result = false;
2024  }
2025  // ticket has been validated, extract the user name
2026  $arr = preg_split('/\n/', $text_response);
2027  $this->_setUser(trim($arr[1]));
2028  $result = true;
2029 
2030  if ($result) {
2031  $this->_renameSession($this->getTicket());
2032  }
2033  // at this step, ticket has been validated and $this->_user has been set,
2034  phpCAS::traceEnd(true);
2035  return true;
2036  }
File written to
$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:1870
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:579
getServerServiceValidateURL()
This method is used to retrieve the service validating URL of the CAS server.
Definition: Client.php:431
_readURL($url, &$headers, &$body, &$err_msg)
This method is used to acces a remote URL.
Definition: Client.php:2790
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:591
+ 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 1912 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 1925 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 1932 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 1863 of file Client.php.

Referenced by CAS_Client\getTicket().