ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
+ Collaboration diagram for Proxy other services:

Functions

 CAS_Client::getProxiedService ($type)
 Answer a proxy-authenticated service handler. More...
 
 CAS_Client::initializeProxiedService (CAS_ProxiedService $proxiedService)
 Initialize a proxied-service handler with the proxy-ticket it should use. More...
 
 CAS_Client::serviceWeb ($url, &$err_code, &$output)
 This method is used to access an HTTP[S] service. More...
 
 CAS_Client::serviceMail ($url, $serviceUrl, $flags, &$err_code, &$err_msg, &$pt)
 This method is used to access an IMAP/POP3/NNTP service. More...
 

Detailed Description

Function Documentation

◆ getProxiedService()

CAS_Client::getProxiedService (   $type)

Answer a proxy-authenticated service handler.

Parameters
string$typeThe service type. One of: PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_PROXIED_SERVICE_HTTP_POST, PHPCAS_PROXIED_SERVICE_IMAP
Returns
CAS_ProxiedService
Exceptions
InvalidArgumentExceptionIf the service type is unknown.

Definition at line 2882 of file Client.php.

References CAS_Client\$_requestImplementation, $type, CAS_Client\_getUser(), CAS_Client\ensureAuthenticationCallSuccessful(), CAS_Client\ensureIsProxy(), PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_PROXIED_SERVICE_HTTP_POST, and PHPCAS_PROXIED_SERVICE_IMAP.

Referenced by CAS_Client\serviceMail(), and CAS_Client\serviceWeb().

2883  {
2884  // Sequence validation
2885  $this->ensureIsProxy();
2887 
2888  // Argument validation
2889  if (gettype($type) != 'string')
2890  throw new CAS_TypeMismatchException($type, '$type', 'string');
2891 
2892  switch ($type) {
2895  $requestClass = $this->_requestImplementation;
2896  $request = new $requestClass();
2897  if (count($this->_curl_options)) {
2898  $request->setCurlOptions($this->_curl_options);
2899  }
2900  $proxiedService = new $type($request, $this->_serviceCookieJar);
2901  if ($proxiedService instanceof CAS_ProxiedService_Testable) {
2902  $proxiedService->setCasClient($this);
2903  }
2904  return $proxiedService;
2906  $proxiedService = new CAS_ProxiedService_Imap($this->_getUser());
2907  if ($proxiedService instanceof CAS_ProxiedService_Testable) {
2908  $proxiedService->setCasClient($this);
2909  }
2910  return $proxiedService;
2911  default:
2912  throw new CAS_InvalidArgumentException(
2913  "Unknown proxied-service type, $type."
2914  );
2915  }
2916  }
const PHPCAS_PROXIED_SERVICE_IMAP
phpCAS::getProxiedService() type for IMAP
Definition: CAS.php:203
$type
ensureIsProxy()
Ensure that this is actually a proxy object or fail with an exception.
Definition: Client.php:745
Provides access to a proxy-authenticated IMAP stream.
Definition: Imap.php:40
_getUser()
This method returns the CAS user's login name.
Definition: Client.php:1134
const PHPCAS_PROXIED_SERVICE_HTTP_POST
phpCAS::getProxiedService() type for HTTP POST
Definition: CAS.php:199
Exception that denotes invalid arguments were passed.
ensureAuthenticationCallSuccessful()
Ensure that authentication was checked.
Definition: Client.php:822
const PHPCAS_PROXIED_SERVICE_HTTP_GET
phpCAS::getProxiedService() type for HTTP GET
Definition: CAS.php:195
$_requestImplementation
The class to instantiate for making web requests in readUrl().
Definition: Client.php:601
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeProxiedService()

CAS_Client::initializeProxiedService ( CAS_ProxiedService  $proxiedService)

Initialize a proxied-service handler with the proxy-ticket it should use.

Parameters
CAS_ProxiedService$proxiedServiceservice handler
Returns
void
Exceptions
CAS_ProxyTicketExceptionIf there is a proxy-ticket failure. The code of the Exception will be one of: PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE PHPCAS_SERVICE_PT_FAILURE
CAS_ProxiedService_ExceptionIf there is a failure getting the url from the proxied service.

Definition at line 2933 of file Client.php.

References $url, CAS_Client\ensureAuthenticationCallSuccessful(), CAS_Client\ensureIsProxy(), CAS_ProxiedService\getServiceUrl(), CAS_Client\retrievePT(), and CAS_ProxiedService\setProxyTicket().

2934  {
2935  // Sequence validation
2936  $this->ensureIsProxy();
2938 
2939  $url = $proxiedService->getServiceUrl();
2940  if (!is_string($url)) {
2941  throw new CAS_ProxiedService_Exception(
2942  "Proxied Service ".get_class($proxiedService)
2943  ."->getServiceUrl() should have returned a string, returned a "
2944  .gettype($url)." instead."
2945  );
2946  }
2947  $pt = $this->retrievePT($url, $err_code, $err_msg);
2948  if (!$pt) {
2949  throw new CAS_ProxyTicketException($err_msg, $err_code);
2950  }
2951  $proxiedService->setProxyTicket($pt);
2952  }
retrievePT($target_service, &$err_code, &$err_msg)
This method is used to retrieve PT's from the CAS server thanks to a PGT.
Definition: Client.php:2658
An Exception for problems communicating with a proxied service.
Definition: Exception.php:40
ensureIsProxy()
Ensure that this is actually a proxy object or fail with an exception.
Definition: Client.php:745
setProxyTicket($proxyTicket)
Register a proxy ticket with the ProxiedService that it can use when making requests.
getServiceUrl()
Answer a service identifier (URL) for whom we should fetch a proxy ticket.
ensureAuthenticationCallSuccessful()
Ensure that authentication was checked.
Definition: Client.php:822
$url
An Exception for errors related to fetching or validating proxy tickets.
+ Here is the call graph for this function:

◆ serviceMail()

CAS_Client::serviceMail (   $url,
  $serviceUrl,
  $flags,
$err_code,
$err_msg,
$pt 
)

This method is used to access an IMAP/POP3/NNTP service.

Parameters
string$urla string giving the URL of the service, including the mailing box for IMAP URLs, as accepted by imap_open().
string$serviceUrla string giving for CAS retrieve Proxy ticket
string$flagsoptions given to imap_open().
int&$err_codean error code Possible values are PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT_AVAILABLE.
string&$err_msgan error message on failure
string&$ptthe Proxy Ticket (PT) retrieved from the CAS server to access the URL on success, false on error).
Returns
object an IMAP stream on success, false otherwise (in this later case, $err_code gives the reason why it failed and $err_msg contains an error message).

Definition at line 3018 of file Client.php.

References $lang, $service, GuzzleHttp\Psr7\$stream, $url, CAS_Client\ensureAuthenticationCallSuccessful(), CAS_Client\ensureIsProxy(), CAS_Client\getLangObj(), CAS_Client\getProxiedService(), PHPCAS_PROXIED_SERVICE_IMAP, PHPCAS_SERVICE_NOT_AVAILABLE, and PHPCAS_SERVICE_OK.

3019  {
3020  // Sequence validation
3021  $this->ensureIsProxy();
3023 
3024  // Argument validation
3025  if (gettype($url) != 'string')
3026  throw new CAS_TypeMismatchException($url, '$url', 'string');
3027  if (gettype($serviceUrl) != 'string')
3028  throw new CAS_TypeMismatchException($serviceUrl, '$serviceUrl', 'string');
3029  if (gettype($flags) != 'integer')
3030  throw new CAS_TypeMismatchException($flags, '$flags', 'string');
3031 
3032  try {
3034  $service->setServiceUrl($serviceUrl);
3035  $service->setMailbox($url);
3036  $service->setOptions($flags);
3037 
3038  $stream = $service->open();
3039  $err_code = PHPCAS_SERVICE_OK;
3040  $pt = $service->getImapProxyTicket();
3041  return $stream;
3042  } catch (CAS_ProxyTicketException $e) {
3043  $err_msg = $e->getMessage();
3044  $err_code = $e->getCode();
3045  $pt = false;
3046  return false;
3047  } catch (CAS_ProxiedService_Exception $e) {
3048  $lang = $this->getLangObj();
3049  $err_msg = sprintf(
3050  $lang->getServiceUnavailable(),
3051  $url,
3052  $e->getMessage()
3053  );
3054  $err_code = PHPCAS_SERVICE_NOT_AVAILABLE;
3055  $pt = false;
3056  return false;
3057  }
3058  }
getLangObj()
Create the language.
Definition: Client.php:222
const PHPCAS_PROXIED_SERVICE_IMAP
phpCAS::getProxiedService() type for IMAP
Definition: CAS.php:203
const PHPCAS_SERVICE_OK
phpCAS::service() error code on success
Definition: CAS.php:168
An Exception for problems communicating with a proxied service.
Definition: Exception.php:40
$service
Definition: login.php:15
$stream
PHP stream implementation.
ensureIsProxy()
Ensure that this is actually a proxy object or fail with an exception.
Definition: Client.php:745
const PHPCAS_SERVICE_NOT_AVAILABLE
phpCAS::service() error code when the service was not available.
Definition: CAS.php:187
ensureAuthenticationCallSuccessful()
Ensure that authentication was checked.
Definition: Client.php:822
$url
An Exception for errors related to fetching or validating proxy tickets.
getProxiedService($type)
Answer a proxy-authenticated service handler.
Definition: Client.php:2882
+ Here is the call graph for this function:

◆ serviceWeb()

CAS_Client::serviceWeb (   $url,
$err_code,
$output 
)

This method is used to access an HTTP[S] service.

Parameters
string$urlthe service to access.
int&$err_codean error code Possible values are PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT_AVAILABLE.
string&$outputthe output of the service (also used to give an error message on failure).
Returns
true on success, false otherwise (in this later case, $err_code gives the reason why it failed and $output contains an error message).

Definition at line 2968 of file Client.php.

References $lang, $output, $service, $url, CAS_Client\ensureAuthenticationCallSuccessful(), CAS_Client\ensureIsProxy(), CAS_Client\getLangObj(), CAS_Client\getProxiedService(), PHPCAS_PROXIED_SERVICE_HTTP_GET, PHPCAS_SERVICE_NOT_AVAILABLE, and PHPCAS_SERVICE_OK.

2969  {
2970  // Sequence validation
2971  $this->ensureIsProxy();
2973 
2974  // Argument validation
2975  if (gettype($url) != 'string')
2976  throw new CAS_TypeMismatchException($url, '$url', 'string');
2977 
2978  try {
2980  $service->setUrl($url);
2981  $service->send();
2982  $output = $service->getResponseBody();
2983  $err_code = PHPCAS_SERVICE_OK;
2984  return true;
2985  } catch (CAS_ProxyTicketException $e) {
2986  $err_code = $e->getCode();
2987  $output = $e->getMessage();
2988  return false;
2989  } catch (CAS_ProxiedService_Exception $e) {
2990  $lang = $this->getLangObj();
2991  $output = sprintf(
2992  $lang->getServiceUnavailable(), $url, $e->getMessage()
2993  );
2994  $err_code = PHPCAS_SERVICE_NOT_AVAILABLE;
2995  return false;
2996  }
2997  }
getLangObj()
Create the language.
Definition: Client.php:222
const PHPCAS_SERVICE_OK
phpCAS::service() error code on success
Definition: CAS.php:168
An Exception for problems communicating with a proxied service.
Definition: Exception.php:40
$service
Definition: login.php:15
ensureIsProxy()
Ensure that this is actually a proxy object or fail with an exception.
Definition: Client.php:745
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
const PHPCAS_SERVICE_NOT_AVAILABLE
phpCAS::service() error code when the service was not available.
Definition: CAS.php:187
ensureAuthenticationCallSuccessful()
Ensure that authentication was checked.
Definition: Client.php:822
$url
const PHPCAS_PROXIED_SERVICE_HTTP_GET
phpCAS::getProxiedService() type for HTTP GET
Definition: CAS.php:195
An Exception for errors related to fetching or validating proxy tickets.
getProxiedService($type)
Answer a proxy-authenticated service handler.
Definition: Client.php:2882
+ Here is the call graph for this function: