ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
+ Collaboration diagram for PGT storage:

Modules

 PGT storage in a database
 
 PGT storage on the filesystem
 

Namespaces

namespace  PhpCAS
 

Functions

 CAS_Client::_initPGTStorage ()
 This method is used to initialize the storage of PGT's. More...
 
 CAS_Client::_storePGT ($pgt, $pgt_iou)
 This method stores a PGT. More...
 
 CAS_Client::_loadPGT ($pgt_iou)
 This method reads a PGT from its Iou and deletes the corresponding storage entry. More...
 
 CAS_Client::setPGTStorage ($storage)
 This method can be used to set a custom PGT storage object. More...
 
 CAS_Client::setPGTStorageDb ( $dsn_or_pdo, $username='', $password='', $table='', $driver_options=null)
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests in a database. More...
 
 CAS_Client::setPGTStorageFile ($path='')
 This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem. More...
 
 CAS_Client::_validatePGT (&$validate_url, $text_response, $tree_response)
 This method is used to validate a PGT; halt on failure. More...
 
 CAS_Client::retrievePT ($target_service, &$err_code, &$err_msg)
 This method is used to retrieve PT's from the CAS server thanks to a PGT. More...
 
 CAS_PGTStorage_AbstractStorage::__construct ($cas_parent)
 The constructor of the class, should be called only by inherited classes. More...
 
 CAS_PGTStorage_AbstractStorage::getStorageType ()
 This virtual method returns an informational string giving the type of storage used by the object (used for debugging purposes). More...
 
 CAS_PGTStorage_AbstractStorage::getStorageInfo ()
 This virtual method returns an informational string giving informations on the parameters of the storage. More...
 
 CAS_PGTStorage_AbstractStorage::setErrorMessage ($error_message)
 This method sets en error message, which can be read later by PGTStorage::getErrorMessage(). More...
 
 CAS_PGTStorage_AbstractStorage::getErrorMessage ()
 This method returns an error message set by PGTStorage::setErrorMessage(). More...
 
 CAS_PGTStorage_AbstractStorage::isInitialized ()
 This method tells if the storage has already been intialized. More...
 
 CAS_PGTStorage_AbstractStorage::init ()
 This virtual method initializes the object. More...
 
 CAS_PGTStorage_AbstractStorage::write ($pgt, $pgt_iou)
 This virtual method stores a PGT and its corresponding PGT Iuo. More...
 
 CAS_PGTStorage_AbstractStorage::read ($pgt_iou)
 This virtual method reads a PGT corresponding to a PGT Iou and deletes the corresponding storage entry. More...
 

Variables

 CAS_Client::$_pgt_storage
 an instance of a class inheriting of PGTStorage, used to deal with PGT storage. More...
 
 CAS_PGTStorage_AbstractStorage::$_error_message
 string used to store an error message. More...
 
 CAS_PGTStorage_AbstractStorage::$_initialized
 a boolean telling if the storage has already been initialized. More...
 

Detailed Description

Function Documentation

◆ __construct()

CAS_PGTStorage_AbstractStorage::__construct (   $cas_parent)

The constructor of the class, should be called only by inherited classes.

Parameters
CAS_Client$cas_parentthe CAS _client instance that creates the current object.
Returns
void

Definition at line 67 of file AbstractStorage.php.

68 {
70 if (!$cas_parent->isProxy()) {
72 'defining PGT storage makes no sense when not using a CAS proxy'
73 );
74 }
76 }
static traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:658
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode.
Definition: CAS.php:611
static error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:563

References phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ _initPGTStorage()

CAS_Client::_initPGTStorage ( )
private

This method is used to initialize the storage of PGT's.

Halts on error.

Returns
void

Definition at line 2516 of file Client.php.

2517 {
2518 // if no SetPGTStorageXxx() has been used, default to file
2519 if (!is_object($this->_pgt_storage)) {
2520 $this->setPGTStorageFile();
2521 }
2522
2523 // initializes the storage
2524 $this->_pgt_storage->init();
2525 }
setPGTStorageFile($path='')
This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the f...
Definition: Client.php:2648

References CAS_Client\setPGTStorageFile().

Referenced by CAS_Client\_loadPGT(), and CAS_Client\_storePGT().

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

◆ _loadPGT()

CAS_Client::_loadPGT (   $pgt_iou)
private

This method reads a PGT from its Iou and deletes the corresponding storage entry.

Parameters
string$pgt_iouthe PGT Iou
Returns
mul The PGT corresponding to the Iou, false when not found.

Definition at line 2551 of file Client.php.

2552 {
2553 // ensure that storage is initialized
2554 $this->_initPGTStorage();
2555 // read the PGT
2556 return $this->_pgt_storage->read($pgt_iou);
2557 }
_initPGTStorage()
This method is used to initialize the storage of PGT's.
Definition: Client.php:2516

References CAS_Client\_initPGTStorage().

Referenced by CAS_Client\_validatePGT().

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

◆ _storePGT()

CAS_Client::_storePGT (   $pgt,
  $pgt_iou 
)
private

This method stores a PGT.

Halts on error.

Parameters
string$pgtthe PGT to store
string$pgt_iouits corresponding Iou
Returns
void

Definition at line 2535 of file Client.php.

2536 {
2537 // ensure that storage is initialized
2538 $this->_initPGTStorage();
2539 // writes the PGT
2540 $this->_pgt_storage->write($pgt, $pgt_iou);
2541 }

References CAS_Client\_initPGTStorage().

Referenced by CAS_Client\_callback().

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

◆ _validatePGT()

CAS_Client::_validatePGT ( $validate_url,
  $text_response,
  $tree_response 
)
private

This method is used to validate a PGT; halt on failure.

Parameters
string&$validate_urlthe URL of the request to the CAS server.
string$text_responsethe response of the CAS server, as is (XML text); result of CAS_Client::validateCAS10() or CAS_Client::validateCAS20().
string$tree_responsethe response of the CAS server, as a DOM XML tree; result of CAS_Client::validateCAS10() or CAS_Client::validateCAS20().
Returns
bool true when successfull and issue a CAS_AuthenticationException and false on an error

Definition at line 2680 of file Client.php.

2681 {
2683 if ($tree_response->getElementsByTagName("proxyGrantingTicket")->length == 0) {
2684 phpCAS::trace('<proxyGrantingTicket> not found');
2685 // authentication succeded, but no PGT Iou was transmitted
2687 $this,
2688 'Ticket validated but no PGT Iou transmitted',
2689 $validate_url,
2690 false/*$no_response*/,
2691 false/*$bad_response*/,
2692 $text_response
2693 );
2694 } else {
2695 // PGT Iou transmitted, extract it
2696 $pgt_iou = trim(
2697 $tree_response->getElementsByTagName("proxyGrantingTicket")->item(0)->nodeValue
2698 );
2699 if (preg_match('/PGTIOU-[\.\-\w]/', $pgt_iou)) {
2700 $pgt = $this->_loadPGT($pgt_iou);
2701 if ($pgt == false) {
2702 phpCAS::trace('could not load PGT');
2704 $this,
2705 'PGT Iou was transmitted but PGT could not be retrieved',
2706 $validate_url,
2707 false/*$no_response*/,
2708 false/*$bad_response*/,
2709 $text_response
2710 );
2711 }
2712 $this->_setPGT($pgt);
2713 } else {
2714 phpCAS::trace('PGTiou format error');
2716 $this,
2717 'PGT Iou was transmitted but has wrong format',
2718 $validate_url,
2719 false/*$no_response*/,
2720 false/*$bad_response*/,
2721 $text_response
2722 );
2723 }
2724 }
2725 phpCAS::traceEnd(true);
2726 return true;
2727 }
This interface defines methods that allow proxy-authenticated service handlers to interact with phpCA...
_loadPGT($pgt_iou)
This method reads a PGT from its Iou and deletes the corresponding storage entry.
Definition: Client.php:2551
_setPGT($pgt)
This method stores the Proxy Granting Ticket.
Definition: Client.php:2343
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599

References CAS_Client\_loadPGT(), CAS_Client\_setPGT(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by CAS_Client\isAuthenticated().

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

◆ getErrorMessage()

CAS_PGTStorage_AbstractStorage::getErrorMessage ( )

This method returns an error message set by PGTStorage::setErrorMessage().

Returns
an error message when set by PGTStorage::setErrorMessage(), FALSE otherwise.
Deprecated:
not used.

Definition at line 144 of file AbstractStorage.php.

145 {
147 }
$_error_message
string used to store an error message.

References CAS_PGTStorage_AbstractStorage\$_error_message.

◆ getStorageInfo()

CAS_PGTStorage_AbstractStorage::getStorageInfo ( )

This virtual method returns an informational string giving informations on the parameters of the storage.

(used for debugging purposes).

Returns
void

Reimplemented in CAS_PGTStorage_Db, and CAS_PGTStorage_File.

Definition at line 103 of file AbstractStorage.php.

104 {
105 phpCAS::error(__CLASS__ . '::' . __FUNCTION__ . '() should never be called');
106 }

References phpCAS\error().

+ Here is the call graph for this function:

◆ getStorageType()

CAS_PGTStorage_AbstractStorage::getStorageType ( )

This virtual method returns an informational string giving the type of storage used by the object (used for debugging purposes).

Returns
void

Reimplemented in CAS_PGTStorage_Db, and CAS_PGTStorage_File.

Definition at line 90 of file AbstractStorage.php.

91 {
92 phpCAS::error(__CLASS__ . '::' . __FUNCTION__ . '() should never be called');
93 }

References phpCAS\error().

+ Here is the call graph for this function:

◆ init()

CAS_PGTStorage_AbstractStorage::init ( )

This virtual method initializes the object.

Returns
void

Reimplemented in CAS_PGTStorage_Db, and CAS_PGTStorage_File.

Definition at line 178 of file AbstractStorage.php.

179 {
180 $this->_initialized = true;
181 }

◆ isInitialized()

CAS_PGTStorage_AbstractStorage::isInitialized ( )

This method tells if the storage has already been intialized.

Returns
a boolean

Definition at line 168 of file AbstractStorage.php.

169 {
170 return $this->_initialized;
171 }
$_initialized
a boolean telling if the storage has already been initialized.

References CAS_PGTStorage_AbstractStorage\$_initialized.

Referenced by CAS_PGTStorage_Db\createTable(), CAS_PGTStorage_Db\init(), and CAS_PGTStorage_File\init().

+ Here is the caller graph for this function:

◆ read()

CAS_PGTStorage_AbstractStorage::read (   $pgt_iou)

This virtual method reads a PGT corresponding to a PGT Iou and deletes the corresponding storage entry.

Parameters
string$pgt_iouthe PGT iou
Returns
void
Note
Should never be called.

Reimplemented in CAS_PGTStorage_Db, and CAS_PGTStorage_File.

Definition at line 213 of file AbstractStorage.php.

214 {
215 phpCAS::error(__CLASS__ . '::' . __FUNCTION__ . '() should never be called');
216 }

References phpCAS\error().

+ Here is the call graph for this function:

◆ retrievePT()

CAS_Client::retrievePT (   $target_service,
$err_code,
$err_msg 
)

This method is used to retrieve PT's from the CAS server thanks to a PGT.

Parameters
string$target_servicethe service to ask for with the PT.
string&$err_codean error code (PHPCAS_SERVICE_OK on success).
string&$err_msgan error message (empty on success).
Returns
a Proxy Ticket, or false on error.

Definition at line 2742 of file Client.php.

2743 {
2744 // Argument validation
2745 if (gettype($target_service) != 'string') {
2746 throw new CAS_TypeMismatchException($target_service, '$target_service', 'string');
2747 }
2748
2750
2751 // by default, $err_msg is set empty and $pt to true. On error, $pt is
2752 // set to false and $err_msg to an error message. At the end, if $pt is false
2753 // and $error_msg is still empty, it is set to 'invalid response' (the most
2754 // commonly encountered error).
2755 $err_msg = '';
2756
2757 // build the URL to retrieve the PT
2758 $cas_url = $this->getServerProxyURL() . '?targetService='
2759 . urlencode($target_service) . '&pgt=' . $this->_getPGT();
2760
2761 // open and read the URL
2762 if (!$this->_readURL($cas_url, $headers, $cas_response, $err_msg)) {
2764 'could not open URL \'' . $cas_url . '\' to validate (' . $err_msg . ')'
2765 );
2766 $err_code = PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE;
2767 $err_msg = 'could not retrieve PT (no response from the CAS server)';
2768 phpCAS::traceEnd(false);
2769 return false;
2770 }
2771
2772 $bad_response = false;
2773
2774 if (!$bad_response) {
2775 // create new DOMDocument object
2776 $dom = new DOMDocument();
2777 // Fix possible whitspace problems
2778 $dom->preserveWhiteSpace = false;
2779 // read the response of the CAS server into a DOM object
2780 if (!($dom->loadXML($cas_response))) {
2781 phpCAS::trace('dom->loadXML() failed');
2782 // read failed
2783 $bad_response = true;
2784 }
2785 }
2786
2787 if (!$bad_response) {
2788 // read the root node of the XML tree
2789 if (!($root = $dom->documentElement)) {
2790 phpCAS::trace('documentElement failed');
2791 // read failed
2792 $bad_response = true;
2793 }
2794 }
2795
2796 if (!$bad_response) {
2797 // insure that tag name is 'serviceResponse'
2798 if ($root->localName != 'serviceResponse') {
2799 phpCAS::trace('localName failed');
2800 // bad root node
2801 $bad_response = true;
2802 }
2803 }
2804
2805 if (!$bad_response) {
2806 // look for a proxySuccess tag
2807 if ($root->getElementsByTagName("proxySuccess")->length != 0) {
2808 $proxy_success_list = $root->getElementsByTagName("proxySuccess");
2809
2810 // authentication succeded, look for a proxyTicket tag
2811 if ($proxy_success_list->item(0)->getElementsByTagName("proxyTicket")->length != 0) {
2812 $err_code = PHPCAS_SERVICE_OK;
2813 $err_msg = '';
2814 $pt = trim(
2815 $proxy_success_list->item(0)->getElementsByTagName("proxyTicket")->item(0)->nodeValue
2816 );
2817 phpCAS::trace('original PT: ' . trim($pt));
2818 phpCAS::traceEnd($pt);
2819 return $pt;
2820 } else {
2821 phpCAS::trace('<proxySuccess> was found, but not <proxyTicket>');
2822 }
2823 } elseif ($root->getElementsByTagName("proxyFailure")->length != 0) {
2824 // look for a proxyFailure tag
2825 $proxy_failure_list = $root->getElementsByTagName("proxyFailure");
2826
2827 // authentication failed, extract the error
2828 $err_code = PHPCAS_SERVICE_PT_FAILURE;
2829 $err_msg = 'PT retrieving failed (code=`'
2830 . $proxy_failure_list->item(0)->getAttribute('code')
2831 . '\', message=`'
2832 . trim($proxy_failure_list->item(0)->nodeValue)
2833 . '\')';
2834 phpCAS::traceEnd(false);
2835 return false;
2836 } else {
2837 phpCAS::trace('neither <proxySuccess> nor <proxyFailure> found');
2838 }
2839 }
2840
2841 // at this step, we are sure that the response of the CAS server was
2842 // illformed
2843 $err_code = PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE;
2844 $err_msg = 'Invalid response from the CAS server (response=`'
2845 . $cas_response . '\')';
2846
2847 phpCAS::traceEnd(false);
2848 return false;
2849 }
Licensed to Jasig under one or more contributor license agreements.
getServerProxyURL()
This method is used to retrieve the proxy URL of the CAS server.
Definition: Client.php:527
_readURL($url, &$headers, &$body, &$err_msg)
This method is used to acces a remote URL.
Definition: Client.php:2875
_getPGT()
This method returns the Proxy Granting Ticket given by the CAS server.
Definition: Client.php:2331

References CAS_Client\_getPGT(), CAS_Client\_readURL(), CAS_Client\getServerProxyURL(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by CAS_Client\initializeProxiedService().

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

◆ setErrorMessage()

CAS_PGTStorage_AbstractStorage::setErrorMessage (   $error_message)

This method sets en error message, which can be read later by PGTStorage::getErrorMessage().

Parameters
string$error_messagean error message
Returns
void
Deprecated:
not used.

Definition at line 131 of file AbstractStorage.php.

132 {
133 $this->_error_message = $error_message;
134 }

◆ setPGTStorage()

CAS_Client::setPGTStorage (   $storage)

This method can be used to set a custom PGT storage object.

Parameters
CAS_PGTStorage_AbstractStorage$storagea PGT storage object that inherits from the CAS_PGTStorage_AbstractStorage class
Returns
void

Definition at line 2567 of file Client.php.

2568 {
2569 // Sequence validation
2570 $this->ensureIsProxy();
2571
2572 // check that the storage has not already been set
2573 if (is_object($this->_pgt_storage)) {
2574 phpCAS::error('PGT storage already defined');
2575 }
2576
2577 // check to make sure a valid storage object was specified
2578 if (!($storage instanceof CAS_PGTStorage_AbstractStorage)) {
2579 throw new CAS_TypeMismatchException($storage, '$storage', 'CAS_PGTStorage_AbstractStorage object');
2580 }
2581
2582 // store the PGTStorage object
2583 $this->_pgt_storage = $storage;
2584 }
Basic class for PGT storage The CAS_PGTStorage_AbstractStorage class is a generic class for PGT stora...
ensureIsProxy()
Ensure that this is actually a proxy object or fail with an exception.
Definition: Client.php:754

References CAS_Client\ensureIsProxy(), and phpCAS\error().

Referenced by CAS_Client\setPGTStorageDb(), and CAS_Client\setPGTStorageFile().

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

◆ setPGTStorageDb()

CAS_Client::setPGTStorageDb (   $dsn_or_pdo,
  $username = '',
  $password = '',
  $table = '',
  $driver_options = null 
)

This method is used to tell phpCAS to store the response of the CAS server to PGT requests in a database.

Parameters
string$dsn_or_pdoa dsn string to use for creating a PDO object or a PDO object
string$usernamethe username to use when connecting to the database
string$passwordthe password to use when connecting to the database
string$tablethe table to use for storing and retrieving PGTs
string$driver_optionsany driver options to use when connecting to the database
Returns
void

Definition at line 2603 of file Client.php.

2609 {
2610 // Sequence validation
2611 $this->ensureIsProxy();
2612
2613 // Argument validation
2614 if ((is_object($dsn_or_pdo) && !($dsn_or_pdo instanceof PDO)) || gettype($dsn_or_pdo) != 'string') {
2615 throw new CAS_TypeMismatchException($dsn_or_pdo, '$dsn_or_pdo', 'string or PDO object');
2616 }
2617 if (gettype($username) != 'string') {
2618 throw new CAS_TypeMismatchException($username, '$username', 'string');
2619 }
2620 if (gettype($password) != 'string') {
2621 throw new CAS_TypeMismatchException($password, '$password', 'string');
2622 }
2623 if (gettype($table) != 'string') {
2624 throw new CAS_TypeMismatchException($table, '$password', 'string');
2625 }
2626
2627 // create the storage object
2628 $this->setPGTStorage(
2630 $this,
2631 $dsn_or_pdo,
2632 $username,
2633 $password,
2634 $table,
2635 $driver_options
2636 )
2637 );
2638 }
Basic class for PGT database storage The CAS_PGTStorage_Db class is a class for PGT database storage.
Definition: Db.php:47
$password
Definition: cron.php:14
setPGTStorage($storage)
This method can be used to set a custom PGT storage object.
Definition: Client.php:2567
if(empty($password)) $table
Definition: pwgen.php:24

References $password, $table, CAS_Client\ensureIsProxy(), and CAS_Client\setPGTStorage().

+ Here is the call graph for this function:

◆ setPGTStorageFile()

CAS_Client::setPGTStorageFile (   $path = '')

This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem.

Parameters
string$paththe path where the PGT's should be stored
Returns
void

Definition at line 2648 of file Client.php.

2649 {
2650 // Sequence validation
2651 $this->ensureIsProxy();
2652
2653 // Argument validation
2654 if (gettype($path) != 'string') {
2655 throw new CAS_TypeMismatchException($path, '$path', 'string');
2656 }
2657
2658 // create the storage object
2659 $this->setPGTStorage(new CAS_PGTStorage_File($this, $path));
2660 }
$path
Definition: aliased.php:25
The CAS_PGTStorage_File class is a class for PGT file storage.
Definition: File.php:46

References $path, CAS_Client\ensureIsProxy(), and CAS_Client\setPGTStorage().

Referenced by CAS_Client\_initPGTStorage().

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

◆ write()

CAS_PGTStorage_AbstractStorage::write (   $pgt,
  $pgt_iou 
)

This virtual method stores a PGT and its corresponding PGT Iuo.

Parameters
string$pgtthe PGT
string$pgt_iouthe PGT iou
Returns
void
Note
Should never be called.

Reimplemented in CAS_PGTStorage_Db, and CAS_PGTStorage_File.

Definition at line 198 of file AbstractStorage.php.

199 {
200 phpCAS::error(__CLASS__ . '::' . __FUNCTION__ . '() should never be called');
201 }

References phpCAS\error().

+ Here is the call graph for this function:

Variable Documentation

◆ $_error_message

CAS_PGTStorage_AbstractStorage::$_error_message

string used to store an error message.

Written by PGTStorage::setErrorMessage(), read by PGTStorage::getErrorMessage().

Deprecated:
not used.

Definition at line 119 of file AbstractStorage.php.

Referenced by CAS_PGTStorage_AbstractStorage\getErrorMessage().

◆ $_initialized

CAS_PGTStorage_AbstractStorage::$_initialized

a boolean telling if the storage has already been initialized.

Written by PGTStorage::init(), read by PGTStorage::isInitialized().

Definition at line 159 of file AbstractStorage.php.

Referenced by CAS_PGTStorage_AbstractStorage\isInitialized().

◆ $_pgt_storage

CAS_Client::$_pgt_storage
private

an instance of a class inheriting of PGTStorage, used to deal with PGT storage.

Created by CAS_Client::setPGTStorageFile(), used by CAS_Client::setPGTStorageFile() and CAS_Client::_initPGTStorage().

Definition at line 2508 of file Client.php.