ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
phpCAS Class Reference

The phpCAS class is a simple container for the phpCAS library. More...

+ Collaboration diagram for phpCAS:

Public Member Functions

 client ($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
 phpCAS client initializer. More...
 
 proxy ($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
 phpCAS proxy initializer. More...
 
 setDebug ($filename='')
 Set/unset debug mode. More...
 
 backtrace ()
 This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4.3.0 only) More...
 
 trace ($str)
 This method is used to log something in debug mode. More...
 
 traceBegin ()
 This method is used to indicate the start of the execution of a function in debug mode. More...
 
 traceEnd ($res='')
 This method is used to indicate the end of the execution of a function in debug mode. More...
 
 traceExit ()
 This method is used to indicate the end of the execution of the program. More...
 
 setLang ($lang)
 This method is used to set the language used by phpCAS. More...
 
 getVersion ()
 This method returns the phpCAS version. More...
 
 setHTMLHeader ($header)
 This method sets the HTML header used for all outputs. More...
 
 setHTMLFooter ($footer)
 This method sets the HTML footer used for all outputs. More...
 
 setPGTStorageFile ($format='', $path='')
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem. More...
 
 setPGTStorageDB ($user, $password, $database_type='', $hostname='', $port=0, $database='', $table='')
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests into a database. More...
 
 serviceWeb ($url, & $err_code, & $output)
 This method is used to access an HTTP[S] service. More...
 
 serviceMail ($url, $service, $flags, & $err_code, & $err_msg, & $pt)
 This method is used to access an IMAP/POP3/NNTP service. More...
 
 setCacheTimesForAuthRecheck ($n)
 Set the times authentication will be cached before really accessing the CAS server in gateway mode: More...
 
 checkAuthentication ()
 This method is called to check if the user is authenticated (use the gateway feature). More...
 
 forceAuthentication ()
 This method is called to force authentication if the user was not already authenticated. More...
 
 renewAuthentication ()
 This method is called to renew the authentication. More...
 
 authenticate ()
 This method has been left from version 0.4.1 for compatibility reasons. More...
 
 isAuthenticated ()
 This method is called to check if the user is authenticated (previously or by tickets given in the URL). More...
 
 isSessionAuthenticated ()
 Checks whether authenticated based on $_SESSION. More...
 
 getUser ()
 This method returns the CAS user's login name. More...
 
 getAttributes ()
 This method returns the CAS user's login name. More...
 
 handleLogoutRequests ($check_client=true, $allowed_clients=false)
 Handle logout requests. More...
 
 getServerLoginURL ()
 This method returns the URL to be used to login. More...
 
 setServerLoginURL ($url='')
 Set the login URL of the CAS server. More...
 
 setServerServiceValidateURL ($url='')
 Set the serviceValidate URL of the CAS server. More...
 
 setServerProxyValidateURL ($url='')
 Set the proxyValidate URL of the CAS server. More...
 
 setServerSamlValidateURL ($url='')
 Set the samlValidate URL of the CAS server. More...
 
 getServerLogoutURL ()
 This method returns the URL to be used to login. More...
 
 setServerLogoutURL ($url='')
 Set the logout URL of the CAS server. More...
 
 logout ($params="")
 This method is used to logout from CAS. More...
 
 logoutWithRedirectService ($service)
 This method is used to logout from CAS. More...
 
 logoutWithUrl ($url)
 This method is used to logout from CAS. More...
 
 logoutWithRedirectServiceAndUrl ($service, $url)
 This method is used to logout from CAS. More...
 
 setFixedCallbackURL ($url='')
 Set the fixed URL that will be used by the CAS server to transmit the PGT. More...
 
 setFixedServiceURL ($url)
 Set the fixed URL that will be set as the CAS service parameter. More...
 
 getServiceURL ()
 Get the URL that is set as the CAS service parameter. More...
 
 retrievePT ($target_service, & $err_code, & $err_msg)
 Retrieve a Proxy Ticket from the CAS server. More...
 
 setCasServerCert ($cert)
 Set the certificate of the CAS server. More...
 
 setCasServerCACert ($cert)
 Set the certificate of the CAS server CA. More...
 
 setNoCasServerValidation ()
 Set no SSL validation for the CAS server. More...
 
 setExtraCurlOption ($key, $value)
 Change CURL options. More...
 
 client ($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
 phpCAS client initializer. More...
 
 proxy ($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
 phpCAS proxy initializer. More...
 
 setDebug ($filename='')
 Set/unset debug mode. More...
 
 backtrace ()
 This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4.3.0 only) More...
 
 trace ($str)
 This method is used to log something in debug mode. More...
 
 traceBegin ()
 This method is used to indicate the start of the execution of a function in debug mode. More...
 
 traceEnd ($res='')
 This method is used to indicate the end of the execution of a function in debug mode. More...
 
 traceExit ()
 This method is used to indicate the end of the execution of the program. More...
 
 setLang ($lang)
 This method is used to set the language used by phpCAS. More...
 
 getVersion ()
 This method returns the phpCAS version. More...
 
 setHTMLHeader ($header)
 This method sets the HTML header used for all outputs. More...
 
 setHTMLFooter ($footer)
 This method sets the HTML footer used for all outputs. More...
 
 setPGTStorageFile ($format='', $path='')
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem. More...
 
 setPGTStorageDB ($user, $password, $database_type='', $hostname='', $port=0, $database='', $table='')
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests into a database. More...
 
 serviceWeb ($url, &$err_code, &$output)
 This method is used to access an HTTP[S] service. More...
 
 serviceMail ($url, $flags, &$err_code, &$err_msg, &$pt)
 This method is used to access an IMAP/POP3/NNTP service. More...
 
 checkAuthentication ()
 This method is called to check if the user is authenticated (use the gateway feature). More...
 
 forceAuthentication ()
 This method is called to force authentication if the user was not already authenticated. More...
 
 authenticate ()
 This method has been left from version 0.4.1 for compatibility reasons. More...
 
 isAuthenticated ()
 This method has been left from version 0.4.19 for compatibility reasons. More...
 
 getUser ()
 This method returns the CAS user's login name. More...
 
 getServerLoginURL ()
 This method returns the URL to be used to login. More...
 
 getServerLogoutURL ()
 This method returns the URL to be used to login. More...
 
 logout ($url="")
 This method is used to logout from CAS. More...
 
 setFixedCallbackURL ($url='')
 Set the fixed URL that will be used by the CAS server to transmit the PGT. More...
 
 setFixedServiceURL ($url)
 Set the fixed URL that will be set as the CAS service parameter. More...
 
 getServiceURL ()
 Get the URL that is set as the CAS service parameter. More...
 
 retrievePT ($target_service, &$err_code, &$err_msg)
 Retrieve a Proxy Ticket from the CAS server. More...
 

Private Member Functions

 log ($str)
 Logs a string in debug mode. More...
 
 error ($msg)
 This method is used by interface methods to print an error and where the function was originally called from. More...
 
 log ($str)
 Logs a string in debug mode. More...
 
 error ($msg)
 This method is used by interface methods to print an error and where the function was originally called from. More...
 

Detailed Description

The phpCAS class is a simple container for the phpCAS library.

It provides CAS authentication for web applications written in PHP.

Author
Pascal Aubry <pascal.aubry at univ-rennes1.fr>

Definition at line 341 of file CAS.php.

Member Function Documentation

◆ authenticate()

phpCAS::authenticate ( )

This method has been left from version 0.4.1 for compatibility reasons.

Definition at line 902 of file CAS.php.

903  {
904  phpCAS::error('this method is deprecated. You should use '.__CLASS__.'::forceAuthentication() instead');
905  }
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544

◆ backtrace()

phpCAS::backtrace ( )

This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4.3.0 only)

Definition at line 415 of file CAS.php.

416  {
417  if ( function_exists('debug_backtrace') ) {
418  return debug_backtrace();
419  } else {
420  // poor man's hack ... but it does work ...
421  return array();
422  }
423  }

◆ checkAuthentication()

phpCAS::checkAuthentication ( )

This method is called to check if the user is authenticated (use the gateway feature).

Returns
TRUE when the user is authenticated; otherwise FALSE.

Definition at line 843 of file CAS.php.

References $auth, $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, backtrace(), error(), traceBegin(), and traceEnd().

844  {
846 
848  if ( !is_object($PHPCAS_CLIENT) ) {
849  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
850  }
851 
852  $auth = $PHPCAS_CLIENT->checkAuthentication();
853 
854  // store where the authentication has been checked and the result
855  $dbg = phpCAS::backtrace();
856  $PHPCAS_AUTH_CHECK_CALL = array('done' => TRUE,
857  'file' => $dbg[0]['file'],
858  'line' => $dbg[0]['line'],
859  'method' => __CLASS__.'::'.__FUNCTION__,
860  'result' => $auth );
862  return $auth;
863  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ client()

phpCAS::client (   $server_version,
  $server_hostname,
  $server_port,
  $server_uri,
  $start_session = true 
)

phpCAS client initializer.

Note
Only one of the phpCAS::client() and phpCAS::proxy functions should be called, only once, and before all other methods (except phpCAS::getVersion() and phpCAS::setDebug()).
Parameters
$server_versionthe version of the CAS server
$server_hostnamethe hostname of the CAS server
$server_portthe port the CAS server is running on
$server_urithe URI the CAS server is responding on
$start_sessionHave phpCAS start PHP sessions (default true)
Returns
a newly created CASClient object

Definition at line 270 of file CAS.php.

References $PHPCAS_CLIENT, $PHPCAS_INIT_CALL, backtrace(), error(), traceBegin(), and traceEnd().

275  {
277 
279  if ( is_object($PHPCAS_CLIENT) ) {
280  phpCAS::error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')');
281  }
282  if ( gettype($server_version) != 'string' ) {
283  phpCAS::error('type mismatched for parameter $server_version (should be `string\')');
284  }
285  if ( gettype($server_hostname) != 'string' ) {
286  phpCAS::error('type mismatched for parameter $server_hostname (should be `string\')');
287  }
288  if ( gettype($server_port) != 'integer' ) {
289  phpCAS::error('type mismatched for parameter $server_port (should be `integer\')');
290  }
291  if ( gettype($server_uri) != 'string' ) {
292  phpCAS::error('type mismatched for parameter $server_uri (should be `string\')');
293  }
294 
295  // store where the initialzer is called from
296  $dbg = phpCAS::backtrace();
297  $PHPCAS_INIT_CALL = array('done' => TRUE,
298  'file' => $dbg[0]['file'],
299  'line' => $dbg[0]['line'],
300  'method' => __CLASS__.'::'.__FUNCTION__);
301 
302  // initialize the global object $PHPCAS_CLIENT
303  $PHPCAS_CLIENT = new CASClient($server_version,FALSE/*proxy*/,$server_hostname,$server_port,$server_uri,$start_session);
305  }
$PHPCAS_INIT_CALL
This global variable is used to store where the initializer is called from (to print a comprehensive ...
Definition: CAS.php:184
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
The CASClient class is a client interface that provides CAS authentication to PHP applications...
Definition: client.php:51
+ Here is the call graph for this function:

◆ error()

phpCAS::error (   $msg)
private

This method is used by interface methods to print an error and where the function was originally called from.

Parameters
$msgthe message to print

Definition at line 454 of file CAS.php.

References $file, backtrace(), exit, trace(), and traceExit().

455  {
456  $dbg = phpCAS::backtrace();
457  $function = '?';
458  $file = '?';
459  $line = '?';
460  if ( is_array($dbg) ) {
461  for ( $i=1; $i<sizeof($dbg); $i++) {
462  if ( is_array($dbg[$i]) ) {
463  if ( $dbg[$i]['class'] == __CLASS__ ) {
464  $function = $dbg[$i]['function'];
465  $file = $dbg[$i]['file'];
466  $line = $dbg[$i]['line'];
467  }
468  }
469  }
470  }
471  echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>".__CLASS__."::".$function.'(): '.htmlentities($msg)."</b></font> in <b>".$file."</b> on line <b>".$line."</b><br />\n";
472  phpCAS::trace($msg);
474  exit();
475  }
print $file
exit
Definition: login.php:54
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
traceExit()
This method is used to indicate the end of the execution of the program.
Definition: CAS.php:617
+ Here is the call graph for this function:

◆ forceAuthentication()

phpCAS::forceAuthentication ( )

This method is called to force authentication if the user was not already authenticated.

If the user is not authenticated, halt by redirecting to the CAS server.

Definition at line 870 of file CAS.php.

References $auth, $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, backtrace(), error(), getUser(), trace(), and traceBegin().

871  {
873 
875  if ( !is_object($PHPCAS_CLIENT) ) {
876  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
877  }
878 
879  $auth = $PHPCAS_CLIENT->forceAuthentication();
880 
881  // store where the authentication has been checked and the result
882  $dbg = phpCAS::backtrace();
883  $PHPCAS_AUTH_CHECK_CALL = array('done' => TRUE,
884  'file' => $dbg[0]['file'],
885  'line' => $dbg[0]['line'],
886  'method' => __CLASS__.'::'.__FUNCTION__,
887  'result' => $auth );
888 
889  if ( !$auth ) {
890  phpCAS::trace('user is not authenticated, redirecting to the CAS server');
891  $PHPCAS_CLIENT->forceAuthentication();
892  } else {
893  phpCAS::trace('no need to authenticate (user `'.phpCAS::getUser().'\' is already authenticated)');
894  }
895 
896  phpCAS::traceEnd();
897  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
getUser()
This method returns the CAS user&#39;s login name.
Definition: CAS.php:1075
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
+ Here is the call graph for this function:

◆ getServerLoginURL()

phpCAS::getServerLoginURL ( )

This method returns the URL to be used to login.

or phpCAS::isAuthenticated().

Returns
the login name of the authenticated user

Definition at line 943 of file CAS.php.

References $PHPCAS_CLIENT, and error().

944  {
945  global $PHPCAS_CLIENT;
946  if ( !is_object($PHPCAS_CLIENT) ) {
947  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
948  }
949  return $PHPCAS_CLIENT->getServerLoginURL();
950  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ getServerLogoutURL()

phpCAS::getServerLogoutURL ( )

This method returns the URL to be used to login.

or phpCAS::isAuthenticated().

Returns
the login name of the authenticated user

Definition at line 958 of file CAS.php.

References $PHPCAS_CLIENT, and error().

959  {
960  global $PHPCAS_CLIENT;
961  if ( !is_object($PHPCAS_CLIENT) ) {
962  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
963  }
964  return $PHPCAS_CLIENT->getServerLogoutURL();
965  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ getServiceURL()

phpCAS::getServiceURL ( )

Get the URL that is set as the CAS service parameter.

Definition at line 1030 of file CAS.php.

References $PHPCAS_CLIENT, and error().

1031  {
1032  global $PHPCAS_CLIENT;
1033  if ( !is_object($PHPCAS_CLIENT) ) {
1034  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
1035  }
1036  return($PHPCAS_CLIENT->getURL());
1037  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ getUser()

phpCAS::getUser ( )

This method returns the CAS user's login name.

Warning
should not be called only after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().
Returns
the login name of the authenticated user

Definition at line 922 of file CAS.php.

References $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, and error().

923  {
925  if ( !is_object($PHPCAS_CLIENT) ) {
926  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
927  }
928  if ( !$PHPCAS_AUTH_CHECK_CALL['done'] ) {
929  phpCAS::error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()');
930  }
931  if ( !$PHPCAS_AUTH_CHECK_CALL['result'] ) {
932  phpCAS::error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE');
933  }
934  return $PHPCAS_CLIENT->getUser();
935  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ getVersion()

phpCAS::getVersion ( )

This method returns the phpCAS version.

Returns
the phpCAS version.

Definition at line 585 of file CAS.php.

References PHPCAS_VERSION.

586  {
587  return PHPCAS_VERSION;
588  }
const PHPCAS_VERSION
phpCAS version.
Definition: CAS.php:64

◆ isAuthenticated()

phpCAS::isAuthenticated ( )

This method has been left from version 0.4.19 for compatibility reasons.

Definition at line 910 of file CAS.php.

References error().

911  {
912  phpCAS::error('this method is deprecated. You should use '.__CLASS__.'::forceAuthentication() instead');
913  }
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ log()

phpCAS::log (   $str)
private

Logs a string in debug mode.

Parameters
$strthe string to write

Definition at line 432 of file CAS.php.

References $PHPCAS_DEBUG.

433  {
434  $indent_str = ".";
435  global $PHPCAS_DEBUG;
436 
437  if ( $PHPCAS_DEBUG['filename'] ) {
438  for ($i=0;$i<$PHPCAS_DEBUG['indent'];$i++) {
439  $indent_str .= '| ';
440  }
441  error_log($PHPCAS_DEBUG['unique_id'].' '.$indent_str.$str."\n",3,$PHPCAS_DEBUG['filename']);
442  }
443 
444  }
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
Definition: CAS.php:206

◆ logout()

phpCAS::logout (   $url = "")

This method is used to logout from CAS.

Halts by redirecting to the CAS server.

Parameters
$urla URL that will be transmitted to the CAS server (to come back to when logged out)

Definition at line 971 of file CAS.php.

References $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

972  {
973  global $PHPCAS_CLIENT;
974 
976  if ( !is_object($PHPCAS_CLIENT) ) {
977  phpCAS::error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()');
978  }
979  $PHPCAS_CLIENT->logout($url);
980  // never reached
982  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ proxy()

phpCAS::proxy (   $server_version,
  $server_hostname,
  $server_port,
  $server_uri,
  $start_session = true 
)

phpCAS proxy initializer.

Note
Only one of the phpCAS::client() and phpCAS::proxy functions should be called, only once, and before all other methods (except phpCAS::getVersion() and phpCAS::setDebug()).
Parameters
$server_versionthe version of the CAS server
$server_hostnamethe hostname of the CAS server
$server_portthe port the CAS server is running on
$server_urithe URI the CAS server is responding on
$start_sessionHave phpCAS start PHP sessions (default true)
Returns
a newly created CASClient object

Definition at line 321 of file CAS.php.

References $PHPCAS_CLIENT, $PHPCAS_INIT_CALL, backtrace(), error(), traceBegin(), and traceEnd().

326  {
328 
330  if ( is_object($PHPCAS_CLIENT) ) {
331  phpCAS::error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')');
332  }
333  if ( gettype($server_version) != 'string' ) {
334  phpCAS::error('type mismatched for parameter $server_version (should be `string\')');
335  }
336  if ( gettype($server_hostname) != 'string' ) {
337  phpCAS::error('type mismatched for parameter $server_hostname (should be `string\')');
338  }
339  if ( gettype($server_port) != 'integer' ) {
340  phpCAS::error('type mismatched for parameter $server_port (should be `integer\')');
341  }
342  if ( gettype($server_uri) != 'string' ) {
343  phpCAS::error('type mismatched for parameter $server_uri (should be `string\')');
344  }
345 
346  // store where the initialzer is called from
347  $dbg = phpCAS::backtrace();
348  $PHPCAS_INIT_CALL = array('done' => TRUE,
349  'file' => $dbg[0]['file'],
350  'line' => $dbg[0]['line'],
351  'method' => __CLASS__.'::'.__FUNCTION__);
352 
353  // initialize the global object $PHPCAS_CLIENT
354  $PHPCAS_CLIENT = new CASClient($server_version,TRUE/*proxy*/,$server_hostname,$server_port,$server_uri,$start_session);
356  }
$PHPCAS_INIT_CALL
This global variable is used to store where the initializer is called from (to print a comprehensive ...
Definition: CAS.php:184
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
The CASClient class is a client interface that provides CAS authentication to PHP applications...
Definition: client.php:51
+ Here is the call graph for this function:

◆ retrievePT()

phpCAS::retrievePT (   $target_service,
$err_code,
$err_msg 
)

Retrieve a Proxy Ticket from the CAS server.

Definition at line 1042 of file CAS.php.

References $PHPCAS_CLIENT, and error().

1043  {
1044  global $PHPCAS_CLIENT;
1045  if ( !is_object($PHPCAS_CLIENT) ) {
1046  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
1047  }
1048  if ( gettype($target_service) != 'string' ) {
1049  phpCAS::error('type mismatched for parameter $target_service(should be `string\')');
1050  }
1051  return($PHPCAS_CLIENT->retrievePT($target_service,$err_code,$err_msg));
1052  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ serviceWeb()

phpCAS::serviceWeb (   $url,
$err_code,
$output 
)

This method is used to access an HTTP[S] service.

Parameters
$urlthe service to access.
$err_codean error code Possible values are PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE.
$outputthe output of the service (also used to give an error message on failure).
Returns
TRUE on success, FALSE otherwise (in this later case, $err_code gives the reason why it failed and $output contains an error message).

Definition at line 756 of file CAS.php.

References $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, $res, error(), traceBegin(), and traceEnd().

757  {
759 
761  if ( !is_object($PHPCAS_CLIENT) ) {
762  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
763  }
764  if ( !$PHPCAS_CLIENT->isProxy() ) {
765  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
766  }
767  if ( !$PHPCAS_AUTH_CHECK_CALL['done'] ) {
768  phpCAS::error('this method should only be called after the programmer is sure the user has been authenticated (by calling '.__CLASS__.'::checkAuthentication() or '.__CLASS__.'::forceAuthentication()');
769  }
770  if ( !$PHPCAS_AUTH_CHECK_CALL['result'] ) {
771  phpCAS::error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE');
772  }
773  if ( gettype($url) != 'string' ) {
774  phpCAS::error('type mismatched for parameter $url (should be `string\')');
775  }
776 
777  $res = $PHPCAS_CLIENT->serviceWeb($url,$err_code,$output);
778 
780  return $res;
781  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setDebug()

phpCAS::setDebug (   $filename = '')

Set/unset debug mode.

Parameters
$filenamethe name of the file used for logging, or FALSE to stop debugging.

Definition at line 373 of file CAS.php.

References $filename, $PHPCAS_DEBUG, error(), and trace().

374  {
375  global $PHPCAS_DEBUG;
376 
377  if ( $filename != FALSE && gettype($filename) != 'string' ) {
378  phpCAS::error('type mismatched for parameter $dbg (should be FALSE or the name of the log file)');
379  }
380 
381  if ( empty($filename) ) {
382  if ( preg_match('/^Win.*/',getenv('OS')) ) {
383  if ( isset($_ENV['TMP']) ) {
384  $debugDir = $_ENV['TMP'].'/';
385  } else if ( isset($_ENV['TEMP']) ) {
386  $debugDir = $_ENV['TEMP'].'/';
387  } else {
388  $debugDir = '';
389  }
390  } else {
391  $debugDir = '/tmp/';
392  }
393  $filename = $debugDir . 'phpCAS.log';
394  }
395 
396  if ( empty($PHPCAS_DEBUG['unique_id']) ) {
397  $PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))),0,4);
398  }
399 
400  $PHPCAS_DEBUG['filename'] = $filename;
401 
402  phpCAS::trace('START ******************');
403  }
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
$filename
Definition: buildRTE.php:89
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
Definition: CAS.php:206
+ Here is the call graph for this function:

◆ setExtraCurlOption()

phpCAS::setExtraCurlOption (   $key,
  $value 
)

Change CURL options.

CURL is used to connect through HTTPS to CAS server

Parameters
$keythe option key
$valuethe value to set

Definition at line 1469 of file CAS.php.

References $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

1469  {
1470  global $PHPCAS_CLIENT;
1472  if (!is_object($PHPCAS_CLIENT)) {
1473  phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1474  }
1475  $PHPCAS_CLIENT->setExtraCurlOption($key, $value);
1477  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setFixedCallbackURL()

phpCAS::setFixedCallbackURL (   $url = '')

Set the fixed URL that will be used by the CAS server to transmit the PGT.

When this method is not called, a phpCAS script uses its own URL for the callback.

Parameters
$urlthe URL

Definition at line 990 of file CAS.php.

References $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

991  {
992  global $PHPCAS_CLIENT;
994  if ( !is_object($PHPCAS_CLIENT) ) {
995  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
996  }
997  if ( !$PHPCAS_CLIENT->isProxy() ) {
998  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
999  }
1000  if ( gettype($url) != 'string' ) {
1001  phpCAS::error('type mismatched for parameter $url (should be `string\')');
1002  }
1003  $PHPCAS_CLIENT->setCallbackURL($url);
1004  phpCAS::traceEnd();
1005  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setFixedServiceURL()

phpCAS::setFixedServiceURL (   $url)

Set the fixed URL that will be set as the CAS service parameter.

When this method is not called, a phpCAS script uses its own URL.

Parameters
$urlthe URL

Definition at line 1013 of file CAS.php.

References $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

1014  {
1015  global $PHPCAS_CLIENT;
1017  if ( !is_object($PHPCAS_CLIENT) ) {
1018  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
1019  }
1020  if ( gettype($url) != 'string' ) {
1021  phpCAS::error('type mismatched for parameter $url (should be `string\')');
1022  }
1023  $PHPCAS_CLIENT->setURL($url);
1024  phpCAS::traceEnd();
1025  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setHTMLFooter()

phpCAS::setHTMLFooter (   $footer)

This method sets the HTML footer used for all outputs.

Parameters
$footerthe HTML footer.

Definition at line 621 of file CAS.php.

References $PHPCAS_CLIENT, and error().

622  {
623  global $PHPCAS_CLIENT;
624  if ( !is_object($PHPCAS_CLIENT) ) {
625  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
626  }
627  if ( gettype($footer) != 'string' ) {
628  phpCAS::error('type mismatched for parameter $footer (should be `string\')');
629  }
630  $PHPCAS_CLIENT->setHTMLHeader($header);
631  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setHTMLHeader()

phpCAS::setHTMLHeader (   $header)

This method sets the HTML header used for all outputs.

Parameters
$headerthe HTML header.

Definition at line 604 of file CAS.php.

References $PHPCAS_CLIENT, and error().

605  {
606  global $PHPCAS_CLIENT;
607  if ( !is_object($PHPCAS_CLIENT) ) {
608  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
609  }
610  if ( gettype($header) != 'string' ) {
611  phpCAS::error('type mismatched for parameter $header (should be `string\')');
612  }
613  $PHPCAS_CLIENT->setHTMLHeader($header);
614  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setLang()

phpCAS::setLang (   $lang)

This method is used to set the language used by phpCAS.

Note
Can be called only once.
Parameters
$langa string representing the language.
See also
PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH

Definition at line 559 of file CAS.php.

References $lang, $PHPCAS_CLIENT, and error().

560  {
561  global $PHPCAS_CLIENT;
562  if ( !is_object($PHPCAS_CLIENT) ) {
563  phpCAS::error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()');
564  }
565  if ( gettype($lang) != 'string' ) {
566  phpCAS::error('type mismatched for parameter $lang (should be `string\')');
567  }
568  $PHPCAS_CLIENT->setLang($lang);
569  }
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setPGTStorageDB()

phpCAS::setPGTStorageDB (   $user,
  $password,
  $database_type = '',
  $hostname = '',
  $port = 0,
  $database = '',
  $table = '' 
)

This method is used to tell phpCAS to store the response of the CAS server to PGT requests into a database.

Note
The connection to the database is done only when needed. As a consequence, bad parameters are detected only when initializing PGT storage, except in debug mode.
Parameters
$userthe user to access the data with
$passwordthe user's password
$database_typethe type of the database hosting the data
$hostnamethe server hosting the database
$portthe port the server is listening on
$databasethe name of the database
$tablethe name of the table storing the data

Definition at line 689 of file CAS.php.

References $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

696  {
698 
700  if ( !is_object($PHPCAS_CLIENT) ) {
701  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
702  }
703  if ( !$PHPCAS_CLIENT->isProxy() ) {
704  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
705  }
706  if ( $PHPCAS_AUTH_CHECK_CALL['done'] ) {
707  phpCAS::error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')');
708  }
709  if ( gettype($user) != 'string' ) {
710  phpCAS::error('type mismatched for parameter $user (should be `string\')');
711  }
712  if ( gettype($password) != 'string' ) {
713  phpCAS::error('type mismatched for parameter $password (should be `string\')');
714  }
715  if ( gettype($database_type) != 'string' ) {
716  phpCAS::error('type mismatched for parameter $database_type (should be `string\')');
717  }
718  if ( gettype($hostname) != 'string' ) {
719  phpCAS::error('type mismatched for parameter $hostname (should be `string\')');
720  }
721  if ( gettype($port) != 'integer' ) {
722  phpCAS::error('type mismatched for parameter $port (should be `integer\')');
723  }
724  if ( gettype($database) != 'string' ) {
725  phpCAS::error('type mismatched for parameter $database (should be `string\')');
726  }
727  if ( gettype($table) != 'string' ) {
728  phpCAS::error('type mismatched for parameter $table (should be `string\')');
729  }
730  $PHPCAS_CLIENT->setPGTStorageDB($this,$user,$password,$hostname,$port,$database,$table);
732  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
+ Here is the call graph for this function:

◆ setPGTStorageFile()

phpCAS::setPGTStorageFile (   $format = '',
  $path = '' 
)

This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem.

Parameters
$formatthe format used to store the PGT's (`plain' and `xml' allowed)
$paththe path where the PGT's should be stored

Definition at line 649 of file CAS.php.

References $path, $PHPCAS_AUTH_CHECK_CALL, $PHPCAS_CLIENT, error(), traceBegin(), and traceEnd().

651  {
653 
655  if ( !is_object($PHPCAS_CLIENT) ) {
656  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
657  }
658  if ( !$PHPCAS_CLIENT->isProxy() ) {
659  phpCAS::error('this method should only be called after '.__CLASS__.'::proxy()');
660  }
661  if ( $PHPCAS_AUTH_CHECK_CALL['done'] ) {
662  phpCAS::error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')');
663  }
664  if ( gettype($format) != 'string' ) {
665  phpCAS::error('type mismatched for parameter $format (should be `string\')');
666  }
667  if ( gettype($path) != 'string' ) {
668  phpCAS::error('type mismatched for parameter $format (should be `string\')');
669  }
670  $PHPCAS_CLIENT->setPGTStorageFile($format,$path);
672  }
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
Definition: CAS.php:176
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
Definition: CAS.php:195
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
$path
Definition: index.php:22
+ Here is the call graph for this function:

◆ trace()

phpCAS::trace (   $str)

This method is used to log something in debug mode.

Definition at line 480 of file CAS.php.

References backtrace(), and log().

481  {
482  $dbg = phpCAS::backtrace();
483  phpCAS::log($str.' ['.basename($dbg[1]['file']).':'.$dbg[1]['line'].']');
484  }
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
log($str)
Logs a string in debug mode.
Definition: CAS.php:523
+ Here is the call graph for this function:

◆ traceBegin()

phpCAS::traceBegin ( )

This method is used to indicate the start of the execution of a function in debug mode.

Definition at line 489 of file CAS.php.

References $PHPCAS_DEBUG, backtrace(), and log().

490  {
491  global $PHPCAS_DEBUG;
492 
493  $dbg = phpCAS::backtrace();
494  $str = '=> ';
495  if ( !empty($dbg[2]['class']) ) {
496  $str .= $dbg[2]['class'].'::';
497  }
498  $str .= $dbg[2]['function'].'(';
499  if ( is_array($dbg[2]['args']) ) {
500  foreach ($dbg[2]['args'] as $index => $arg) {
501  if ( $index != 0 ) {
502  $str .= ', ';
503  }
504  $str .= str_replace("\n","",var_export($arg,TRUE));
505  }
506  }
507  $str .= ') ['.basename($dbg[2]['file']).':'.$dbg[2]['line'].']';
508  phpCAS::log($str);
509  $PHPCAS_DEBUG['indent'] ++;
510  }
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
log($str)
Logs a string in debug mode.
Definition: CAS.php:523
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
Definition: CAS.php:206
+ Here is the call graph for this function:

◆ traceEnd()

phpCAS::traceEnd (   $res = '')

This method is used to indicate the end of the execution of a function in debug mode.

Parameters
$resthe result of the function

Definition at line 517 of file CAS.php.

References $PHPCAS_DEBUG, $res, backtrace(), and log().

518  {
519  global $PHPCAS_DEBUG;
520 
521  $PHPCAS_DEBUG['indent'] --;
522  $dbg = phpCAS::backtrace();
523  $str = '';
524  $str .= '<= '.str_replace("\n","",var_export($res,TRUE));
525  phpCAS::log($str);
526  }
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
Definition: CAS.php:507
log($str)
Logs a string in debug mode.
Definition: CAS.php:523
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
Definition: CAS.php:206
+ Here is the call graph for this function:

◆ traceExit()

phpCAS::traceExit ( )

This method is used to indicate the end of the execution of the program.

Definition at line 531 of file CAS.php.

References $PHPCAS_DEBUG, and log().

532  {
533  global $PHPCAS_DEBUG;
534 
535  phpCAS::log('exit()');
536  while ( $PHPCAS_DEBUG['indent'] > 0 ) {
537  phpCAS::log('-');
538  $PHPCAS_DEBUG['indent'] --;
539  }
540  }
log($str)
Logs a string in debug mode.
Definition: CAS.php:523
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
Definition: CAS.php:206
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: