public static function initialized_php_cas()
{
if (!self::$_initialized_php_cas) {
$casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
$casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $_SERVER['SERVER_NAME']);
$casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', 443);
$casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', '/cas');
$casDebugFile = OCP\Config::getAppValue('user_cas', 'cas_debug_file', '');
$casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
$php_cas_path = OCP\Config::getAppValue('user_cas', 'cas_php_cas_path', 'CAS.php');
if (!class_exists('phpCAS')) {
if (empty($php_cas_path)) {
$php_cas_path = 'CAS.php';
}
OC_Log::write('cas', "Try to load phpCAS library ({$php_cas_path})", OC_Log::DEBUG);
include_once $php_cas_path;
if (!class_exists('phpCAS')) {
OC_Log::write('cas', 'Fail to load phpCAS library !', OC_Log::ERROR);
return false;
}
}
if ($casDebugFile !== '') {
phpCAS::setDebug($casDebugFile);
}
phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
if (!empty($casCertPath)) {
phpCAS::setCasServerCACert($casCertPath);
} else {
phpCAS::setNoCasServerValidation();
}
self::$_initialized_php_cas = true;
}
return self::$_initialized_php_cas;
}