Esempio n. 1
0
 /**
  * Answer a proxy-authenticated service handler.
  *
  * @param string $type The service type. One of:
  * PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_PROXIED_SERVICE_HTTP_POST,
  * PHPCAS_PROXIED_SERVICE_IMAP
  *
  * @return CAS_ProxiedService
  * @throws InvalidArgumentException If the service type is unknown.
  */
 public function getProxiedService($type)
 {
     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}.");
     }
 }
Esempio n. 2
0
 /**
  * Answer a proxy-authenticated service handler.
  *
  * @param string $type The service type. One of:
  * PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_PROXIED_SERVICE_HTTP_POST,
  * PHPCAS_PROXIED_SERVICE_IMAP
  *
  * @return CAS_ProxiedService
  * @throws InvalidArgumentException If the service type is unknown.
  */
 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}.");
     }
 }