getVersion() public static method

This method returns the phpCAS version.
public static getVersion ( ) : the
return the phpCAS version.
 public function __construct(array $options = array())
 {
     $this->options = $options;
     \phpCAS::getVersion();
     \phpCAS::setDebug('/tmp/cas-log.log');
     \phpCAS::setVerbose(true);
     $this->client = new \CAS_Client(SAML_VERSION_1_1, false, $this->options['webnet.sso_auth.client.option.cas_host.value'], $this->options['webnet.sso_auth.client.option.cas_port.value'], $this->options['webnet.sso_auth.client.option.cas_context.value']);
     $this->client->setNoCasServerValidation();
     $this->client->handleLogoutRequests(false, false);
 }
示例#2
0
 /**
  * CASClient constructor.
  *
  * @param $server_version the version of the CAS server
  * @param $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise
  * @param $server_hostname the hostname of the CAS server
  * @param $server_port the port the CAS server is running on
  * @param $server_uri the URI the CAS server is responding on
  * @param $start_session Have phpCAS start PHP sessions (default true)
  *
  * @return a newly created CASClient object
  *
  * @public
  */
 function CASClient($server_version, $proxy, $server_hostname, $server_port, $server_uri, $start_session = true)
 {
     phpCAS::traceBegin();
     // activate session mechanism if desired
     if ($start_session) {
         session_start();
     }
     $this->_proxy = $proxy;
     // check version
     switch ($server_version) {
         case CAS_VERSION_1_0:
             if ($this->isProxy()) {
                 phpCAS::error('CAS proxies are not supported in CAS ' . $server_version);
             }
             break;
         case CAS_VERSION_2_0:
             break;
         default:
             phpCAS::error('this version of CAS (`' . $server_version . '\') is not supported by phpCAS ' . phpCAS::getVersion());
     }
     $this->_server['version'] = $server_version;
     // check hostname
     if (empty($server_hostname) || !preg_match('/[\\.\\d\\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)) {
         phpCAS::error('bad CAS server hostname (`' . $server_hostname . '\')');
     }
     $this->_server['hostname'] = $server_hostname;
     // check port
     if ($server_port == 0 || !is_int($server_port)) {
         phpCAS::error('bad CAS server port (`' . $server_hostname . '\')');
     }
     $this->_server['port'] = $server_port;
     // check URI
     if (!preg_match('/[\\.\\d\\-_abcdefghijklmnopqrstuvwxyz\\/]*/', $server_uri)) {
         phpCAS::error('bad CAS server URI (`' . $server_uri . '\')');
     }
     // add leading and trailing `/' and remove doubles
     $server_uri = preg_replace('/\\/\\//', '/', '/' . $server_uri . '/');
     $this->_server['uri'] = $server_uri;
     // set to callback mode if PgtIou and PgtId CGI GET parameters are provided
     if ($this->isProxy()) {
         $this->setCallbackMode(!empty($_GET['pgtIou']) && !empty($_GET['pgtId']));
     }
     if ($this->isCallbackMode()) {
         // callback mode: check that phpCAS is secured
         if ($_SERVER['HTTPS'] != 'on') {
             phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
         }
     } else {
         // normal mode: get ticket and remove it from CGI parameters for developpers
         $ticket = $_GET['ticket'];
         // at first check for a Service Ticket
         if (preg_match('/^ST-/', $ticket)) {
             phpCAS::trace('ST \'' . $ticket . '\' found');
             // ST present
             $this->setST($ticket);
         } else {
             if ($this->getServerVersion() != CAS_VERSION_1_0 && preg_match('/^PT-/', $ticket)) {
                 phpCAS::trace('PT \'' . $ticket . '\' found');
                 $this->setPT($ticket);
             } else {
                 if (!empty($ticket)) {
                     phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                 }
             }
         }
         // ticket has been taken into account, unset it to hide it to applications
         unset($_GET['ticket']);
     }
     phpCAS::traceEnd();
 }
示例#3
0
//phpCAS::setCasServerCACert("path");
// Per aquesta prova simplement indiquem que no validi l'autenticitat del servidor de CAS
phpCAS::setNoCasServerValidation();
// Forcem l'autenticacio...
phpCAS::forceAuthentication();
// En aquest punt l'usuari ja ha seigut autenticat pel servidor de CAS
// podem llegir el seu usuari amb phpCAS::getUser().
// Si s'ha clicat logout, fem logout amb phpCAS::logout();
if (isset($_REQUEST['logout'])) {
    phpCAS::logout();
}
?>
<!--Indiquem a l'susuari que s'ha loguejat correctament i mostrem la versió del CAS-->
<html>
  <head>
    <title>Exemple login CAS</title>
  </head>
  <body>
    <h1>Has entrat correctament!</h1>
    <p>El teu nom d'usuari es <b><?php 
echo phpCAS::getUser();
?>
</b>.</p>
    <p>La veris&oacute de phpCAS es <b><?php 
echo phpCAS::getVersion();
?>
</b>.</p>
    <p><a href="?logout=">Logout</a></p>
  </body>
</html>
示例#4
0
文件: Client.php 项目: Trideon/gigolo
 /**
  * CAS_Client constructor.
  *
  * @param string $server_version  the version of the CAS server
  * @param bool   $proxy           true if the CAS client is a CAS proxy
  * @param string $server_hostname the hostname of the CAS server
  * @param int    $server_port     the port the CAS server is running on
  * @param string $server_uri      the URI the CAS server is responding on
  * @param bool   $changeSessionID Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
  *
  * @return a newly created CAS_Client object
  */
 public function __construct($server_version, $proxy, $server_hostname, $server_port, $server_uri, $changeSessionID = true)
 {
     phpCAS::traceBegin();
     $this->_setChangeSessionID($changeSessionID);
     // true : allow to change the session_id(), false session_id won't be change and logout won't be handle because of that
     // skip Session Handling for logout requests and if don't want it'
     if (session_id() == "" && !$this->_isLogoutRequest()) {
         phpCAS::trace("Starting a new session");
         session_start();
     }
     // are we in proxy mode ?
     $this->_proxy = $proxy;
     // Make cookie handling available.
     if ($this->isProxy()) {
         if (!isset($_SESSION['phpCAS'])) {
             $_SESSION['phpCAS'] = array();
         }
         if (!isset($_SESSION['phpCAS']['service_cookies'])) {
             $_SESSION['phpCAS']['service_cookies'] = array();
         }
         $this->_serviceCookieJar = new CAS_CookieJar($_SESSION['phpCAS']['service_cookies']);
     }
     //check version
     switch ($server_version) {
         case CAS_VERSION_1_0:
             if ($this->isProxy()) {
                 phpCAS::error('CAS proxies are not supported in CAS ' . $server_version);
             }
             break;
         case CAS_VERSION_2_0:
             break;
         case SAML_VERSION_1_1:
             break;
         default:
             phpCAS::error('this version of CAS (`' . $server_version . '\') is not supported by phpCAS ' . phpCAS::getVersion());
     }
     $this->_server['version'] = $server_version;
     // check hostname
     if (empty($server_hostname) || !preg_match('/[\\.\\d\\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)) {
         phpCAS::error('bad CAS server hostname (`' . $server_hostname . '\')');
     }
     $this->_server['hostname'] = $server_hostname;
     // check port
     if ($server_port == 0 || !is_int($server_port)) {
         phpCAS::error('bad CAS server port (`' . $server_hostname . '\')');
     }
     $this->_server['port'] = $server_port;
     // check URI
     if (!preg_match('/[\\.\\d\\-_abcdefghijklmnopqrstuvwxyz\\/]*/', $server_uri)) {
         phpCAS::error('bad CAS server URI (`' . $server_uri . '\')');
     }
     // add leading and trailing `/' and remove doubles
     $server_uri = preg_replace('/\\/\\//', '/', '/' . $server_uri . '/');
     $this->_server['uri'] = $server_uri;
     // set to callback mode if PgtIou and PgtId CGI GET parameters are provided
     if ($this->isProxy()) {
         $this->_setCallbackMode(!empty($_GET['pgtIou']) && !empty($_GET['pgtId']));
     }
     if ($this->_isCallbackMode()) {
         //callback mode: check that phpCAS is secured
         if (!$this->_isHttps()) {
             phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
         }
     } else {
         //normal mode: get ticket and remove it from CGI parameters for
         // developers
         $ticket = isset($_GET['ticket']) ? $_GET['ticket'] : null;
         if (preg_match('/^[SP]T-/', $ticket)) {
             phpCAS::trace('Ticket \'' . $ticket . '\' found');
             $this->setTicket($ticket);
             unset($_GET['ticket']);
         } else {
             if (!empty($ticket)) {
                 //ill-formed ticket, halt
                 phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
             }
         }
     }
     phpCAS::traceEnd();
 }
 /**
  * show Libraries information in system information
  *
  * @since version 0.84
  **/
 static function showLibrariesInformation()
 {
     // No gettext
     echo "<tr class='tab_bg_2'><th>Libraries</th></tr>\n";
     echo "<tr class='tab_bg_1'><td><pre>\n&nbsp;\n";
     include_once GLPI_HTMLAWED;
     echo "htmLawed version " . hl_version() . " in (" . realpath(dirname(GLPI_HTMLAWED)) . ")\n";
     include GLPI_PHPCAS;
     echo "phpCas version " . phpCAS::getVersion() . " in (" . (dirname(GLPI_PHPCAS) ? realpath(dirname(GLPI_PHPCAS)) : "system") . ")\n";
     require_once GLPI_PHPMAILER_DIR . "/class.phpmailer.php";
     $pm = new PHPMailer();
     echo "PHPMailer version " . $pm->Version . " in (" . realpath(GLPI_PHPMAILER_DIR) . ")\n";
     // EZ component
     echo "ZetaComponent ezcGraph installed in (" . dirname(dirname(GLPI_EZC_BASE)) . "):  " . (class_exists('ezcGraph') ? 'OK' : 'KO') . "\n";
     // Zend
     $zv = new Zend\Version\Version();
     echo "Zend Framework version " . $zv::VERSION . " in (" . realpath(GLPI_ZEND_PATH) . ")\n";
     // SimplePie :
     $sp = new SimplePie();
     echo "SimplePie version " . SIMPLEPIE_VERSION . " in (" . realpath(GLPI_SIMPLEPIE_PATH) . ")\n";
     // TCPDF
     include_once GLPI_TCPDF_DIR . '/include/tcpdf_static.php';
     echo "TCPDF version " . TCPDF_STATIC::getTCPDFVersion() . " in (" . realpath(GLPI_TCPDF_DIR) . ")\n";
     // password_compat
     require_once GLPI_PASSWORD_COMPAT;
     $check = PasswordCompat\binary\check() ? "Ok" : "KO";
     echo "ircmaxell/password-compat in (" . realpath(dirname(GLPI_PASSWORD_COMPAT)) . "). Compatitility: {$check}\n";
     echo "\n</pre></td></tr>";
 }
示例#6
0
 /**
  * show Libraries information in system information
  *
  * @since version 0.84
  **/
 static function showLibrariesInformation()
 {
     // No gettext
     echo "<tr class='tab_bg_2'><th>Libraries</th></tr>\n";
     echo "<tr class='tab_bg_1'><td><pre>\n&nbsp;\n";
     include_once GLPI_HTMLAWED;
     $pm = new PHPMailer();
     $sp = new SimplePie();
     $deps = [['name' => 'htmLawed', 'version' => hl_version(), 'check' => 'hl_version'], ['name' => 'phpCas', 'version' => phpCAS::getVersion(), 'check' => 'phpCAS'], ['name' => 'PHPMailer', 'version' => $pm->Version, 'check' => 'PHPMailer'], ['name' => 'Zend Framework', 'check' => 'Zend\\Loader\\StandardAutoloader'], ['name' => 'zetacomponents/graph', 'check' => 'ezcGraph'], ['name' => 'SimplePie', 'version' => SIMPLEPIE_VERSION, 'check' => $sp], ['name' => 'TCPDF', 'version' => TCPDF_STATIC::getTCPDFVersion(), 'check' => 'TCPDF'], ['name' => 'ircmaxell/password-compat', 'check' => 'password_hash'], ['name' => 'ramsey/array_column', 'check' => 'array_column'], ['name' => 'michelf/php-markdown', 'check' => 'Michelf\\Markdown'], ['name' => 'true/punycode', 'check' => 'TrueBV\\Punycode'], ['name' => 'iacaml/autolink', 'check' => 'autolink'], ['name' => 'sabre/vobject', 'check' => 'Sabre\\VObject\\Component']];
     foreach ($deps as $dep) {
         $path = self::getLibraryDir($dep['check']);
         if ($path) {
             echo "{$dep['name']} ";
             if (isset($dep['version'])) {
                 echo "version {$dep['version']} ";
             }
             echo "in ({$path})\n";
         }
     }
     echo "\n</pre></td></tr>";
 }
示例#7
0
文件: client.php 项目: skdong/nfs-ovd
 /**
  * CASClient constructor.
  *
  * @param $server_version the version of the CAS server
  * @param $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise
  * @param $server_hostname the hostname of the CAS server
  * @param $server_port the port the CAS server is running on
  * @param $server_uri the URI the CAS server is responding on
  * @param $start_session Have phpCAS start PHP sessions (default true)
  *
  * @return a newly created CASClient object
  *
  * @public
  */
 function CASClient($server_version, $proxy, $server_hostname, $server_port, $server_uri, $start_session = true)
 {
     phpCAS::traceBegin();
     if (!$this->isLogoutRequest() && !empty($_GET['ticket']) && $start_session) {
         // copy old session vars and destroy the current session
         if (!isset($_SESSION)) {
             session_start();
         }
         $old_session = $_SESSION;
         session_destroy();
         // set up a new session, of name based on the ticket
         $session_id = preg_replace('/[^\\w]/', '', $_GET['ticket']);
         phpCAS::LOG("Session ID: " . $session_id);
         session_id($session_id);
         if (!isset($_SESSION)) {
             session_start();
         }
         // restore old session vars
         $_SESSION = $old_session;
         // Redirect to location without ticket.
         header('Location: ' . $this->getURL());
     }
     //activate session mechanism if desired
     if (!$this->isLogoutRequest() && $start_session && !isset($_SESSION)) {
         session_start();
     }
     $this->_proxy = $proxy;
     //check version
     switch ($server_version) {
         case CAS_VERSION_1_0:
             if ($this->isProxy()) {
                 phpCAS::error('CAS proxies are not supported in CAS ' . $server_version);
             }
             break;
         case CAS_VERSION_2_0:
             break;
         default:
             phpCAS::error('this version of CAS (`' . $server_version . '\') is not supported by phpCAS ' . phpCAS::getVersion());
     }
     $this->_server['version'] = $server_version;
     //check hostname
     if (empty($server_hostname) || !preg_match('/[\\.\\d\\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)) {
         phpCAS::error('bad CAS server hostname (`' . $server_hostname . '\')');
     }
     $this->_server['hostname'] = $server_hostname;
     //check port
     if ($server_port == 0 || !is_int($server_port)) {
         phpCAS::error('bad CAS server port (`' . $server_hostname . '\')');
     }
     $this->_server['port'] = $server_port;
     //check URI
     if (!preg_match('/[\\.\\d\\-_abcdefghijklmnopqrstuvwxyz\\/]*/', $server_uri)) {
         phpCAS::error('bad CAS server URI (`' . $server_uri . '\')');
     }
     //add leading and trailing `/' and remove doubles
     $server_uri = preg_replace('/\\/\\//', '/', '/' . $server_uri . '/');
     $this->_server['uri'] = $server_uri;
     //set to callback mode if PgtIou and PgtId CGI GET parameters are provided
     if ($this->isProxy()) {
         $this->setCallbackMode(!empty($_GET['pgtIou']) && !empty($_GET['pgtId']));
     }
     if ($this->isCallbackMode()) {
         //callback mode: check that phpCAS is secured
         if (!$this->isHttps()) {
             phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
         }
     } else {
         //normal mode: get ticket and remove it from CGI parameters for developpers
         $ticket = isset($_GET['ticket']) ? $_GET['ticket'] : null;
         switch ($this->getServerVersion()) {
             case CAS_VERSION_1_0:
                 // check for a Service Ticket
                 if (preg_match('/^ST-/', $ticket)) {
                     phpCAS::trace('ST \'' . $ticket . '\' found');
                     //ST present
                     $this->setST($ticket);
                     //ticket has been taken into account, unset it to hide it to applications
                     unset($_GET['ticket']);
                 } else {
                     if (!empty($ticket)) {
                         //ill-formed ticket, halt
                         phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                     }
                 }
                 break;
             case CAS_VERSION_2_0:
                 // check for a Service or Proxy Ticket
                 if (preg_match('/^[SP]T-/', $ticket)) {
                     phpCAS::trace('ST or PT \'' . $ticket . '\' found');
                     $this->setPT($ticket);
                     unset($_GET['ticket']);
                 } else {
                     if (!empty($ticket)) {
                         //ill-formed ticket, halt
                         phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                     }
                 }
                 break;
         }
     }
     phpCAS::traceEnd();
 }
function RWSPLOCas($r_csp)
{
    global $RWSESL3;
    if (isset($_SESSION['rwscas']['cookiejar'])) {
        $r_ckf = $_SESSION['rwscas']['cookiejar'];
    }
    if (empty($r_csp->config->hostname) || !$r_csp->config->logoutcas) {
        if (isset($r_ckf)) {
            if (file_exists($r_ckf)) {
                unlink($r_ckf);
            }
            unset($_SESSION['rwscas']['cookiejar']);
        }
        unset($_SESSION['rwscas']);
        return;
    }
    list($r_v1, $r_v2, $r_v3) = explode(".", phpCAS::getVersion());
    $r_csp->connectCAS();
    $r_lou = phpCAS::getServerLogoutURL();
    $r_ch = curl_init();
    curl_setopt($r_ch, CURLOPT_URL, $r_lou);
    curl_setopt($r_ch, CURLOPT_HTTPGET, true);
    curl_setopt($r_ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($r_ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($r_ch, CURLOPT_FAILONERROR, true);
    curl_setopt($r_ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($r_ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($r_ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($r_ch, CURLOPT_USERAGENT, "PHP");
    if (isset($r_ckf)) {
        curl_setopt($r_ch, CURLOPT_COOKIEFILE, $r_ckf);
        curl_setopt($r_ch, CURLOPT_COOKIEJAR, $r_ckf);
    }
    curl_exec($r_ch);
    curl_close($r_ch);
    if (isset($r_ckf)) {
        if (file_exists($r_ckf)) {
            unlink($r_ckf);
        }
        unset($_SESSION['rwscas']['cookiejar']);
    }
    unset($_SESSION['rwscas']);
    session_unset();
    session_destroy();
}
示例#9
0
 /**
  * CASClient constructor.
  *
  * @param $server_version the version of the CAS server
  * @param $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise
  * @param $server_hostname the hostname of the CAS server
  * @param $server_port the port the CAS server is running on
  * @param $server_uri the URI the CAS server is responding on
  * @param $start_session Have phpCAS start PHP sessions (default true)
  *
  * @return a newly created CASClient object
  *
  * @public
  */
 function CASClient($server_version, $proxy, $server_hostname, $server_port, $server_uri, $start_session = true)
 {
     phpCAS::traceBegin();
     // the redirect header() call and DOM parsing code from domxml-php4-php5.php won't work in PHP4 compatibility mode
     if (version_compare(PHP_VERSION, '5', '>=') && ini_get('zend.ze1_compatibility_mode')) {
         phpCAS::error('phpCAS cannot support zend.ze1_compatibility_mode. Sorry.');
     }
     // skip Session Handling for logout requests and if don't want it'
     if ($start_session && !$this->isLogoutRequest()) {
         phpCAS::trace("Starting session handling");
         // Check for Tickets from the CAS server
         if (empty($_GET['ticket'])) {
             phpCAS::trace("No ticket found");
             // only create a session if necessary
             if (session_id() !== '') {
                 phpCAS::trace("No session found, creating new session");
                 session_start();
             }
         } else {
             phpCAS::trace("Ticket found");
             // We have to copy any old data before renaming the session
             if (session_id() !== '') {
                 phpCAS::trace("Old active session found, saving old data and destroying session");
                 $old_session = $_SESSION;
                 session_destroy();
             } else {
                 session_start();
                 phpCAS::trace("Starting possible old session to copy variables");
                 $old_session = $_SESSION;
                 session_destroy();
             }
             // set up a new session, of name based on the ticket
             $session_id = preg_replace('/[^\\w]/', '', $_GET['ticket']);
             phpCAS::LOG("Session ID: " . $session_id);
             session_id($session_id);
             session_start();
             // restore old session vars
             if (isset($old_session)) {
                 phpCAS::trace("Restoring old session vars");
                 $_SESSION = $old_session;
             }
         }
     } else {
         phpCAS::trace("Skipping session creation");
     }
     // are we in proxy mode ?
     $this->_proxy = $proxy;
     //check version
     switch ($server_version) {
         case CAS_VERSION_1_0:
             if ($this->isProxy()) {
                 phpCAS::error('CAS proxies are not supported in CAS ' . $server_version);
             }
             break;
         case CAS_VERSION_2_0:
             break;
         case SAML_VERSION_1_1:
             break;
         default:
             phpCAS::error('this version of CAS (`' . $server_version . '\') is not supported by phpCAS ' . phpCAS::getVersion());
     }
     $this->_server['version'] = $server_version;
     // check hostname
     if (empty($server_hostname) || !preg_match('/[\\.\\d\\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)) {
         phpCAS::error('bad CAS server hostname (`' . $server_hostname . '\')');
     }
     $this->_server['hostname'] = $server_hostname;
     // check port
     if ($server_port == 0 || !is_int($server_port)) {
         phpCAS::error('bad CAS server port (`' . $server_hostname . '\')');
     }
     $this->_server['port'] = $server_port;
     // check URI
     if (!preg_match('/[\\.\\d\\-_abcdefghijklmnopqrstuvwxyz\\/]*/', $server_uri)) {
         phpCAS::error('bad CAS server URI (`' . $server_uri . '\')');
     }
     // add leading and trailing `/' and remove doubles
     $server_uri = preg_replace('/\\/\\//', '/', '/' . $server_uri . '/');
     $this->_server['uri'] = $server_uri;
     // set to callback mode if PgtIou and PgtId CGI GET parameters are provided
     if ($this->isProxy()) {
         $this->setCallbackMode(!empty($_GET['pgtIou']) && !empty($_GET['pgtId']));
     }
     if ($this->isCallbackMode()) {
         //callback mode: check that phpCAS is secured
         if (!$this->isHttps()) {
             phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
         }
     } else {
         //normal mode: get ticket and remove it from CGI parameters for developpers
         $ticket = isset($_GET['ticket']) ? $_GET['ticket'] : null;
         switch ($this->getServerVersion()) {
             case CAS_VERSION_1_0:
                 // check for a Service Ticket
                 if (preg_match('/^ST-/', $ticket)) {
                     phpCAS::trace('ST \'' . $ticket . '\' found');
                     //ST present
                     $this->setST($ticket);
                     //ticket has been taken into account, unset it to hide it to applications
                     unset($_GET['ticket']);
                 } else {
                     if (!empty($ticket)) {
                         //ill-formed ticket, halt
                         phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                     }
                 }
                 break;
             case CAS_VERSION_2_0:
                 // check for a Service or Proxy Ticket
                 if (preg_match('/^[SP]T-/', $ticket)) {
                     phpCAS::trace('ST or PT \'' . $ticket . '\' found');
                     $this->setPT($ticket);
                     unset($_GET['ticket']);
                 } else {
                     if (!empty($ticket)) {
                         //ill-formed ticket, halt
                         phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                     }
                 }
                 break;
             case SAML_VERSION_1_1:
                 // SAML just does Service Tickets
                 if (preg_match('/^[SP]T-/', $ticket)) {
                     phpCAS::trace('SA \'' . $ticket . '\' found');
                     $this->setSA($ticket);
                     unset($_GET['ticket']);
                 } else {
                     if (!empty($ticket)) {
                         //ill-formed ticket, halt
                         phpCAS::error('ill-formed ticket found in the URL (ticket=`' . htmlentities($ticket) . '\')');
                     }
                 }
                 break;
         }
     }
     phpCAS::traceEnd();
 }
示例#10
0
 public function unserialize($str)
 {
     \phpCAS::getVersion();
     list($this->credentials, $this->manager, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
示例#11
0
文件: client.php 项目: rhertzog/lcs
	/**
	* CASClient constructor.
	*
	* @param $server_version the version of the CAS server
	* @param $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise
	* @param $server_hostname the hostname of the CAS server
	* @param $server_port the port the CAS server is running on
	* @param $server_uri the URI the CAS server is responding on
	* @param $start_session Have phpCAS start PHP sessions (default true)
	*
	* @return a newly created CASClient object
	*/
	public function CASClient(
	$server_version,
	$proxy,
	$server_hostname,
	$server_port,
	$server_uri,
	$start_session = true) {

		phpCAS::traceBegin();

		$this->_start_session = $start_session;

		if ($this->_start_session && session_id() !== "")
		{
			phpCAS :: error("Another session was started before phpcas. Either disable the session" .
				" handling for phpcas in the client() call or modify your application to leave" .
				" session handling to phpcas");			
		}
		// skip Session Handling for logout requests and if don't want it'
		if ($start_session && !$this->isLogoutRequest())
		{
			phpCAS :: trace("Starting a new session");
			session_start();
		}


		// are we in proxy mode ?
		$this->_proxy = $proxy;

		// Make cookie handling available.
		if ($this->isProxy()) {
			if (!isset($_SESSION['phpCAS']))
			$_SESSION['phpCAS'] = array();
			if (!isset($_SESSION['phpCAS']['service_cookies']))
			$_SESSION['phpCAS']['service_cookies'] = array();
			$this->_serviceCookieJar = new CAS_CookieJar($_SESSION['phpCAS']['service_cookies']);
		}

		//check version
		switch ($server_version) {
			case CAS_VERSION_1_0:
				if ( $this->isProxy() )
				phpCAS::error('CAS proxies are not supported in CAS '
				.$server_version);
				break;
			case CAS_VERSION_2_0:
				break;
			case SAML_VERSION_1_1:
				break;
			default:
				phpCAS::error('this version of CAS (`'
				.$server_version
				.'\') is not supported by phpCAS '
				.phpCAS::getVersion());
		}
		$this->_server['version'] = $server_version;

		// check hostname
		if ( empty($server_hostname)
		|| !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/',$server_hostname) ) {
			phpCAS::error('bad CAS server hostname (`'.$server_hostname.'\')');
		}
		$this->_server['hostname'] = $server_hostname;

		// check port
		if ( $server_port == 0
		|| !is_int($server_port) ) {
			phpCAS::error('bad CAS server port (`'.$server_hostname.'\')');
		}
		$this->_server['port'] = $server_port;

		// check URI
		if ( !preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/',$server_uri) ) {
			phpCAS::error('bad CAS server URI (`'.$server_uri.'\')');
		}
		// add leading and trailing `/' and remove doubles
		$server_uri = preg_replace('/\/\//','/','/'.$server_uri.'/');
		$this->_server['uri'] = $server_uri;

		// set to callback mode if PgtIou and PgtId CGI GET parameters are provided
		if ( $this->isProxy() ) {
			$this->setCallbackMode(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId']));
		}

		if ( $this->isCallbackMode() ) {
			//callback mode: check that phpCAS is secured
			if ( !$this->isHttps() ) {
				phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
			}
		} else {
			//normal mode: get ticket and remove it from CGI parameters for developpers
			$ticket = (isset($_GET['ticket']) ? $_GET['ticket'] : null);
			switch ($this->getServerVersion()) {
				case CAS_VERSION_1_0: // check for a Service Ticket
					if( preg_match('/^ST-/',$ticket) ) {
						phpCAS::trace('ST \''.$ticket.'\' found');
						//ST present
						$this->setST($ticket);
						//ticket has been taken into account, unset it to hide it to applications
						unset($_GET['ticket']);
					} else if ( !empty($ticket) ) {
						//ill-formed ticket, halt
						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
					}
					break;
				case CAS_VERSION_2_0: // check for a Service or Proxy Ticket
					if( preg_match('/^[SP]T-/',$ticket) ) {
						phpCAS::trace('ST or PT \''.$ticket.'\' found');
						$this->setPT($ticket);
						unset($_GET['ticket']);
					} else if ( !empty($ticket) ) {
						//ill-formed ticket, halt
						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
					}
					break;
				case SAML_VERSION_1_1: // SAML just does Service Tickets
					if( preg_match('/^[SP]T-/',$ticket) ) {
						phpCAS::trace('SA \''.$ticket.'\' found');
						$this->setSA($ticket);
						unset($_GET['ticket']);
					} else if ( !empty($ticket) ) {
						//ill-formed ticket, halt
						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
					}
					break;
			}
		}
		phpCAS::traceEnd();
	}
示例#12
0
 /**
  * show Libraries information in system information
  *
  * @since version 0.84
  **/
 static function showLibrariesInformation()
 {
     // No gettext
     echo "<tr class='tab_bg_2'><th>Libraries</th></tr>\n";
     echo "<tr class='tab_bg_1'><td><pre>\n&nbsp;\n";
     include_once GLPI_HTMLAWED;
     echo "htmLawed version " . hl_version() . " in (" . self::getLibraryDir("hl_version") . ")\n";
     echo "phpCas version " . phpCAS::getVersion() . " in (" . (self::getLibraryDir("phpCAS") ? self::getLibraryDir("phpCAS") : "system") . ")\n";
     $pm = new PHPMailer();
     echo "PHPMailer version " . $pm->Version . " in (" . self::getLibraryDir("PHPMailer") . ")\n";
     // EZ component
     echo "ZetaComponent ezcGraph installed in (" . self::getLibraryDir("ezcGraph") . "): " . (class_exists('ezcGraph') ? 'OK' : 'KO') . "\n";
     // Zend
     echo "Zend Framework in (" . self::getLibraryDir("Zend\\Loader\\StandardAutoloader") . ")\n";
     // SimplePie :
     $sp = new SimplePie();
     echo "SimplePie version " . SIMPLEPIE_VERSION . " in (" . self::getLibraryDir($sp) . ")\n";
     // TCPDF
     echo "TCPDF version " . TCPDF_STATIC::getTCPDFVersion() . " in (" . self::getLibraryDir("TCPDF") . ")\n";
     // password_compat
     $check = PasswordCompat\binary\check() ? "Ok" : "KO";
     echo "ircmaxell/password-compat in (" . self::getLibraryDir("PasswordCompat\\binary\\check") . "). Compatitility: {$check}\n";
     // autolink
     echo "iacaml/autolink in (" . self::getLibraryDir("autolink") . ")\n";
     // sabre/vobject
     echo "sabre/vobject in (" . self::getLibraryDir("Sabre\\VObject\\Component") . ")\n";
     // vcard
     echo "guzzlehttp/guzzle in (" . self::getLibraryDir("JeroenDesloovere\\VCard\\VCard") . ")\n";
     echo "\n</pre></td></tr>";
 }
示例#13
0
 /**
  * This method filters a string by replacing special tokens by appropriate values
  * and prints it. The corresponding tokens are taken into account:
  * - __CAS_VERSION__
  * - __PHPCAS_VERSION__
  * - __SERVER_BASE_URL__
  *
  * Used by CASClient::PrintHTMLHeader() and CASClient::printHTMLFooter().
  *
  * @param $str the string to filter and output
  *
  * @private
  */
 function HTMLFilterOutput($str)
 {
     $str = str_replace('__CAS_VERSION__', $this->getServerVersion(), $str);
     $str = str_replace('__PHPCAS_VERSION__', phpCAS::getVersion(), $str);
     $str = str_replace('__SERVER_BASE_URL__', $this->getServerBaseURL(), $str);
     echo $str;
 }
示例#14
0
 /**
  * show Libraries information in system information
  *
  * @since version 0.84
  **/
 static function showLibrariesInformation()
 {
     // No gettext
     echo "<tr class='tab_bg_2'><th>Libraries</th></tr>\n";
     echo "<tr class='tab_bg_1'><td><pre>\n&nbsp;\n";
     include_once GLPI_HTMLAWED;
     echo "htmLawed version " . hl_version() . " in (" . realpath(dirname(GLPI_HTMLAWED)) . ")\n";
     include GLPI_PHPCAS;
     echo "phpCas version " . phpCAS::getVersion() . " in (" . (dirname(GLPI_PHPCAS) ? realpath(dirname(GLPI_PHPCAS)) : "system") . ")\n";
     require_once GLPI_PHPMAILER_DIR . "/class.phpmailer.php";
     $pm = new PHPMailer();
     echo "PHPMailer version " . $pm->Version . " in (" . realpath(GLPI_PHPMAILER_DIR) . ")\n";
     // EZ component
     echo "eZ Graph componnent installed :  " . (class_exists('ezcGraph') ? 'OK' : 'KO') . "\n";
     // Zend
     $zv = new Zend\Version\Version();
     echo "Zend Framework version " . $zv::VERSION . " in (" . realpath(GLPI_ZEND_PATH) . ")\n";
     // SimplePie :
     $sp = new SimplePie();
     echo "SimplePie version " . SIMPLEPIE_VERSION . " in (" . realpath(GLPI_SIMPLEPIE_PATH) . ")\n";
     echo "\n</pre></td></tr>";
 }