phpCAS::client PHP Method

client() public static method

phpCAS client initializer.
public static client ( string $server_version, string $server_hostname, string $server_port, string $server_uri, boolean $changeSessionID = true ) : a
$server_version string the version of the CAS server
$server_hostname string the hostname of the CAS server
$server_port string the port the CAS server is running on
$server_uri string the URI the CAS server is responding on
$changeSessionID boolean Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
return a newly created CAS_Client object
    public static function client($server_version, $server_hostname, $server_port, $server_uri, $changeSessionID = true)
    {
        phpCAS::traceBegin();
        if (is_object(self::$_PHPCAS_CLIENT)) {
            phpCAS::error(self::$_PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . self::$_PHPCAS_INIT_CALL['file'] . ':' . self::$_PHPCAS_INIT_CALL['line'] . ')');
        }
        // store where the initializer is called from
        $dbg = debug_backtrace();
        self::$_PHPCAS_INIT_CALL = array('done' => true, 'file' => $dbg[0]['file'], 'line' => $dbg[0]['line'], 'method' => __CLASS__ . '::' . __FUNCTION__);
        // initialize the object $_PHPCAS_CLIENT
        try {
            self::$_PHPCAS_CLIENT = new CAS_Client($server_version, false, $server_hostname, $server_port, $server_uri, $changeSessionID);
        } catch (Exception $e) {
            phpCAS::error(get_class($e) . ': ' . $e->getMessage());
        }
        phpCAS::traceEnd();
    }

Usage Example

Ejemplo n.º 1
0
 public function __construct()
 {
     // These are default values for the first login and should be changed via GUI
     $CAS_HOSTNAME = 'your.domain.org';
     $CAS_PORT = '443';
     $CAS_PATH = '/cas';
     $this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
     $this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
     $this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
     $this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
     $this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
     $this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
     $this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
     $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
     $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $CAS_HOSTNAME);
     $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', $CAS_PORT);
     $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', $CAS_PATH);
     $casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
     global $initialized_cas;
     if (!$initialized_cas) {
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if (!empty($casCertPath)) {
             phpCAS::setCasServerCACert($casCertPath);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         $initialized_cas = true;
     }
 }
All Usage Examples Of phpCAS::client