ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Configuration
+ Collaboration diagram for Configuration:

Modules

 HTML output
 
 Internationalization
 To add a new language:
 

Functions

 CASClient::getServerVersion ()
 This method is used to retrieve the version of the CAS server. More...
 
 CASClient::getServerHostname ()
 This method is used to retrieve the hostname of the CAS server. More...
 
 CASClient::getServerPort ()
 This method is used to retrieve the port of the CAS server. More...
 
 CASClient::getServerURI ()
 This method is used to retrieve the URI of the CAS server. More...
 
 CASClient::getServerBaseURL ()
 This method is used to retrieve the base URL of the CAS server. More...
 
 CASClient::getServerLoginURL ($gateway=false, $renew=false)
 This method is used to retrieve the login URL of the CAS server. More...
 
 CASClient::setServerLoginURL ($url)
 This method sets the login URL of the CAS server. More...
 
 CASClient::setServerServiceValidateURL ($url)
 This method sets the serviceValidate URL of the CAS server. More...
 
 CASClient::setServerProxyValidateURL ($url)
 This method sets the proxyValidate URL of the CAS server. More...
 
 CASClient::setServerSamlValidateURL ($url)
 This method sets the samlValidate URL of the CAS server. More...
 
 CASClient::getServerServiceValidateURL ()
 This method is used to retrieve the service validating URL of the CAS server. More...
 
 CASClient::getServerSamlValidateURL ()
 This method is used to retrieve the SAML validating URL of the CAS server. More...
 
 CASClient::getServerProxyValidateURL ()
 This method is used to retrieve the proxy validating URL of the CAS server. More...
 
 CASClient::getServerProxyURL ()
 This method is used to retrieve the proxy URL of the CAS server. More...
 
 CASClient::getServerLogoutURL ()
 This method is used to retrieve the logout URL of the CAS server. More...
 
 CASClient::setServerLogoutURL ($url)
 This method sets the logout URL of the CAS server. More...
 
 CASClient::setExtraCurlOption ($key, $value)
 This method is used to set additional user curl options. More...
 
 CASClient::isHttps ()
 This method checks to see if the request is secured via HTTPS. More...
 
 CASClient::CASClient ( $server_version, $proxy, $server_hostname, $server_port, $server_uri, $start_session=true)
 CASClient constructor. More...
 
 CASClient::getServerLoginURL ($gateway)
 This method is used to retrieve the login URL of the CAS server. More...
 

Variables

 CASClient::$_server
 a record to store information about the CAS server. More...
 
 CASClient::$_curl_options = array()
 An array to store extra curl options. More...
 

Detailed Description

Function Documentation

◆ CASClient()

CASClient::CASClient (   $server_version,
  $proxy,
  $server_hostname,
  $server_port,
  $server_uri,
  $start_session = true 
)

CASClient constructor.

Parameters
$server_versionthe version of the CAS server
$proxyTRUE if the CAS client is a CAS proxy, FALSE otherwise
$server_hostnamethe hostname of the CAS server
$server_portthe port the CAS server is running on
$server_urithe URI the CAS server is responding on
$start_sessionHave phpCAS start PHP sessions (default true)
Returns
a newly created CASClient object

Definition at line 575 of file client.php.

581 {
582
584
585 // the redirect header() call and DOM parsing code from domxml-php4-php5.php won't work in PHP4 compatibility mode
586 if (version_compare(PHP_VERSION,'5','>=') && ini_get('zend.ze1_compatibility_mode')) {
587 phpCAS::error('phpCAS cannot support zend.ze1_compatibility_mode. Sorry.');
588 }
589 $this->_start_session = $start_session;
590
591 if ($this->_start_session && session_id())
592 {
593 phpCAS :: error("Another session was started before phpcas. Either disable the session" .
594 " handling for phpcas in the client() call or modify your application to leave" .
595 " session handling to phpcas");
596 }
597 // skip Session Handling for logout requests and if don't want it'
598 if ($start_session && !$this->isLogoutRequest())
599 {
600 phpCAS :: trace("Starting a new session");
601 session_start();
602 }
603
604
605 // are we in proxy mode ?
606 $this->_proxy = $proxy;
607
608 //check version
609 switch ($server_version) {
610 case CAS_VERSION_1_0:
611 if ( $this->isProxy() )
612 phpCAS::error('CAS proxies are not supported in CAS '
613 .$server_version);
614 break;
615 case CAS_VERSION_2_0:
616 break;
617 case SAML_VERSION_1_1:
618 break;
619 default:
620 phpCAS::error('this version of CAS (`'
621 .$server_version
622 .'\') is not supported by phpCAS '
623 .phpCAS::getVersion());
624 }
625 $this->_server['version'] = $server_version;
626
627 // check hostname
628 if ( empty($server_hostname)
629 || !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/',$server_hostname) ) {
630 phpCAS::error('bad CAS server hostname (`'.$server_hostname.'\')');
631 }
632 $this->_server['hostname'] = $server_hostname;
633
634 // check port
635 if ( $server_port == 0
636 || !is_int($server_port) ) {
637 phpCAS::error('bad CAS server port (`'.$server_hostname.'\')');
638 }
639 $this->_server['port'] = $server_port;
640
641 // check URI
642 if ( !preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/',$server_uri) ) {
643 phpCAS::error('bad CAS server URI (`'.$server_uri.'\')');
644 }
645 // add leading and trailing `/' and remove doubles
646 $server_uri = preg_replace('/\/\//','/','/'.$server_uri.'/');
647 $this->_server['uri'] = $server_uri;
648
649 // set to callback mode if PgtIou and PgtId CGI GET parameters are provided
650 if ( $this->isProxy() ) {
651 $this->setCallbackMode(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId']));
652 }
653
654 if ( $this->isCallbackMode() ) {
655 //callback mode: check that phpCAS is secured
656 if ( !$this->isHttps() ) {
657 phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
658 }
659 } else {
660 //normal mode: get ticket and remove it from CGI parameters for developpers
661 $ticket = (isset($_GET['ticket']) ? $_GET['ticket'] : null);
662 switch ($this->getServerVersion()) {
663 case CAS_VERSION_1_0: // check for a Service Ticket
664 if( preg_match('/^ST-/',$ticket) ) {
665 phpCAS::trace('ST \''.$ticket.'\' found');
666 //ST present
667 $this->setST($ticket);
668 //ticket has been taken into account, unset it to hide it to applications
669 unset($_GET['ticket']);
670 } else if ( !empty($ticket) ) {
671 //ill-formed ticket, halt
672 phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
673 }
674 break;
675 case CAS_VERSION_2_0: // check for a Service or Proxy Ticket
676 if( preg_match('/^ST-/',$ticket) ) {
677 phpCAS::trace('ST \''.$ticket.'\' found');
678 $this->setST($ticket);
679 unset($_GET['ticket']);
680 }
681 elseif(preg_match('/PT-/', $ticket)) {
682 phpCAS::trace('PT \''.$ticket.'\' found');
683 $this->setPT($ticket);
684 unset($_GET['ticket']);
685 } else if ( !empty($ticket) ) {
686 //ill-formed ticket, halt
687 phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
688 }
689 break;
690 case SAML_VERSION_1_1: // SAML just does Service Tickets
691 if( preg_match('/^[SP]T-/',$ticket) ) {
692 phpCAS::trace('SA \''.$ticket.'\' found');
693 $this->setSA($ticket);
694 unset($_GET['ticket']);
695 } else if ( !empty($ticket) ) {
696 //ill-formed ticket, halt
697 phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
698 }
699 break;
700 }
701 }
703 }
$_GET["client_id"]
The phpCAS class is a simple container for the phpCAS library.
Definition: CAS.php:341
isLogoutRequest()
Definition: client.php:1183
setCallbackMode($callback_mode)
This method sets/unsets callback mode.
Definition: client.php:1759
isCallbackMode()
This method returns TRUE when the CAs client is running i callback mode, FALSE otherwise.
Definition: client.php:1772
getServerVersion()
This method is used to retrieve the version of the CAS server.
Definition: client.php:297
isHttps()
This method checks to see if the request is secured via HTTPS.
Definition: client.php:547
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode.
Definition: CAS.php:577
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
isProxy()
Tells if a CAS client is a CAS proxy or not.
Definition: client.php:1681
const SAML_VERSION_1_1
SAML protocol.
Definition: CAS.php:90
const CAS_VERSION_1_0
CAS version 1.0.
Definition: CAS.php:77
const CAS_VERSION_2_0
Definition: CAS.php:81

References $_GET, CAS_VERSION_1_0, CAS_VERSION_2_0, phpCAS\error(), CASClient\getServerVersion(), CASClient\isCallbackMode(), CASClient\isHttps(), CASClient\isLogoutRequest(), CASClient\isProxy(), SAML_VERSION_1_1, CASClient\setCallbackMode(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ getServerBaseURL()

CASClient::getServerBaseURL ( )
private

This method is used to retrieve the base URL of the CAS server.

Returns
a URL.

Definition at line 331 of file client.php.

332 {
333 // the URL is build only when needed
334 if ( empty($this->_server['base_url']) ) {
335 $this->_server['base_url'] = 'https://'
336 .$this->getServerHostname()
337 .':'
338 .$this->getServerPort()
339 .$this->getServerURI();
340 }
341 return $this->_server['base_url'];
342 }

Referenced by CASClient\getServerLoginURL(), CASClient\getServerLogoutURL(), CASClient\getServerProxyURL(), CASClient\getServerProxyValidateURL(), CASClient\getServerSamlValidateURL(), CASClient\getServerServiceValidateURL(), and CASClient\HTMLFilterOutput().

+ Here is the caller graph for this function:

◆ getServerHostname()

CASClient::getServerHostname ( )
private

This method is used to retrieve the hostname of the CAS server.

Returns
the hostname of the CAS server.

Definition at line 307 of file client.php.

308 { return $this->_server['hostname']; }

Referenced by CASClient\handleLogoutRequests().

+ Here is the caller graph for this function:

◆ getServerLoginURL() [1/2]

CASClient::getServerLoginURL (   $gateway)
private

This method is used to retrieve the login URL of the CAS server.

Parameters
$gatewaytrue to check authentication, false to force it
Returns
a URL.

Definition at line 325 of file client.php.

326 {
328 // the URL is build only when needed
329 if ( empty($this->_server['login_url']) ) {
330 $this->_server['login_url'] = $this->getServerBaseURL();
331 $this->_server['login_url'] .= 'login?service=';
332 $this->_server['login_url'] .= preg_replace('/&/','%26',$this->getURL());
333 if ($gateway) {
334 $this->_server['login_url'] .= '&gateway=true';
335 }
336 }
337 phpCAS::traceEnd($this->_server['login_url']);
338 return $this->_server['login_url'];
339 }
getServerBaseURL()
This method is used to retrieve the base URL of the CAS server.
Definition: client.php:331
getURL()
This method returns the URL of the current request (without any ticket CGI parameter).
Definition: client.php:2621

References CASClient\getServerBaseURL(), CASClient\getURL(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ getServerLoginURL() [2/2]

CASClient::getServerLoginURL (   $gateway = false,
  $renew = false 
)
private

This method is used to retrieve the login URL of the CAS server.

Parameters
$gatewaytrue to check authentication, false to force it
$renewtrue to force the authentication with the CAS server NOTE : It is recommended that CAS implementations ignore the "gateway" parameter if "renew" is set
Returns
a URL.

Definition at line 353 of file client.php.

353 {
355 // the URL is build only when needed
356 if ( empty($this->_server['login_url']) ) {
357 $this->_server['login_url'] = $this->getServerBaseURL();
358 $this->_server['login_url'] .= 'login?service=';
359 // $this->_server['login_url'] .= preg_replace('/&/','%26',$this->getURL());
360 $this->_server['login_url'] .= urlencode($this->getURL());
361 if($renew) {
362 // It is recommended that when the "renew" parameter is set, its value be "true"
363 $this->_server['login_url'] .= '&renew=true';
364 } elseif ($gateway) {
365 // It is recommended that when the "gateway" parameter is set, its value be "true"
366 $this->_server['login_url'] .= '&gateway=true';
367 }
368 }
369 phpCAS::traceEnd($this->_server['login_url']);
370 return $this->_server['login_url'];
371 }

References CASClient\getServerBaseURL(), CASClient\getURL(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by CASClient\redirectToCas().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerLogoutURL()

CASClient::getServerLogoutURL ( )
private

This method is used to retrieve the logout URL of the CAS server.

Returns
a URL.

Definition at line 509 of file client.php.

510 {
511 // the URL is build only when needed
512 if ( empty($this->_server['logout_url']) ) {
513 $this->_server['logout_url'] = $this->getServerBaseURL().'logout';
514 }
515 return $this->_server['logout_url'];
516 }

References CASClient\getServerBaseURL().

Referenced by CASClient\logout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerPort()

CASClient::getServerPort ( )
private

This method is used to retrieve the port of the CAS server.

Returns
the port of the CAS server.

Definition at line 315 of file client.php.

316 { return $this->_server['port']; }

◆ getServerProxyURL()

CASClient::getServerProxyURL ( )
private

This method is used to retrieve the proxy URL of the CAS server.

Returns
a URL.

Definition at line 488 of file client.php.

489 {
490 // the URL is build only when needed
491 if ( empty($this->_server['proxy_url']) ) {
492 switch ($this->getServerVersion()) {
493 case CAS_VERSION_1_0:
494 $this->_server['proxy_url'] = '';
495 break;
496 case CAS_VERSION_2_0:
497 $this->_server['proxy_url'] = $this->getServerBaseURL().'proxy';
498 break;
499 }
500 }
501 return $this->_server['proxy_url'];
502 }

References CAS_VERSION_1_0, CAS_VERSION_2_0, CASClient\getServerBaseURL(), and CASClient\getServerVersion().

+ Here is the call graph for this function:

◆ getServerProxyValidateURL()

CASClient::getServerProxyValidateURL ( )
private

This method is used to retrieve the proxy validating URL of the CAS server.

Returns
a URL.

Definition at line 466 of file client.php.

467 {
468 // the URL is build only when needed
469 if ( empty($this->_server['proxy_validate_url']) ) {
470 switch ($this->getServerVersion()) {
471 case CAS_VERSION_1_0:
472 $this->_server['proxy_validate_url'] = '';
473 break;
474 case CAS_VERSION_2_0:
475 $this->_server['proxy_validate_url'] = $this->getServerBaseURL().'proxyValidate';
476 break;
477 }
478 }
479 // return $this->_server['proxy_validate_url'].'?service='.preg_replace('/&/','%26',$this->getURL());
480 return $this->_server['proxy_validate_url'].'?service='.urlencode($this->getURL());
481 }

References CAS_VERSION_1_0, CAS_VERSION_2_0, CASClient\getServerBaseURL(), CASClient\getServerVersion(), and CASClient\getURL().

+ Here is the call graph for this function:

◆ getServerSamlValidateURL()

CASClient::getServerSamlValidateURL ( )
private

This method is used to retrieve the SAML validating URL of the CAS server.

Returns
a URL.

Definition at line 447 of file client.php.

448 {
450 // the URL is build only when needed
451 if ( empty($this->_server['saml_validate_url']) ) {
452 switch ($this->getServerVersion()) {
453 case SAML_VERSION_1_1:
454 $this->_server['saml_validate_url'] = $this->getServerBaseURL().'samlValidate';
455 break;
456 }
457 }
458 phpCAS::traceEnd($this->_server['saml_validate_url'].'?TARGET='.urlencode($this->getURL()));
459 return $this->_server['saml_validate_url'].'?TARGET='.urlencode($this->getURL());
460 }

References CASClient\getServerBaseURL(), CASClient\getServerVersion(), CASClient\getURL(), SAML_VERSION_1_1, phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ getServerServiceValidateURL()

CASClient::getServerServiceValidateURL ( )
private

This method is used to retrieve the service validating URL of the CAS server.

Returns
a URL.

Definition at line 426 of file client.php.

427 {
428 // the URL is build only when needed
429 if ( empty($this->_server['service_validate_url']) ) {
430 switch ($this->getServerVersion()) {
431 case CAS_VERSION_1_0:
432 $this->_server['service_validate_url'] = $this->getServerBaseURL().'validate';
433 break;
434 case CAS_VERSION_2_0:
435 $this->_server['service_validate_url'] = $this->getServerBaseURL().'serviceValidate';
436 break;
437 }
438 }
439 // return $this->_server['service_validate_url'].'?service='.preg_replace('/&/','%26',$this->getURL());
440 return $this->_server['service_validate_url'].'?service='.urlencode($this->getURL());
441 }

References CAS_VERSION_1_0, CAS_VERSION_2_0, CASClient\getServerBaseURL(), CASClient\getServerVersion(), and CASClient\getURL().

Referenced by CASClient\validateST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerURI()

CASClient::getServerURI ( )
private

This method is used to retrieve the URI of the CAS server.

Returns
a URI.

Definition at line 323 of file client.php.

324 { return $this->_server['uri']; }

◆ getServerVersion()

CASClient::getServerVersion ( )
private

This method is used to retrieve the version of the CAS server.

Returns
the version of the CAS server.

Definition at line 297 of file client.php.

298 {
299 return $this->_server['version'];
300 }

Referenced by CASClient\CASClient(), CASClient\getServerProxyURL(), CASClient\getServerProxyValidateURL(), CASClient\getServerSamlValidateURL(), CASClient\getServerServiceValidateURL(), and CASClient\HTMLFilterOutput().

+ Here is the caller graph for this function:

◆ isHttps()

CASClient::isHttps ( )
private

This method checks to see if the request is secured via HTTPS.

Returns
true if https, false otherwise

Definition at line 547 of file client.php.

547 {
548 //if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ) {
549 //0.4.24 by Hinnack
550 if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
551 # mantis: 0013115: CAS not work on HTTPS
552 return true;
553 } else {
554 return false;
555 }
556 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER.

Referenced by CASClient\CASClient().

+ Here is the caller graph for this function:

◆ setExtraCurlOption()

CASClient::setExtraCurlOption (   $key,
  $value 
)

This method is used to set additional user curl options.

Definition at line 537 of file client.php.

538 {
539 $this->_curl_options[$key] = $value;
540 }

◆ setServerLoginURL()

CASClient::setServerLoginURL (   $url)
private

This method sets the login URL of the CAS server.

Parameters
$urlthe login URL
Since
0.4.21 by Wyman Chan

Definition at line 379 of file client.php.

380 {
381 return $this->_server['login_url'] = $url;
382 }
$url
Definition: shib_logout.php:72

References $url.

◆ setServerLogoutURL()

CASClient::setServerLogoutURL (   $url)
private

This method sets the logout URL of the CAS server.

Parameters
$urlthe logout URL
Since
0.4.21 by Wyman Chan

Definition at line 524 of file client.php.

525 {
526 return $this->_server['logout_url'] = $url;
527 }

References $url.

◆ setServerProxyValidateURL()

CASClient::setServerProxyValidateURL (   $url)
private

This method sets the proxyValidate URL of the CAS server.

Parameters
$urlthe proxyValidate URL
Since
1.1.0 by Joachim Fritschi

Definition at line 403 of file client.php.

404 {
405 return $this->_server['proxy_validate_url'] = $url;
406 }

References $url.

◆ setServerSamlValidateURL()

CASClient::setServerSamlValidateURL (   $url)
private

This method sets the samlValidate URL of the CAS server.

Parameters
$urlthe samlValidate URL
Since
1.1.0 by Joachim Fritschi

Definition at line 415 of file client.php.

416 {
417 return $this->_server['saml_validate_url'] = $url;
418 }

References $url.

◆ setServerServiceValidateURL()

CASClient::setServerServiceValidateURL (   $url)
private

This method sets the serviceValidate URL of the CAS server.

Parameters
$urlthe serviceValidate URL
Since
1.1.0 by Joachim Fritschi

Definition at line 391 of file client.php.

392 {
393 return $this->_server['service_validate_url'] = $url;
394 }

References $url.

Variable Documentation

◆ $_curl_options

CASClient::$_curl_options = array()

An array to store extra curl options.

Definition at line 532 of file client.php.

◆ $_server

CASClient::$_server
private

a record to store information about the CAS server.

  • $_server["version"]: the version of the CAS server
  • $_server["hostname"]: the hostname of the CAS server
  • $_server["port"]: the port the CAS server is running on
  • $_server["uri"]: the base URI the CAS server is responding on
  • $_server["base_url"]: the base URL of the CAS server
  • $_server["login_url"]: the login URL of the CAS server
  • $_server["service_validate_url"]: the service validating URL of the CAS server
  • $_server["proxy_url"]: the proxy URL of the CAS server
  • $_server["proxy_validate_url"]: the proxy validating URL of the CAS server
  • $_server["logout_url"]: the logout URL of the CAS server

$_server["version"], $_server["hostname"], $_server["port"] and $_server["uri"] are written by CASClient::CASClient(), read by CASClient::getServerVersion(), CASClient::getServerHostname(), CASClient::getServerPort() and CASClient::getServerURI().

The other fields are written and read by CASClient::getServerBaseURL(), CASClient::getServerLoginURL(), CASClient::getServerServiceValidateURL(), CASClient::getServerProxyValidateURL() and CASClient::getServerLogoutURL().

Definition at line 285 of file client.php.