35 if (!$_SERVER[
'REQUEST_URI']) {
36 $_SERVER[
'REQUEST_URI'] = $_SERVER[
'SCRIPT_NAME'] .
'?' . $_SERVER[
'QUERY_STRING'];
42 if (version_compare(PHP_VERSION,
'5',
'>=') && !(function_exists(
'domxml_new_doc'))) {
43 require_once (dirname(__FILE__) .
'/CAS/domxml-php4-to-php5.php');
64 define(
'PHPCAS_VERSION',
'1.1.2');
77 define(
"CAS_VERSION_1_0",
'1.0');
81 define(
"CAS_VERSION_2_0",
'2.0');
90 define(
"SAML_VERSION_1_1",
'S1');
95 define(
"SAML_XML_HEADER",
'<?xml version="1.0" encoding="UTF-8"?>');
100 define(
"SAML_SOAP_ENV",
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/>');
105 define(
"SAML_SOAP_BODY",
'<SOAP-ENV:Body>');
110 define(
"SAMLP_REQUEST",
'<samlp:Request xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" MajorVersion="1" MinorVersion="1" RequestID="_192.168.16.51.1024506224022" IssueInstant="2002-06-19T17:03:44.022Z">');
111 define(
"SAMLP_REQUEST_CLOSE",
'</samlp:Request>');
116 define(
"SAML_ASSERTION_ARTIFACT",
'<samlp:AssertionArtifact>');
121 define(
"SAML_ASSERTION_ARTIFACT_CLOSE",
'</samlp:AssertionArtifact>');
126 define(
"SAML_SOAP_BODY_CLOSE",
'</SOAP-ENV:Body>');
131 define(
"SAML_SOAP_ENV_CLOSE",
'</SOAP-ENV:Envelope>');
136 define(
"SAML_ATTRIBUTES",
'SAMLATTRIBS');
149 define(
"CAS_PGT_STORAGE_FILE_DEFAULT_PATH",
'/tmp');
153 define(
"CAS_PGT_STORAGE_FILE_FORMAT_PLAIN",
'plain');
157 define(
"CAS_PGT_STORAGE_FILE_FORMAT_XML",
'xml');
168 define(
"CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE",
'mysql');
172 define(
"CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME",
'localhost');
176 define(
"CAS_PGT_STORAGE_DB_DEFAULT_PORT",
'');
180 define(
"CAS_PGT_STORAGE_DB_DEFAULT_DATABASE",
'phpCAS');
184 define(
"CAS_PGT_STORAGE_DB_DEFAULT_TABLE",
'pgt');
198 define(
"PHPCAS_SERVICE_OK", 0);
203 define(
"PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE", 1);
208 define(
"PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE", 2);
213 define(
"PHPCAS_SERVICE_PT_FAILURE", 3);
217 define(
"PHPCAS_SERVICE_NOT AVAILABLE", 4);
228 define(
"PHPCAS_LANG_ENGLISH",
'english');
229 define(
"PHPCAS_LANG_FRENCH",
'french');
230 define(
"PHPCAS_LANG_GREEK",
'greek');
231 define(
"PHPCAS_LANG_GERMAN",
'german');
232 define(
"PHPCAS_LANG_JAPANESE",
'japanese');
233 define(
"PHPCAS_LANG_SPANISH",
'spanish');
234 define(
"PHPCAS_LANG_CATALAN",
'catalan');
260 define(
'DEFAULT_DEBUG_DIR',
'/tmp/');
323 include_once (dirname(__FILE__) .
'/CAS/client.php');
366 function client($server_version, $server_hostname, $server_port, $server_uri, $start_session =
true) {
370 if (is_object($PHPCAS_CLIENT)) {
371 phpCAS :: error($PHPCAS_INIT_CALL[
'method'] .
'() has already been called (at ' . $PHPCAS_INIT_CALL[
'file'] .
':' . $PHPCAS_INIT_CALL[
'line'] .
')');
373 if (gettype($server_version) !=
'string') {
374 phpCAS :: error(
'type mismatched for parameter $server_version (should be `string\')');
376 if (gettype($server_hostname) !=
'string') {
377 phpCAS :: error(
'type mismatched for parameter $server_hostname (should be `string\')');
379 if (gettype($server_port) !=
'integer') {
380 phpCAS :: error(
'type mismatched for parameter $server_port (should be `integer\')');
382 if (gettype($server_uri) !=
'string') {
383 phpCAS :: error(
'type mismatched for parameter $server_uri (should be `string\')');
388 $PHPCAS_INIT_CALL = array (
390 'file' => $dbg[0][
'file'],
391 'line' => $dbg[0][
'line'],
392 'method' => __CLASS__ .
'::' . __FUNCTION__
396 $PHPCAS_CLIENT =
new CASClient($server_version, FALSE
397 , $server_hostname, $server_port, $server_uri, $start_session);
415 function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session =
true) {
419 if (is_object($PHPCAS_CLIENT)) {
420 phpCAS :: error($PHPCAS_INIT_CALL[
'method'] .
'() has already been called (at ' . $PHPCAS_INIT_CALL[
'file'] .
':' . $PHPCAS_INIT_CALL[
'line'] .
')');
422 if (gettype($server_version) !=
'string') {
423 phpCAS :: error(
'type mismatched for parameter $server_version (should be `string\')');
425 if (gettype($server_hostname) !=
'string') {
426 phpCAS :: error(
'type mismatched for parameter $server_hostname (should be `string\')');
428 if (gettype($server_port) !=
'integer') {
429 phpCAS :: error(
'type mismatched for parameter $server_port (should be `integer\')');
431 if (gettype($server_uri) !=
'string') {
432 phpCAS :: error(
'type mismatched for parameter $server_uri (should be `string\')');
437 $PHPCAS_INIT_CALL = array (
439 'file' => $dbg[0][
'file'],
440 'line' => $dbg[0][
'line'],
441 'method' => __CLASS__ .
'::' . __FUNCTION__
445 $PHPCAS_CLIENT =
new CASClient($server_version, TRUE
446 , $server_hostname, $server_port, $server_uri, $start_session);
469 phpCAS :: error(
'type mismatched for parameter $dbg (should be FALSE or the name of the log file)');
473 if (preg_match(
'/^Win.*/', getenv(
'OS'))) {
474 if (isset ($_ENV[
'TMP'])) {
475 $debugDir = $_ENV[
'TMP'] .
'/';
477 if (isset ($_ENV[
'TEMP'])) {
478 $debugDir = $_ENV[
'TEMP'] .
'/';
488 if (empty ($PHPCAS_DEBUG[
'unique_id'])) {
489 $PHPCAS_DEBUG[
'unique_id'] = substr(strtoupper(md5(uniqid(
''))), 0, 4);
508 if (function_exists(
'debug_backtrace')) {
509 return debug_backtrace();
527 if ($PHPCAS_DEBUG[
'filename']) {
528 for ($i = 0; $i < $PHPCAS_DEBUG[
'indent']; $i++) {
531 error_log($PHPCAS_DEBUG[
'unique_id'] .
' ' . $indent_str . $str .
"\n", 3, $PHPCAS_DEBUG[
'filename']);
549 if (is_array($dbg)) {
550 for ($i = 1; $i <
sizeof($dbg); $i++) {
551 if (is_array($dbg[$i])) {
552 if ($dbg[$i][
'class'] == __CLASS__) {
553 $function = $dbg[$i][
'function'];
554 $file = $dbg[$i][
'file'];
555 $line = $dbg[$i][
'line'];
560 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";
571 phpCAS :: log($str .
' [' . basename($dbg[1][
'file']) .
':' . $dbg[1][
'line'] .
']');
582 if (!empty ($dbg[2][
'class'])) {
583 $str .= $dbg[2][
'class'] .
'::';
585 $str .= $dbg[2][
'function'] .
'(';
586 if (is_array($dbg[2][
'args'])) {
587 foreach ($dbg[2][
'args'] as $index => $arg) {
591 $str .= str_replace(
"\n",
"", var_export($arg, TRUE));
594 $str .=
') [' . basename($dbg[2][
'file']) .
':' . $dbg[2][
'line'] .
']';
596 $PHPCAS_DEBUG[
'indent']++;
607 $PHPCAS_DEBUG[
'indent']--;
610 $str .=
'<= ' . str_replace(
"\n",
"", var_export(
$res, TRUE));
621 while ($PHPCAS_DEBUG[
'indent'] > 0) {
623 $PHPCAS_DEBUG[
'indent']--;
646 if (!is_object($PHPCAS_CLIENT)) {
647 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
649 if (gettype(
$lang) !=
'string') {
650 phpCAS :: error(
'type mismatched for parameter $lang (should be `string\')');
652 $PHPCAS_CLIENT->setLang(
$lang);
689 if (!is_object($PHPCAS_CLIENT)) {
690 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
692 if (gettype($header) !=
'string') {
693 phpCAS :: error(
'type mismatched for parameter $header (should be `string\')');
695 $PHPCAS_CLIENT->setHTMLHeader($header);
705 if (!is_object($PHPCAS_CLIENT)) {
706 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
708 if (gettype($footer) !=
'string') {
709 phpCAS :: error(
'type mismatched for parameter $footer (should be `string\')');
711 $PHPCAS_CLIENT->setHTMLFooter($footer);
734 if (!is_object($PHPCAS_CLIENT)) {
735 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
737 if (!$PHPCAS_CLIENT->isProxy()) {
738 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
740 if ($PHPCAS_AUTH_CHECK_CALL[
'done']) {
741 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'] .
')');
743 if (gettype($format) !=
'string') {
744 phpCAS :: error(
'type mismatched for parameter $format (should be `string\')');
746 if (gettype(
$path) !=
'string') {
747 phpCAS :: error(
'type mismatched for parameter $format (should be `string\')');
749 $PHPCAS_CLIENT->setPGTStorageFile($format,
$path);
768 function setPGTStorageDB($user, $password, $database_type =
'', $hostname =
'', $port = 0, $database =
'', $table =
'') {
772 if (!is_object($PHPCAS_CLIENT)) {
773 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
775 if (!$PHPCAS_CLIENT->isProxy()) {
776 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
778 if ($PHPCAS_AUTH_CHECK_CALL[
'done']) {
779 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'] .
')');
781 if (gettype($user) !=
'string') {
782 phpCAS :: error(
'type mismatched for parameter $user (should be `string\')');
784 if (gettype($password) !=
'string') {
785 phpCAS :: error(
'type mismatched for parameter $password (should be `string\')');
787 if (gettype($database_type) !=
'string') {
788 phpCAS :: error(
'type mismatched for parameter $database_type (should be `string\')');
790 if (gettype($hostname) !=
'string') {
791 phpCAS :: error(
'type mismatched for parameter $hostname (should be `string\')');
793 if (gettype($port) !=
'integer') {
794 phpCAS :: error(
'type mismatched for parameter $port (should be `integer\')');
796 if (gettype($database) !=
'string') {
797 phpCAS :: error(
'type mismatched for parameter $database (should be `string\')');
799 if (gettype($table) !=
'string') {
800 phpCAS :: error(
'type mismatched for parameter $table (should be `string\')');
802 $PHPCAS_CLIENT->setPGTStorageDB($user, $password, $database_type, $hostname, $port, $database, $table);
832 if (!is_object($PHPCAS_CLIENT)) {
833 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
835 if (!$PHPCAS_CLIENT->isProxy()) {
836 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
838 if (!$PHPCAS_AUTH_CHECK_CALL[
'done']) {
839 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()');
841 if (!$PHPCAS_AUTH_CHECK_CALL[
'result']) {
842 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');
844 if (gettype($url) !=
'string') {
845 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
848 $res = $PHPCAS_CLIENT->serviceWeb($url, $err_code, $output);
871 function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
875 if (!is_object($PHPCAS_CLIENT)) {
876 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
878 if (!$PHPCAS_CLIENT->isProxy()) {
879 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
881 if (!$PHPCAS_AUTH_CHECK_CALL[
'done']) {
882 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()');
884 if (!$PHPCAS_AUTH_CHECK_CALL[
'result']) {
885 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');
887 if (gettype($url) !=
'string') {
888 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
891 if (gettype($flags) !=
'integer') {
892 phpCAS :: error(
'type mismatched for parameter $flags (should be `integer\')');
895 $res = $PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt);
920 if (!is_object($PHPCAS_CLIENT)) {
921 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
923 if (gettype(
$n) !=
'integer') {
924 phpCAS :: error(
'type mismatched for parameter $header (should be `string\')');
926 $PHPCAS_CLIENT->setCacheTimesForAuthRecheck(
$n);
937 if (!is_object($PHPCAS_CLIENT)) {
938 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
941 $auth = $PHPCAS_CLIENT->checkAuthentication();
945 $PHPCAS_AUTH_CHECK_CALL = array (
947 'file' => $dbg[0][
'file'],
948 'line' => $dbg[0][
'line'],
949 'method' => __CLASS__ .
'::' . __FUNCTION__,
965 if (!is_object($PHPCAS_CLIENT)) {
966 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
969 $auth = $PHPCAS_CLIENT->forceAuthentication();
973 $PHPCAS_AUTH_CHECK_CALL = array (
975 'file' => $dbg[0][
'file'],
976 'line' => $dbg[0][
'line'],
977 'method' => __CLASS__ .
'::' . __FUNCTION__,
982 phpCAS :: trace(
'user is not authenticated, redirecting to the CAS server');
983 $PHPCAS_CLIENT->forceAuthentication();
988 phpCAS :: traceEnd(); 995 function renewAuthentication() { 996 global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; 998 phpCAS :: traceBegin(); 999 if (!is_object($PHPCAS_CLIENT)) { 1000 phpCAS :: error('this method should not be called before
' . __CLASS__ . '::client() or ' . __CLASS__ . '::
proxy()');
1005 $PHPCAS_AUTH_CHECK_CALL = array (
1007 'file' => $dbg[0]['file'],
1008 'line' => $dbg[0]['line'],
1009 'method' => __CLASS__ . '::' . __FUNCTION__,
1021 phpCAS :: error(
'this method is deprecated. You should use ' . __CLASS__ .
'::forceAuthentication() instead');
1034 if (!is_object($PHPCAS_CLIENT)) {
1035 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1039 $auth = $PHPCAS_CLIENT->isAuthenticated();
1043 $PHPCAS_AUTH_CHECK_CALL = array (
1045 'file' => $dbg[0][
'file'],
1046 'line' => $dbg[0][
'line'],
1047 'method' => __CLASS__ .
'::' . __FUNCTION__,
1062 if (!is_object($PHPCAS_CLIENT)) {
1063 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1065 return ($PHPCAS_CLIENT->isSessionAuthenticated());
1077 if (!is_object($PHPCAS_CLIENT)) {
1078 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1080 if (!$PHPCAS_AUTH_CHECK_CALL[
'done']) {
1081 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::forceAuthentication() or ' . __CLASS__ .
'::isAuthenticated()');
1083 if (!$PHPCAS_AUTH_CHECK_CALL[
'result']) {
1084 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');
1086 return $PHPCAS_CLIENT->getUser();
1098 if (!is_object($PHPCAS_CLIENT)) {
1099 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1101 if (!$PHPCAS_AUTH_CHECK_CALL[
'done']) {
1102 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::forceAuthentication() or ' . __CLASS__ .
'::isAuthenticated()');
1104 if (!$PHPCAS_AUTH_CHECK_CALL[
'result']) {
1105 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');
1107 return $PHPCAS_CLIENT->getAttributes();
1114 if (!is_object($PHPCAS_CLIENT)) {
1115 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1117 return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients));
1128 if (!is_object($PHPCAS_CLIENT)) {
1129 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1131 return $PHPCAS_CLIENT->getServerLoginURL();
1142 if (!is_object($PHPCAS_CLIENT)) {
1144 ' . __CLASS__ .
'::client()');
1146 if (gettype($url) !=
'string') {
1150 $PHPCAS_CLIENT->setServerLoginURL($url);
1163 if (!is_object($PHPCAS_CLIENT)) {
1165 ' . __CLASS__ .
'::client()');
1167 if (gettype($url) !=
'string') {
1171 $PHPCAS_CLIENT->setServerServiceValidateURL($url);
1184 if (!is_object($PHPCAS_CLIENT)) {
1186 ' . __CLASS__ .
'::client()');
1188 if (gettype($url) !=
'string') {
1192 $PHPCAS_CLIENT->setServerProxyValidateURL($url);
1204 if (!is_object($PHPCAS_CLIENT)) {
1206 ' . __CLASS__ .
'::client()');
1208 if (gettype($url) !=
'string') {
1212 $PHPCAS_CLIENT->setServerSamlValidateURL($url);
1224 if (!is_object($PHPCAS_CLIENT)) {
1225 phpCAS :: error(
'this method should not be called before ' . __CLASS__ .
'::client() or ' . __CLASS__ .
'::proxy()');
1227 return $PHPCAS_CLIENT->getServerLogoutURL();
1238 if (!is_object($PHPCAS_CLIENT)) {
1240 ' . __CLASS__ .
'::client()');
1242 if (gettype($url) !=
'string') {
1246 $PHPCAS_CLIENT->setServerLogoutURL($url);
1258 if (!is_object($PHPCAS_CLIENT)) {
1259 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1261 $parsedParams = array ();
1262 if ($params !=
"") {
1263 if (is_string($params)) {
1264 phpCAS :: error(
'method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead');
1266 if (!is_array($params)) {
1267 phpCAS :: error(
'type mismatched for parameter $params (should be `array\')');
1269 foreach ($params as $key => $value) {
1270 if ($key !=
"service" && $key !=
"url") {
1271 phpCAS :: error(
'only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\'');
1273 $parsedParams[$key] = $value;
1276 $PHPCAS_CLIENT->logout($parsedParams);
1288 if (!is_object($PHPCAS_CLIENT)) {
1289 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1291 if (!is_string($service)) {
1292 phpCAS :: error(
'type mismatched for parameter $service (should be `string\')');
1294 $PHPCAS_CLIENT->logout(array (
1295 "service" => $service
1308 if (!is_object($PHPCAS_CLIENT)) {
1309 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1311 if (!is_string($url)) {
1312 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
1314 $PHPCAS_CLIENT->logout(array (
1329 if (!is_object($PHPCAS_CLIENT)) {
1330 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1332 if (!is_string($service)) {
1333 phpCAS :: error(
'type mismatched for parameter $service (should be `string\')');
1335 if (!is_string($url)) {
1336 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
1338 $PHPCAS_CLIENT->logout(array (
1339 "service" => $service,
1355 if (!is_object($PHPCAS_CLIENT)) {
1356 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
1358 if (!$PHPCAS_CLIENT->isProxy()) {
1359 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
1361 if (gettype($url) !=
'string') {
1362 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
1364 $PHPCAS_CLIENT->setCallbackURL($url);
1377 if (!is_object($PHPCAS_CLIENT)) {
1378 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
1380 if (gettype($url) !=
'string') {
1381 phpCAS :: error(
'type mismatched for parameter $url (should be `string\')');
1383 $PHPCAS_CLIENT->setURL($url);
1392 if (!is_object($PHPCAS_CLIENT)) {
1393 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
1395 return ($PHPCAS_CLIENT->getURL());
1403 if (!is_object($PHPCAS_CLIENT)) {
1404 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::proxy()');
1406 if (gettype($target_service) !=
'string') {
1407 phpCAS :: error(
'type mismatched for parameter $target_service(should be `string\')');
1409 return ($PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg));
1420 if (!is_object($PHPCAS_CLIENT)) {
1421 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1423 if (gettype($cert) !=
'string') {
1424 phpCAS :: error(
'type mismatched for parameter $cert (should be `string\')');
1426 $PHPCAS_CLIENT->setCasServerCert($cert);
1438 if (!is_object($PHPCAS_CLIENT)) {
1439 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1441 if (gettype($cert) !=
'string') {
1442 phpCAS :: error(
'type mismatched for parameter $cert (should be `string\')');
1444 $PHPCAS_CLIENT->setCasServerCACert($cert);
1454 if (!is_object($PHPCAS_CLIENT)) {
1455 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1457 $PHPCAS_CLIENT->setNoCasServerValidation();
1472 if (!is_object($PHPCAS_CLIENT)) {
1473 phpCAS :: error(
'this method should only be called after ' . __CLASS__ .
'::client() or' . __CLASS__ .
'::proxy()');
1475 $PHPCAS_CLIENT->setExtraCurlOption($key, $value);
setHTMLFooter($footer)
This method sets the HTML footer used for all outputs.
$PHPCAS_INIT_CALL
This global variable is used to store where the initializer is called from (to print a comprehensive ...
setFixedCallbackURL($url='')
Set the fixed URL that will be used by the CAS server to transmit the PGT.
setServerServiceValidateURL($url='')
Set the serviceValidate URL of the CAS server.
setNoCasServerValidation()
Set no SSL validation for the CAS server.
logoutWithUrl($url)
This method is used to logout from CAS.
The phpCAS class is a simple container for the phpCAS library.
retrievePT($target_service, & $err_code, & $err_msg)
Retrieve a Proxy Ticket from the CAS server.
authenticate()
This method has been left from version 0.4.1 for compatibility reasons.
getAttributes()
This method returns the CAS user's login name.
setCasServerCert($cert)
Set the certificate of the CAS server.
checkAuthentication()
This method is called to check if the user is authenticated (use the gateway feature).
client($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
phpCAS client initializer.
setExtraCurlOption($key, $value)
Change CURL options.
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
$PHPCAS_CLIENT
This global variable is used by the interface class phpCAS.
setLang($lang)
This method is used to set the language used by phpCAS.
handleLogoutRequests($check_client=true, $allowed_clients=false)
Handle logout requests.
setFixedServiceURL($url)
Set the fixed URL that will be set as the CAS service parameter.
setPGTStorageFile($format='', $path='')
This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the f...
backtrace()
This method is a wrapper for debug_backtrace() that is not available in all PHP versions (>= 4...
isSessionAuthenticated()
Checks whether authenticated based on $_SESSION.
$PHPCAS_AUTH_CHECK_CALL
This global variable is used to store where the method checking the authentication is called from (to...
logout($params="")
This method is used to logout from CAS.
forceAuthentication()
This method is called to force authentication if the user was not already authenticated.
setDebug($filename='')
Set/unset debug mode.
getServiceURL()
Get the URL that is set as the CAS service parameter.
logoutWithRedirectServiceAndUrl($service, $url)
This method is used to logout from CAS.
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 dat...
proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session=true)
phpCAS proxy initializer.
setServerLoginURL($url='')
Set the login URL of the CAS server.
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
serviceWeb($url, & $err_code, & $output)
This method is used to access an HTTP[S] service.
getUser()
This method returns the CAS user's login name.
const PHPCAS_LANG_ENGLISH
logoutWithRedirectService($service)
This method is used to logout from CAS.
getServerLogoutURL()
This method returns the URL to be used to login.
getVersion()
This method returns the phpCAS version.
renewAuthentication()
This method is called to renew the authentication.
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
const DEFAULT_DEBUG_DIR
The default directory for the debug file under Unix.
isAuthenticated()
This method is called to check if the user is authenticated (previously or by tickets given in the UR...
setServerLogoutURL($url='')
Set the logout URL of the CAS server.
trace($str)
This method is used to log something in debug mode.
setServerProxyValidateURL($url='')
Set the proxyValidate URL of the CAS server.
setHTMLHeader($header)
This method sets the HTML header used for all outputs.
log($str)
Logs a string in debug mode.
setCasServerCACert($cert)
Set the certificate of the CAS server CA.
const PHPCAS_VERSION
phpCAS version.
const CAS_PGT_STORAGE_FILE_FORMAT_PLAIN
phpCAS::setPGTStorageFile()'s 2nd parameter to write plain text files
$PHPCAS_DEBUG
This global variable is used to store phpCAS debug mode.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
setServerSamlValidateURL($url='')
Set the samlValidate URL of the CAS server.
traceExit()
This method is used to indicate the end of the execution of the program.
getServerLoginURL()
This method returns the URL to be used to login.
setCacheTimesForAuthRecheck($n)
Set the times authentication will be cached before really accessing the CAS server in gateway mode: ...
The CASClient class is a client interface that provides CAS authentication to PHP applications...
serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt)
This method is used to access an IMAP/POP3/NNTP service.