CAS_Client::getProxiedService PHP Метод

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

Answer a proxy-authenticated service handler.
public getProxiedService ( string $type ) : CAS_ProxiedService
$type string The service type. One of: PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_PROXIED_SERVICE_HTTP_POST, PHPCAS_PROXIED_SERVICE_IMAP
Результат CAS_ProxiedService
    public function getProxiedService($type)
    {
        // Sequence validation
        $this->ensureIsProxy();
        $this->ensureAuthenticationCallSuccessful();
        // Argument validation
        if (gettype($type) != 'string') {
            throw new CAS_TypeMismatchException($type, '$type', 'string');
        }
        switch ($type) {
            case PHPCAS_PROXIED_SERVICE_HTTP_GET:
            case PHPCAS_PROXIED_SERVICE_HTTP_POST:
                $requestClass = $this->_requestImplementation;
                $request = new $requestClass();
                if (count($this->_curl_options)) {
                    $request->setCurlOptions($this->_curl_options);
                }
                $proxiedService = new $type($request, $this->_serviceCookieJar);
                if ($proxiedService instanceof CAS_ProxiedService_Testable) {
                    $proxiedService->setCasClient($this);
                }
                return $proxiedService;
            case PHPCAS_PROXIED_SERVICE_IMAP:
                $proxiedService = new CAS_ProxiedService_Imap($this->_getUser());
                if ($proxiedService instanceof CAS_ProxiedService_Testable) {
                    $proxiedService->setCasClient($this);
                }
                return $proxiedService;
            default:
                throw new CAS_InvalidArgumentException("Unknown proxied-service type, {$type}.");
        }
    }

Usage Example

Пример #1
0
 /**
  * Verify that a CAS_ProxyTicketException is thrown if we try to access a service
  * that results in a proxy-ticket failure.
  *
  * @return void
  *
  * @expectedException CAS_ProxyTicketException
  */
 public function testPtException()
 {
     $service = $this->object->getProxiedService(PHPCAS_PROXIED_SERVICE_IMAP);
     $service->setServiceUrl('imap://mail.example.edu/path/that/doesnt/exist');
     $service->setMailbox('mailbox_name');
     $service->setOptions(OP_READONLY);
     $stream = $service->open();
 }
All Usage Examples Of CAS_Client::getProxiedService
CAS_Client