Permalink
Browse files

MDL-31938, MDL-36138 auth_cas: upgrade phpCAS library

Proxy mode changes testing still pending (we don't have such a setup).
  • Loading branch information...
iarenaza authored and danpoltawski committed Oct 21, 2012
1 parent 4e47920 commit 02a9e4a7f355849c7f86276cef5482c0f53990ff
Showing with 10,755 additions and 5,529 deletions.
  1. +1,980 −1,532 auth/cas/CAS/CAS.php
  2. +107 −0 auth/cas/CAS/CAS/AuthenticationException.php
  3. +97 −0 auth/cas/CAS/CAS/Autoload.php
  4. +3,401 −0 auth/cas/CAS/CAS/Client.php
  5. +377 −0 auth/cas/CAS/CAS/CookieJar.php
  6. +59 −0 auth/cas/CAS/CAS/Exception.php
  7. +86 −0 auth/cas/CAS/CAS/GracefullTerminationException.php
  8. +46 −0 auth/cas/CAS/CAS/InvalidArgumentException.php
  9. +114 −0 auth/cas/CAS/CAS/Languages/Catalan.php
  10. +114 −0 auth/cas/CAS/CAS/Languages/English.php
  11. +116 −0 auth/cas/CAS/CAS/Languages/French.php
  12. +116 −0 auth/cas/CAS/CAS/Languages/German.php
  13. +115 −0 auth/cas/CAS/CAS/Languages/Greek.php
  14. +113 −0 auth/cas/CAS/CAS/Languages/Japanese.php
  15. +96 −0 auth/cas/CAS/CAS/Languages/LanguageInterface.php
  16. +117 −0 auth/cas/CAS/CAS/Languages/Spanish.php
  17. +49 −0 auth/cas/CAS/CAS/OutOfSequenceException.php
  18. +220 −0 auth/cas/CAS/CAS/PGTStorage/AbstractStorage.php
  19. +429 −0 auth/cas/CAS/CAS/PGTStorage/Db.php
  20. +259 −0 auth/cas/CAS/CAS/PGTStorage/File.php
  21. +0 −283 auth/cas/CAS/CAS/PGTStorage/pgt-file.php
  22. +0 −214 auth/cas/CAS/CAS/PGTStorage/pgt-main.php
  23. +72 −0 auth/cas/CAS/CAS/ProxiedService.php
  24. +138 −0 auth/cas/CAS/CAS/ProxiedService/Abstract.php
  25. +46 −0 auth/cas/CAS/CAS/ProxiedService/Exception.php
  26. +91 −0 auth/cas/CAS/CAS/ProxiedService/Http.php
  27. +343 −0 auth/cas/CAS/CAS/ProxiedService/Http/Abstract.php
  28. +84 −0 auth/cas/CAS/CAS/ProxiedService/Http/Get.php
  29. +144 −0 auth/cas/CAS/CAS/ProxiedService/Http/Post.php
  30. +260 −0 auth/cas/CAS/CAS/ProxiedService/Imap.php
  31. +73 −0 auth/cas/CAS/CAS/ProxiedService/Testable.php
  32. +118 −0 auth/cas/CAS/CAS/ProxyChain.php
  33. +119 −0 auth/cas/CAS/CAS/ProxyChain/AllowedList.php
  34. +64 −0 auth/cas/CAS/CAS/ProxyChain/Any.php
  35. +53 −0 auth/cas/CAS/CAS/ProxyChain/Interface.php
  36. +59 −0 auth/cas/CAS/CAS/ProxyChain/Trusted.php
  37. +68 −0 auth/cas/CAS/CAS/ProxyTicketException.php
  38. +343 −0 auth/cas/CAS/CAS/Request/AbstractRequest.php
  39. +136 −0 auth/cas/CAS/CAS/Request/CurlMultiRequest.php
  40. +197 −0 auth/cas/CAS/CAS/Request/CurlRequest.php
  41. +45 −0 auth/cas/CAS/CAS/Request/Exception.php
  42. +83 −0 auth/cas/CAS/CAS/Request/MultiRequestInterface.php
  43. +179 −0 auth/cas/CAS/CAS/Request/RequestInterface.php
  44. +0 −2,776 auth/cas/CAS/CAS/client.php
  45. +0 −499 auth/cas/CAS/CAS/domxml-php4-to-php5.php
  46. +0 −27 auth/cas/CAS/CAS/languages/catalan.php
  47. +0 −27 auth/cas/CAS/CAS/languages/english.php
  48. +0 −28 auth/cas/CAS/CAS/languages/french.php
  49. +0 −27 auth/cas/CAS/CAS/languages/german.php
  50. +0 −27 auth/cas/CAS/CAS/languages/greek.php
  51. +0 −27 auth/cas/CAS/CAS/languages/japanese.php
  52. +0 −24 auth/cas/CAS/CAS/languages/languages.php
  53. +0 −27 auth/cas/CAS/CAS/languages/spanish.php
  54. +5 −0 auth/cas/CAS/moodle_readme.txt
  55. +8 −5 auth/cas/auth.php
  56. +9 −0 auth/cas/db/upgrade.php
  57. +6 −5 auth/cas/languages.php
  58. +1 −1 auth/cas/thirdpartylibs.xml
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,107 @@
+<?php
+
+/**
+ * Licensed to Jasig under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * Jasig licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * PHP Version 5
+ *
+ * @file CAS/AuthenticationException.php
+ * @category Authentication
+ * @package PhpCAS
+ * @author Joachim Fritschi <jfritschi@freenet.de>
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
+ * @link https://wiki.jasig.org/display/CASC/phpCAS
+ */
+
+/**
+ * This interface defines methods that allow proxy-authenticated service handlers
+ * to interact with phpCAS.
+ *
+ * Proxy service handlers must implement this interface as well as call
+ * phpCAS::initializeProxiedService($this) at some point in their implementation.
+ *
+ * While not required, proxy-authenticated service handlers are encouraged to
+ * implement the CAS_ProxiedService_Testable interface to facilitate unit testing.
+ *
+ * @class CAS_AuthenticationException
+ * @category Authentication
+ * @package PhpCAS
+ * @author Joachim Fritschi <jfritschi@freenet.de>
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
+ * @link https://wiki.jasig.org/display/CASC/phpCAS
+ */
+
+class CAS_AuthenticationException
+extends RuntimeException
+implements CAS_Exception
+{
+
+ /**
+ * This method is used to print the HTML output when the user was not
+ * authenticated.
+ *
+ * @param CAS_Client $client phpcas client
+ * @param string $failure the failure that occured
+ * @param string $cas_url the URL the CAS server was asked for
+ * @param bool $no_response the response from the CAS server (other
+ * parameters are ignored if TRUE)
+ * @param bool $bad_response bad response from the CAS server ($err_code
+ * and $err_msg ignored if TRUE)
+ * @param string $cas_response the response of the CAS server
+ * @param int $err_code the error code given by the CAS server
+ * @param string $err_msg the error message given by the CAS server
+ */
+ public function __construct($client,$failure,$cas_url,$no_response,
+ $bad_response='',$cas_response='',$err_code='',$err_msg=''
+ ) {
+ phpCAS::traceBegin();
+ $lang = $client->getLangObj();
+ $client->printHTMLHeader($lang->getAuthenticationFailed());
+ printf(
+ $lang->getYouWereNotAuthenticated(),
+ htmlentities($client->getURL()),
+ $_SERVER['SERVER_ADMIN']
+ );
+ phpCAS::trace('CAS URL: '.$cas_url);
+ phpCAS::trace('Authentication failure: '.$failure);
+ if ( $no_response ) {
+ phpCAS::trace('Reason: no response from the CAS server');
+ } else {
+ if ( $bad_response ) {
+ phpCAS::trace('Reason: bad response from the CAS server');
+ } else {
+ switch ($client->getServerVersion()) {
+ case CAS_VERSION_1_0:
+ phpCAS::trace('Reason: CAS error');
+ break;
+ case CAS_VERSION_2_0:
+ if ( empty($err_code) ) {
+ phpCAS::trace('Reason: no CAS error');
+ } else {
+ phpCAS::trace('Reason: ['.$err_code.'] CAS error: '.$err_msg);
+ }
+ break;
+ }
+ }
+ phpCAS::trace('CAS response: '.$cas_response);
+ }
+ $client->printHTMLFooter();
+ phpCAS::traceExit();
+ }
+
+}
+?>
@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * Autoloader Class
+ *
+ * PHP Version 5
+ *
+ * @file CAS/Autoload.php
+ * @category Authentication
+ * @package SimpleCAS
+ * @author Brett Bieber <brett.bieber@gmail.com>
+ * @copyright 2008 Regents of the University of Nebraska
+ * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License
+ * @link http://code.google.com/p/simplecas/
+ **/
+
+/**
+ * Autoload a class
+ *
+ * @param string $class Classname to load
+ *
+ * @return bool
+ */
+function CAS_autoload($class)
+{
+ // Static to hold the Include Path to CAS
+ static $include_path;
+ // Setup the include path if it's not already set from a previous call
+ if (!$include_path) {
+ $include_path = dirname(dirname(__FILE__));
+ }
+ if (substr($class, 0, 4) !== 'CAS_') {
+ return false;
+ }
+ // Declare local variable to store the expected full path to the file
+ $file_path = $include_path . '/' . str_replace('_', '/', $class) . '.php';
+
+ $fp = @fopen($file_path, 'r', true);
+ if ($fp) {
+ fclose($fp);
+ include $file_path;
+ if (!class_exists($class, false) && !interface_exists($class, false)) {
+ die(
+ new Exception(
+ 'Class ' . $class . ' was not present in ' .
+ $file_path .
+ ' [CAS_autoload]'
+ )
+ );
+ }
+ return true;
+ }
+ $e = new Exception(
+ 'Class ' . $class . ' could not be loaded from ' .
+ $file_path . ', file does not exist (Path="'
+ . $include_path .'") [CAS_autoload]'
+ );
+ $trace = $e->getTrace();
+ if (isset($trace[2]) && isset($trace[2]['function'])
+ && in_array($trace[2]['function'], array('class_exists', 'interface_exists'))
+ ) {
+ return false;
+ }
+ if (isset($trace[1]) && isset($trace[1]['function'])
+ && in_array($trace[1]['function'], array('class_exists', 'interface_exists'))
+ ) {
+ return false;
+ }
+ die ((string) $e);
+}
+
+// set up __autoload
+if (function_exists('spl_autoload_register')) {
+ if (!(spl_autoload_functions()) || !in_array('CAS_autoload', spl_autoload_functions())) {
+ spl_autoload_register('CAS_autoload');
+ if (function_exists('__autoload') && !in_array('__autoload', spl_autoload_functions())) {
+ // __autoload() was being used, but now would be ignored, add
+ // it to the autoload stack
+ spl_autoload_register('__autoload');
+ }
+ }
+} elseif (!function_exists('__autoload')) {
+
+ /**
+ * Autoload a class
+ *
+ * @param string $class Class name
+ *
+ * @return bool
+ */
+ function __autoload($class)
+ {
+ return CAS_autoload($class);
+ }
+}
+
+?>
Oops, something went wrong.

0 comments on commit 02a9e4a

Please sign in to comment.