ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 CASClient::getServerHostname ()
 This method is used to retrieve the hostname of the CAS server.
 CASClient::getServerPort ()
 This method is used to retrieve the port of the CAS server.
 CASClient::getServerURI ()
 This method is used to retrieve the URI of the CAS server.
 CASClient::getServerBaseURL ()
 This method is used to retrieve the base URL of the CAS server.
 CASClient::getServerLoginURL ($gateway=false, $renew=false)
 This method is used to retrieve the login URL of the CAS server.
 CASClient::setServerLoginURL ($url)
 This method sets the login URL of the CAS server.
 CASClient::setServerServiceValidateURL ($url)
 This method sets the serviceValidate URL of the CAS server.
 CASClient::setServerProxyValidateURL ($url)
 This method sets the proxyValidate URL of the CAS server.
 CASClient::setServerSamlValidateURL ($url)
 This method sets the samlValidate URL of the CAS server.
 CASClient::getServerServiceValidateURL ()
 This method is used to retrieve the service validating URL of the CAS server.
 CASClient::getServerSamlValidateURL ()
 This method is used to retrieve the SAML validating URL of the CAS server.
 CASClient::getServerProxyValidateURL ()
 This method is used to retrieve the proxy validating URL of the CAS server.
 CASClient::getServerProxyURL ()
 This method is used to retrieve the proxy URL of the CAS server.
 CASClient::getServerLogoutURL ()
 This method is used to retrieve the logout URL of the CAS server.
 CASClient::setServerLogoutURL ($url)
 This method sets the logout URL of the CAS server.
 CASClient::setExtraCurlOption ($key, $value)
 This method is used to set additional user curl options.
 CASClient::isHttps ()
 This method checks to see if the request is secured via HTTPS.
 CASClient::CASClient ($server_version, $proxy, $server_hostname, $server_port, $server_uri, $start_session=true)
 CASClient constructor.
 CASClient::getServerLoginURL ($gateway)
 This method is used to retrieve the login URL of the CAS server.

Variables

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

Detailed Description

Function Documentation

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 574 of file client.php.

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().

{
// the redirect header() call and DOM parsing code from domxml-php4-php5.php won't work in PHP4 compatibility mode
if (version_compare(PHP_VERSION,'5','>=') && ini_get('zend.ze1_compatibility_mode')) {
phpCAS::error('phpCAS cannot support zend.ze1_compatibility_mode. Sorry.');
}
$this->_start_session = $start_session;
if ($this->_start_session && session_id())
{
phpCAS :: error("Another session was started before phpcas. Either disable the session" .
" handling for phpcas in the client() call or modify your application to leave" .
" session handling to phpcas");
}
// skip Session Handling for logout requests and if don't want it'
if ($start_session && !$this->isLogoutRequest())
{
phpCAS :: trace("Starting a new session");
session_start();
}
// are we in proxy mode ?
$this->_proxy = $proxy;
//check version
switch ($server_version) {
if ( $this->isProxy() )
phpCAS::error('CAS proxies are not supported in CAS '
.$server_version);
break;
break;
break;
default:
phpCAS::error('this version of CAS (`'
.$server_version
.'\') is not supported by phpCAS '
.phpCAS::getVersion());
}
$this->_server['version'] = $server_version;
// check hostname
if ( empty($server_hostname)
|| !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/',$server_hostname) ) {
phpCAS::error('bad CAS server hostname (`'.$server_hostname.'\')');
}
$this->_server['hostname'] = $server_hostname;
// check port
if ( $server_port == 0
|| !is_int($server_port) ) {
phpCAS::error('bad CAS server port (`'.$server_hostname.'\')');
}
$this->_server['port'] = $server_port;
// check URI
if ( !preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/',$server_uri) ) {
phpCAS::error('bad CAS server URI (`'.$server_uri.'\')');
}
// add leading and trailing `/' and remove doubles
$server_uri = preg_replace('/\/\//','/','/'.$server_uri.'/');
$this->_server['uri'] = $server_uri;
// set to callback mode if PgtIou and PgtId CGI GET parameters are provided
if ( $this->isProxy() ) {
$this->setCallbackMode(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId']));
}
if ( $this->isCallbackMode() ) {
//callback mode: check that phpCAS is secured
if ( !$this->isHttps() ) {
phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
}
} else {
//normal mode: get ticket and remove it from CGI parameters for developpers
$ticket = (isset($_GET['ticket']) ? $_GET['ticket'] : null);
switch ($this->getServerVersion()) {
case CAS_VERSION_1_0: // check for a Service Ticket
if( preg_match('/^ST-/',$ticket) ) {
phpCAS::trace('ST \''.$ticket.'\' found');
//ST present
$this->setST($ticket);
//ticket has been taken into account, unset it to hide it to applications
unset($_GET['ticket']);
} else if ( !empty($ticket) ) {
//ill-formed ticket, halt
phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
}
break;
case CAS_VERSION_2_0: // check for a Service or Proxy Ticket
if( preg_match('/^ST-/',$ticket) ) {
phpCAS::trace('ST \''.$ticket.'\' found');
$this->setST($ticket);
unset($_GET['ticket']);
}
elseif(preg_match('/PT-', $ticket)) {
phpCAS::trace('PT \''.$ticket.'\' found');
$this->setPT($ticket);
unset($_GET['ticket']);
} else if ( !empty($ticket) ) {
//ill-formed ticket, halt
phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
}
break;
case SAML_VERSION_1_1: // SAML just does Service Tickets
if( preg_match('/^[SP]T-/',$ticket) ) {
phpCAS::trace('SA \''.$ticket.'\' found');
$this->setSA($ticket);
unset($_GET['ticket']);
} else if ( !empty($ticket) ) {
//ill-formed ticket, halt
phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
}
break;
}
}
}

+ Here is the call graph for this function:

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.

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

{
// the URL is build only when needed
if ( empty($this->_server['base_url']) ) {
$this->_server['base_url'] = 'https://'
.$this->getServerHostname()
.':'
.$this->getServerPort()
.$this->getServerURI();
}
return $this->_server['base_url'];
}

+ Here is the caller graph for this function:

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.

Referenced by CASClient\handleLogoutRequests().

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

+ Here is the caller graph for this function:

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.

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

{
// the URL is build only when needed
if ( empty($this->_server['login_url']) ) {
$this->_server['login_url'] = $this->getServerBaseURL();
$this->_server['login_url'] .= 'login?service=';
$this->_server['login_url'] .= preg_replace('/&/','%26',$this->getURL());
if ($gateway) {
$this->_server['login_url'] .= '&gateway=true';
}
}
phpCAS::traceEnd($this->_server['login_url']);
return $this->_server['login_url'];
}

+ Here is the call graph for this function:

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.

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

Referenced by CASClient\redirectToCas().

{
// the URL is build only when needed
if ( empty($this->_server['login_url']) ) {
$this->_server['login_url'] = $this->getServerBaseURL();
$this->_server['login_url'] .= 'login?service=';
// $this->_server['login_url'] .= preg_replace('/&/','%26',$this->getURL());
$this->_server['login_url'] .= urlencode($this->getURL());
if($renew) {
// It is recommended that when the "renew" parameter is set, its value be "true"
$this->_server['login_url'] .= '&renew=true';
} elseif ($gateway) {
// It is recommended that when the "gateway" parameter is set, its value be "true"
$this->_server['login_url'] .= '&gateway=true';
}
}
phpCAS::traceEnd($this->_server['login_url']);
return $this->_server['login_url'];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

References CASClient\getServerBaseURL().

Referenced by CASClient\logout().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

{ return $this->_server['port']; }
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.

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

{
// the URL is build only when needed
if ( empty($this->_server['proxy_url']) ) {
switch ($this->getServerVersion()) {
$this->_server['proxy_url'] = '';
break;
$this->_server['proxy_url'] = $this->getServerBaseURL().'proxy';
break;
}
}
return $this->_server['proxy_url'];
}

+ Here is the call graph for this function:

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.

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

{
// the URL is build only when needed
if ( empty($this->_server['proxy_validate_url']) ) {
switch ($this->getServerVersion()) {
$this->_server['proxy_validate_url'] = '';
break;
$this->_server['proxy_validate_url'] = $this->getServerBaseURL().'proxyValidate';
break;
}
}
// return $this->_server['proxy_validate_url'].'?service='.preg_replace('/&/','%26',$this->getURL());
return $this->_server['proxy_validate_url'].'?service='.urlencode($this->getURL());
}

+ Here is the call graph for this function:

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.

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

{
// the URL is build only when needed
if ( empty($this->_server['saml_validate_url']) ) {
switch ($this->getServerVersion()) {
$this->_server['saml_validate_url'] = $this->getServerBaseURL().'samlValidate';
break;
}
}
phpCAS::traceEnd($this->_server['saml_validate_url'].'?TARGET='.urlencode($this->getURL()));
return $this->_server['saml_validate_url'].'?TARGET='.urlencode($this->getURL());
}

+ Here is the call graph for this function:

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.

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

Referenced by CASClient\validateST().

{
// the URL is build only when needed
if ( empty($this->_server['service_validate_url']) ) {
switch ($this->getServerVersion()) {
$this->_server['service_validate_url'] = $this->getServerBaseURL().'validate';
break;
$this->_server['service_validate_url'] = $this->getServerBaseURL().'serviceValidate';
break;
}
}
// return $this->_server['service_validate_url'].'?service='.preg_replace('/&/','%26',$this->getURL());
return $this->_server['service_validate_url'].'?service='.urlencode($this->getURL());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

{ return $this->_server['uri']; }
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.

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

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

+ Here is the caller graph for this function:

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.

Referenced by CASClient\CASClient().

{
//if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ) {
//0.4.24 by Hinnack
if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
return false;
} else {
return false;
}
}

+ Here is the caller graph for this function:

CASClient::setExtraCurlOption (   $key,
  $value 
)

This method is used to set additional user curl options.

Definition at line 537 of file client.php.

{
$this->_curl_options[$key] = $value;
}
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.

{
return $this->_server['login_url'] = $url;
}
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.

{
return $this->_server['logout_url'] = $url;
}
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.

{
return $this->_server['proxy_validate_url'] = $url;
}
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.

{
return $this->_server['saml_validate_url'] = $url;
}
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.

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

Variable Documentation

CASClient::$_curl_options = array()

An array to store extra curl options.

Definition at line 532 of file client.php.

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.