CAS_Client::setPGTStorage PHP Метод

setPGTStorage() публичный Метод

This method can be used to set a custom PGT storage object.
public setPGTStorage ( CAS_PGTStorage_AbstractStorage $storage ) : void
$storage CAS_PGTStorage_AbstractStorage a PGT storage object that inherits from the CAS_PGTStorage_AbstractStorage class
Результат void
    public function setPGTStorage($storage)
    {
        // Sequence validation
        $this->ensureIsProxy();
        // check that the storage has not already been set
        if (is_object($this->_pgt_storage)) {
            phpCAS::error('PGT storage already defined');
        }
        // check to make sure a valid storage object was specified
        if (!$storage instanceof CAS_PGTStorage_AbstractStorage) {
            throw new CAS_TypeMismatchException($storage, '$storage', 'CAS_PGTStorage_AbstractStorage object');
        }
        // store the PGTStorage object
        $this->_pgt_storage = $storage;
    }

Usage Example

 private function initializeCAS()
 {
     $casClient = new \CAS_Client(CAS_VERSION_2_0, true, Config::get('cas.hostname'), Config::get('cas.port'), Config::get('cas.context'));
     $casClient->setNoCasServerValidation();
     if (true === Config::get('pgtservice.enabled', false)) {
         $casClient->setCallbackURL(Config::get('pgtservice.callback'));
         $casClient->setPGTStorage(new ProxyTicketServiceStorage($casClient));
     } else {
         if (false !== Config::get('redis.hostname', false)) {
             $casClient->setCallbackURL($this->url->getURL() . '/callback.php');
             $redis = new \Redis();
             $redis->connect(Config::get('redis.hostname'), Config::get('redis.port', 6379), 2, null, 100);
             $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
             $redis->setOption(\Redis::OPT_PREFIX, Config::get('application.project_name') . ':PHPCAS_TICKET_STORAGE:');
             $redis->select((int) Config::get('redis.hostname', 2));
             $casClient->setPGTStorage(new RedisTicketStorage($casClient, $redis));
         } else {
             $casClient->setCallbackURL($this->url->getURL() . '/callback.php');
             $casClient->setPGTStorageFile(session_save_path());
             // Handle logout requests but do not validate the server
             $casClient->handleLogoutRequests(false);
         }
     }
     // Accept all proxy chains
     $casClient->getAllowedProxyChains()->allowProxyChain(new \CAS_ProxyChain_Any());
     return $casClient;
 }
All Usage Examples Of CAS_Client::setPGTStorage
CAS_Client