Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAJ des scripts phpCAS en version 1.3.5 #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
706 changes: 372 additions & 334 deletions lib/CAS.php

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions lib/CAS/AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,43 @@ class CAS_AuthenticationException
public function __construct($client,$failure,$cas_url,$no_response,
$bad_response='',$cas_response='',$err_code='',$err_msg=''
) {
$messages = array();
phpCAS::traceBegin();
$lang = $client->getLangObj();
$client->printHTMLHeader($lang->getAuthenticationFailed());
printf(
$lang->getYouWereNotAuthenticated(),
htmlentities($client->getURL()),
$_SERVER['SERVER_ADMIN']
isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN']:''
);
phpCAS::trace('CAS URL: '.$cas_url);
phpCAS::trace('Authentication failure: '.$failure);
phpCAS::trace($messages[] = 'CAS URL: '.$cas_url);
phpCAS::trace($messages[] = 'Authentication failure: '.$failure);
if ( $no_response ) {
phpCAS::trace('Reason: no response from the CAS server');
phpCAS::trace($messages[] = 'Reason: no response from the CAS server');
} else {
if ( $bad_response ) {
phpCAS::trace('Reason: bad response from the CAS server');
phpCAS::trace($messages[] = 'Reason: bad response from the CAS server');
} else {
switch ($client->getServerVersion()) {
case CAS_VERSION_1_0:
phpCAS::trace('Reason: CAS error');
phpCAS::trace($messages[] = 'Reason: CAS error');
break;
case CAS_VERSION_2_0:
case CAS_VERSION_3_0:
if ( empty($err_code) ) {
phpCAS::trace('Reason: no CAS error');
phpCAS::trace($messages[] = 'Reason: no CAS error');
} else {
phpCAS::trace('Reason: ['.$err_code.'] CAS error: '.$err_msg);
phpCAS::trace($messages[] = 'Reason: ['.$err_code.'] CAS error: '.$err_msg);
}
break;
}
}
phpCAS::trace('CAS response: '.$cas_response);
phpCAS::trace($messages[] = 'CAS response: '.$cas_response);
}
$client->printHTMLFooter();
phpCAS::traceExit();

parent::__construct(implode("\n", $messages));
}

}
Expand Down
50 changes: 29 additions & 21 deletions lib/CAS/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,39 @@ 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__));
}
// Check only for CAS classes
if (substr($class, 0, 4) !== 'CAS_') {
return false;
}
// Setup the include path if it's not already set from a previous call
if (empty($include_path)) {
$include_path = array(dirname(dirname(__FILE__)), dirname(dirname(__FILE__)) . '/../test/' );
}

// 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]'
)
);
foreach ($include_path as $path) {
$file_path = $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;
}
return true;
}
$e = new Exception(
'Class ' . $class . ' could not be loaded from ' .
$file_path . ', file does not exist (Path="'
. $include_path .'") [CAS_autoload]'
. implode(':', $include_path) .'") [CAS_autoload]'
);
$trace = $e->getTrace();
if (isset($trace[2]) && isset($trace[2]['function'])
Expand All @@ -71,9 +75,13 @@ function CAS_autoload($class)

// set up __autoload
if (function_exists('spl_autoload_register')) {
if (!(spl_autoload_functions()) || !in_array('CAS_autoload', spl_autoload_functions())) {
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())) {
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');
Expand Down
Loading