Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-36138 auth_cas: Fix CAS Authentication Strict Standards warnings

  • Loading branch information...
commit 99f66eb13973e82e466e6ca5fd94f830e898f49a 1 parent a5ec499
leblangi authored November 01, 2012
92  auth/cas/CAS/CAS.php
@@ -339,7 +339,7 @@ class phpCAS {
339 339
 	 *
340 340
 	 * @return a newly created CASClient object
341 341
 	 */
342  
-	function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
  342
+	public static function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
343 343
 		global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
344 344
 
345 345
 		phpCAS :: traceBegin();
@@ -388,7 +388,7 @@ function client($server_version, $server_hostname, $server_port, $server_uri, $s
388 388
 	 *
389 389
 	 * @return a newly created CASClient object
390 390
 	 */
391  
-	function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
  391
+	public static function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
392 392
 		global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
393 393
 
394 394
 		phpCAS :: traceBegin();
@@ -438,7 +438,7 @@ function proxy($server_version, $server_hostname, $server_port, $server_uri, $st
438 438
 	 *
439 439
 	 * @param $filename the name of the file used for logging, or FALSE to stop debugging.
440 440
 	 */
441  
-	function setDebug($filename = '') {
  441
+	public static function setDebug($filename = '') {
442 442
 		global $PHPCAS_DEBUG;
443 443
 
444 444
 		if ($filename != FALSE && gettype($filename) != 'string') {
@@ -480,7 +480,7 @@ function setDebug($filename = '') {
480 480
 	 * This method is a wrapper for debug_backtrace() that is not available 
481 481
 	 * in all PHP versions (>= 4.3.0 only)
482 482
 	 */
483  
-	function backtrace() {
  483
+	public static function backtrace() {
484 484
 		if (function_exists('debug_backtrace')) {
485 485
 			return debug_backtrace();
486 486
 		} else {
@@ -496,7 +496,7 @@ function backtrace() {
496 496
 	 *
497 497
 	 * @private
498 498
 	 */
499  
-	function log($str) {
  499
+	public static function log($str) {
500 500
 		$indent_str = ".";
501 501
 		global $PHPCAS_DEBUG;
502 502
 
@@ -517,7 +517,7 @@ function log($str) {
517 517
 	 *
518 518
 	 * @private
519 519
 	 */
520  
-	function error($msg) {
  520
+	public static function error($msg) {
521 521
 		$dbg = phpCAS :: backtrace();
522 522
 		$function = '?';
523 523
 		$file = '?';
@@ -542,7 +542,7 @@ function error($msg) {
542 542
 	/**
543 543
 	 * This method is used to log something in debug mode.
544 544
 	 */
545  
-	function trace($str) {
  545
+	public static function trace($str) {
546 546
 		$dbg = phpCAS :: backtrace();
547 547
 		phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']');
548 548
 	}
@@ -550,7 +550,7 @@ function trace($str) {
550 550
 	/**
551 551
 	 * This method is used to indicate the start of the execution of a function in debug mode.
552 552
 	 */
553  
-	function traceBegin() {
  553
+	public static function traceBegin() {
554 554
 		global $PHPCAS_DEBUG;
555 555
 
556 556
 		$dbg = phpCAS :: backtrace();
@@ -577,7 +577,7 @@ function traceBegin() {
577 577
 	 *
578 578
 	 * @param $res the result of the function
579 579
 	 */
580  
-	function traceEnd($res = '') {
  580
+	public static function traceEnd($res = '') {
581 581
 		global $PHPCAS_DEBUG;
582 582
 
583 583
 		$PHPCAS_DEBUG['indent']--;
@@ -590,7 +590,7 @@ function traceEnd($res = '') {
590 590
 	/**
591 591
 	 * This method is used to indicate the end of the execution of the program
592 592
 	 */
593  
-	function traceExit() {
  593
+	public static function traceExit() {
594 594
 		global $PHPCAS_DEBUG;
595 595
 
596 596
 		phpCAS :: log('exit()');
@@ -617,7 +617,7 @@ function traceExit() {
617 617
 	 *
618 618
 	 * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH
619 619
 	 */
620  
-	function setLang($lang) {
  620
+	public static function setLang($lang) {
621 621
 		global $PHPCAS_CLIENT;
622 622
 		if (!is_object($PHPCAS_CLIENT)) {
623 623
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -642,7 +642,7 @@ function setLang($lang) {
642 642
 	 *
643 643
 	 * @return the phpCAS version.
644 644
 	 */
645  
-	function getVersion() {
  645
+	public static function getVersion() {
646 646
 		return PHPCAS_VERSION;
647 647
 	}
648 648
 
@@ -660,7 +660,7 @@ function getVersion() {
660 660
 	 *
661 661
 	 * @param $header the HTML header.
662 662
 	 */
663  
-	function setHTMLHeader($header) {
  663
+	public static function setHTMLHeader($header) {
664 664
 		global $PHPCAS_CLIENT;
665 665
 		if (!is_object($PHPCAS_CLIENT)) {
666 666
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -676,7 +676,7 @@ function setHTMLHeader($header) {
676 676
 	 *
677 677
 	 * @param $footer the HTML footer.
678 678
 	 */
679  
-	function setHTMLFooter($footer) {
  679
+	public static function setHTMLFooter($footer) {
680 680
 		global $PHPCAS_CLIENT;
681 681
 		if (!is_object($PHPCAS_CLIENT)) {
682 682
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -703,7 +703,7 @@ function setHTMLFooter($footer) {
703 703
 	 * @param $format the format used to store the PGT's (`plain' and `xml' allowed)
704 704
 	 * @param $path the path where the PGT's should be stored
705 705
 	 */
706  
-	function setPGTStorageFile($format = '', $path = '') {
  706
+	public static function setPGTStorageFile($format = '', $path = '') {
707 707
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
708 708
 
709 709
 		phpCAS :: traceBegin();
@@ -749,7 +749,7 @@ function setPGTStorageFile($format = '', $path = '') {
749 749
 	 * @return TRUE on success, FALSE otherwise (in this later case, $err_code
750 750
 	 * gives the reason why it failed and $output contains an error message).
751 751
 	 */
752  
-	function serviceWeb($url, & $err_code, & $output) {
  752
+	public static function serviceWeb($url, & $err_code, & $output) {
753 753
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
754 754
 
755 755
 		phpCAS :: traceBegin();
@@ -792,7 +792,7 @@ function serviceWeb($url, & $err_code, & $output) {
792 792
 	 * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code
793 793
 	 * gives the reason why it failed and $err_msg contains an error message).
794 794
 	 */
795  
-	function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
  795
+	public static function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
796 796
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
797 797
 
798 798
 		phpCAS :: traceBegin();
@@ -839,7 +839,7 @@ function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
839 839
 	 *
840 840
 	 * @param $n an integer.
841 841
 	 */
842  
-	function setCacheTimesForAuthRecheck($n) {
  842
+	public static function setCacheTimesForAuthRecheck($n) {
843 843
 		global $PHPCAS_CLIENT;
844 844
 		if (!is_object($PHPCAS_CLIENT)) {
845 845
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -854,7 +854,7 @@ function setCacheTimesForAuthRecheck($n) {
854 854
 	 * This method is called to check if the user is authenticated (use the gateway feature).
855 855
 	 * @return TRUE when the user is authenticated; otherwise FALSE.
856 856
 	 */
857  
-	function checkAuthentication() {
  857
+	public static function checkAuthentication() {
858 858
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
859 859
 
860 860
 		phpCAS :: traceBegin();
@@ -882,7 +882,7 @@ function checkAuthentication() {
882 882
 	 * authenticated. If the user is not authenticated, halt by redirecting to 
883 883
 	 * the CAS server.
884 884
 	 */
885  
-	function forceAuthentication() {
  885
+	public static function forceAuthentication() {
886 886
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
887 887
 
888 888
 		phpCAS :: traceBegin();
@@ -916,7 +916,7 @@ function forceAuthentication() {
916 916
 	/**
917 917
 	 * This method is called to renew the authentication.
918 918
 	 **/
919  
-	function renewAuthentication() {
  919
+	public static function renewAuthentication() {
920 920
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
921 921
 
922 922
 		phpCAS :: traceBegin();
@@ -941,7 +941,7 @@ function renewAuthentication() {
941 941
 	/**
942 942
 	 * This method has been left from version 0.4.1 for compatibility reasons.
943 943
 	 */
944  
-	function authenticate() {
  944
+	public static function authenticate() {
945 945
 		phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead');
946 946
 	}
947 947
 
@@ -951,7 +951,7 @@ function authenticate() {
951 951
 	 *
952 952
 	 * @return TRUE when the user is authenticated.
953 953
 	 */
954  
-	function isAuthenticated() {
  954
+	public static function isAuthenticated() {
955 955
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
956 956
 
957 957
 		phpCAS :: traceBegin();
@@ -981,7 +981,7 @@ function isAuthenticated() {
981 981
 	 * @return true if authenticated, false otherwise.
982 982
 	 * @since 0.4.22 by Brendan Arnold
983 983
 	 */
984  
-	function isSessionAuthenticated() {
  984
+	public static function isSessionAuthenticated() {
985 985
 		global $PHPCAS_CLIENT;
986 986
 		if (!is_object($PHPCAS_CLIENT)) {
987 987
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -996,7 +996,7 @@ function isSessionAuthenticated() {
996 996
 	 *
997 997
 	 * @return the login name of the authenticated user
998 998
 	 */
999  
-	function getUser() {
  999
+	public static function getUser() {
1000 1000
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1001 1001
 		if (!is_object($PHPCAS_CLIENT)) {
1002 1002
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -1017,7 +1017,7 @@ function getUser() {
1017 1017
 	 *
1018 1018
 	 * @return the login name of the authenticated user
1019 1019
 	 */
1020  
-	function getAttributes() {
  1020
+	public static function getAttributes() {
1021 1021
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1022 1022
 		if (!is_object($PHPCAS_CLIENT)) {
1023 1023
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -1033,7 +1033,7 @@ function getAttributes() {
1033 1033
 	/**
1034 1034
 	 * Handle logout requests.
1035 1035
 	 */
1036  
-	function handleLogoutRequests($check_client = true, $allowed_clients = false) {
  1036
+	public static function handleLogoutRequests($check_client = true, $allowed_clients = false) {
1037 1037
 		global $PHPCAS_CLIENT;
1038 1038
 		if (!is_object($PHPCAS_CLIENT)) {
1039 1039
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -1047,7 +1047,7 @@ function handleLogoutRequests($check_client = true, $allowed_clients = false) {
1047 1047
 	 *
1048 1048
 	 * @return the login name of the authenticated user
1049 1049
 	 */
1050  
-	function getServerLoginURL() {
  1050
+	public static function getServerLoginURL() {
1051 1051
 		global $PHPCAS_CLIENT;
1052 1052
 		if (!is_object($PHPCAS_CLIENT)) {
1053 1053
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -1060,7 +1060,7 @@ function getServerLoginURL() {
1060 1060
 	 * @param $url the login URL
1061 1061
 	 * @since 0.4.21 by Wyman Chan
1062 1062
 	 */
1063  
-	function setServerLoginURL($url = '') {
  1063
+	public static function setServerLoginURL($url = '') {
1064 1064
 		global $PHPCAS_CLIENT;
1065 1065
 		phpCAS :: traceBegin();
1066 1066
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1081,7 +1081,7 @@ function setServerLoginURL($url = '') {
1081 1081
 	 * @param $url the serviceValidate URL
1082 1082
 	 * @since 1.1.0 by Joachim Fritschi
1083 1083
 	 */
1084  
-	function setServerServiceValidateURL($url = '') {
  1084
+	public static function setServerServiceValidateURL($url = '') {
1085 1085
 		global $PHPCAS_CLIENT;
1086 1086
 		phpCAS :: traceBegin();
1087 1087
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1102,7 +1102,7 @@ function setServerServiceValidateURL($url = '') {
1102 1102
 	 * @param $url the proxyValidate URL
1103 1103
 	 * @since 1.1.0 by Joachim Fritschi
1104 1104
 	 */
1105  
-	function setServerProxyValidateURL($url = '') {
  1105
+	public static function setServerProxyValidateURL($url = '') {
1106 1106
 		global $PHPCAS_CLIENT;
1107 1107
 		phpCAS :: traceBegin();
1108 1108
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1122,7 +1122,7 @@ function setServerProxyValidateURL($url = '') {
1122 1122
 	 * @param $url the samlValidate URL
1123 1123
 	 * @since 1.1.0 by Joachim Fritschi
1124 1124
 	 */
1125  
-	function setServerSamlValidateURL($url = '') {
  1125
+	public static function setServerSamlValidateURL($url = '') {
1126 1126
 		global $PHPCAS_CLIENT;
1127 1127
 		phpCAS :: traceBegin();
1128 1128
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1143,7 +1143,7 @@ function setServerSamlValidateURL($url = '') {
1143 1143
 	 *
1144 1144
 	 * @return the login name of the authenticated user
1145 1145
 	 */
1146  
-	function getServerLogoutURL() {
  1146
+	public static function getServerLogoutURL() {
1147 1147
 		global $PHPCAS_CLIENT;
1148 1148
 		if (!is_object($PHPCAS_CLIENT)) {
1149 1149
 			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
@@ -1156,7 +1156,7 @@ function getServerLogoutURL() {
1156 1156
 	 * @param $url the logout URL
1157 1157
 	 * @since 0.4.21 by Wyman Chan
1158 1158
 	 */
1159  
-	function setServerLogoutURL($url = '') {
  1159
+	public static function setServerLogoutURL($url = '') {
1160 1160
 		global $PHPCAS_CLIENT;
1161 1161
 		phpCAS :: traceBegin();
1162 1162
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1176,7 +1176,7 @@ function setServerLogoutURL($url = '') {
1176 1176
 	 * @params $params an array that contains the optional url and service parameters that will be passed to the CAS server
1177 1177
 	 * @public
1178 1178
 	 */
1179  
-	function logout($params = "") {
  1179
+	public static function logout($params = "") {
1180 1180
 		global $PHPCAS_CLIENT;
1181 1181
 		phpCAS :: traceBegin();
1182 1182
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1206,7 +1206,7 @@ function logout($params = "") {
1206 1206
 	 * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1207 1207
 	 * @param $service a URL that will be transmitted to the CAS server
1208 1208
 	 */
1209  
-	function logoutWithRedirectService($service) {
  1209
+	public static function logoutWithRedirectService($service) {
1210 1210
 		global $PHPCAS_CLIENT;
1211 1211
 		phpCAS :: traceBegin();
1212 1212
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1226,7 +1226,7 @@ function logoutWithRedirectService($service) {
1226 1226
 	 * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1227 1227
 	 * @param $url a URL that will be transmitted to the CAS server
1228 1228
 	 */
1229  
-	function logoutWithUrl($url) {
  1229
+	public static function logoutWithUrl($url) {
1230 1230
 		global $PHPCAS_CLIENT;
1231 1231
 		phpCAS :: traceBegin();
1232 1232
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1247,7 +1247,7 @@ function logoutWithUrl($url) {
1247 1247
 	 * @param $service a URL that will be transmitted to the CAS server
1248 1248
 	 * @param $url a URL that will be transmitted to the CAS server
1249 1249
 	 */
1250  
-	function logoutWithRedirectServiceAndUrl($service, $url) {
  1250
+	public static function logoutWithRedirectServiceAndUrl($service, $url) {
1251 1251
 		global $PHPCAS_CLIENT;
1252 1252
 		phpCAS :: traceBegin();
1253 1253
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1273,7 +1273,7 @@ function logoutWithRedirectServiceAndUrl($service, $url) {
1273 1273
 	 *
1274 1274
 	 * @param $url the URL
1275 1275
 	 */
1276  
-	function setFixedCallbackURL($url = '') {
  1276
+	public static function setFixedCallbackURL($url = '') {
1277 1277
 		global $PHPCAS_CLIENT;
1278 1278
 		phpCAS :: traceBegin();
1279 1279
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1295,7 +1295,7 @@ function setFixedCallbackURL($url = '') {
1295 1295
 	 *
1296 1296
 	 * @param $url the URL
1297 1297
 	 */
1298  
-	function setFixedServiceURL($url) {
  1298
+	public static function setFixedServiceURL($url) {
1299 1299
 		global $PHPCAS_CLIENT;
1300 1300
 		phpCAS :: traceBegin();
1301 1301
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1311,7 +1311,7 @@ function setFixedServiceURL($url) {
1311 1311
 	/**
1312 1312
 	 * Get the URL that is set as the CAS service parameter.
1313 1313
 	 */
1314  
-	function getServiceURL() {
  1314
+	public static function getServiceURL() {
1315 1315
 		global $PHPCAS_CLIENT;
1316 1316
 		if (!is_object($PHPCAS_CLIENT)) {
1317 1317
 			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
@@ -1322,7 +1322,7 @@ function getServiceURL() {
1322 1322
 	/**
1323 1323
 	 * Retrieve a Proxy Ticket from the CAS server.
1324 1324
 	 */
1325  
-	function retrievePT($target_service, & $err_code, & $err_msg) {
  1325
+	public static function retrievePT($target_service, & $err_code, & $err_msg) {
1326 1326
 		global $PHPCAS_CLIENT;
1327 1327
 		if (!is_object($PHPCAS_CLIENT)) {
1328 1328
 			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
@@ -1338,7 +1338,7 @@ function retrievePT($target_service, & $err_code, & $err_msg) {
1338 1338
 	 *
1339 1339
 	 * @param $cert the PEM certificate
1340 1340
 	 */
1341  
-	function setCasServerCert($cert) {
  1341
+	public static function setCasServerCert($cert) {
1342 1342
 		global $PHPCAS_CLIENT;
1343 1343
 		phpCAS :: traceBegin();
1344 1344
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1356,7 +1356,7 @@ function setCasServerCert($cert) {
1356 1356
 	 *
1357 1357
 	 * @param $cert the CA certificate
1358 1358
 	 */
1359  
-	function setCasServerCACert($cert) {
  1359
+	public static function setCasServerCACert($cert) {
1360 1360
 		global $PHPCAS_CLIENT;
1361 1361
 		phpCAS :: traceBegin();
1362 1362
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1372,7 +1372,7 @@ function setCasServerCACert($cert) {
1372 1372
 	/**
1373 1373
 	 * Set no SSL validation for the CAS server.
1374 1374
 	 */
1375  
-	function setNoCasServerValidation() {
  1375
+	public static function setNoCasServerValidation() {
1376 1376
 		global $PHPCAS_CLIENT;
1377 1377
 		phpCAS :: traceBegin();
1378 1378
 		if (!is_object($PHPCAS_CLIENT)) {
@@ -1390,7 +1390,7 @@ function setNoCasServerValidation() {
1390 1390
 	 * @param $key the option key
1391 1391
 	 * @param $value the value to set
1392 1392
 	 */
1393  
-	function setExtraCurlOption($key, $value) {
  1393
+	public static function setExtraCurlOption($key, $value) {
1394 1394
 		global $PHPCAS_CLIENT;
1395 1395
 		phpCAS :: traceBegin();
1396 1396
 		if (!is_object($PHPCAS_CLIENT)) {
2  auth/cas/auth.php
@@ -104,12 +104,14 @@ function loginpage_hook() {
104 104
         $this->connectCAS();
105 105
 
106 106
         if (phpCAS::checkAuthentication()) {
  107
+            $frm = new stdClass();
107 108
             $frm->username = phpCAS::getUser();
108 109
             $frm->password = 'passwdCas';
109 110
             return;
110 111
         }
111 112
 
112 113
         if (isset($_GET['loginguest']) && ($_GET['loginguest'] == true)) {
  114
+            $frm = new stdClass();
113 115
             $frm->username = 'guest';
114 116
             $frm->password = 'guest';
115 117
             return;

0 notes on commit 99f66eb

Please sign in to comment.
Something went wrong with that request. Please try again.