ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
+ Collaboration diagram for PGT storage on the filesystem:

Namespaces

namespace  PhpCAS
 

Functions

 CAS_PGTStorage_File::getPath ()
 This method returns the name of the directory where PGT's should be stored on the filesystem. More...
 
 CAS_PGTStorage_File::getStorageType ()
 This method returns an informational string giving the type of storage used by the object (used for debugging purposes). More...
 
 CAS_PGTStorage_File::getStorageInfo ()
 This method returns an informational string giving informations on the parameters of the storage. More...
 
 CAS_PGTStorage_File::__construct ($cas_parent, $path)
 The class constructor, called by CAS_Client::SetPGTStorageFile(). More...
 
 CAS_PGTStorage_File::init ()
 This method is used to initialize the storage. More...
 
 CAS_PGTStorage_File::getPGTIouFilename ($pgt_iou)
 This method returns the filename corresponding to a PGT Iou. More...
 
 CAS_PGTStorage_File::write ($pgt, $pgt_iou)
 This method stores a PGT and its corresponding PGT Iou into a file. More...
 
 CAS_PGTStorage_File::read ($pgt_iou)
 This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file. More...
 

Variables

 CAS_PGTStorage_File::$_path
 a string telling where PGT's should be stored on the filesystem. More...
 

Detailed Description

Function Documentation

◆ __construct()

CAS_PGTStorage_File::__construct (   $cas_parent,
  $path 
)

The class constructor, called by CAS_Client::SetPGTStorageFile().

Parameters
CAS_Client$cas_parentthe CAS_Client instance that creates the object.
string$paththe path where the PGT's should be stored
Returns
void

Definition at line 115 of file File.php.

116 {
118 // call the ancestor's constructor
119 parent::__construct($cas_parent);
120
121 if (empty($path)) {
123 }
124 // check that the path is an absolute path
125 if (getenv("OS")=="Windows_NT") {
126
127 if (!preg_match('`^[a-zA-Z]:`', $path)) {
128 phpCAS::error('an absolute path is needed for PGT storage to file');
129 }
130
131 } else {
132
133 if ( $path[0] != '/' ) {
134 phpCAS::error('an absolute path is needed for PGT storage to file');
135 }
136
137 // store the path (with a leading and trailing '/')
138 $path = preg_replace('|[/]*$|', '/', $path);
139 $path = preg_replace('|^[/]*|', '/', $path);
140 }
141
142 $this->_path = $path;
144 }
static traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:638
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode.
Definition: CAS.php:591
static error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:543
const CAS_PGT_STORAGE_FILE_DEFAULT_PATH
Default path used when storing PGT's to file.
Definition: CAS.php:155

References $path, CAS_PGT_STORAGE_FILE_DEFAULT_PATH, phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ getPath()

CAS_PGTStorage_File::getPath ( )
private

This method returns the name of the directory where PGT's should be stored on the filesystem.

Returns
the name of a directory (with leading and trailing '/')

Definition at line 68 of file File.php.

69 {
70 return $this->_path;
71 }
$_path
a string telling where PGT's should be stored on the filesystem.
Definition: File.php:58

References CAS_PGTStorage_File\$_path.

Referenced by CAS_PGTStorage_File\getPGTIouFilename().

+ Here is the caller graph for this function:

◆ getPGTIouFilename()

CAS_PGTStorage_File::getPGTIouFilename (   $pgt_iou)
private

This method returns the filename corresponding to a PGT Iou.

Parameters
string$pgt_iouthe PGT iou.
Returns
a filename

Definition at line 180 of file File.php.

181 {
183 $filename = $this->getPath()."phpcas-".hash("sha256", $pgt_iou);
184// $filename = $this->getPath().$pgt_iou.'.plain';
185 phpCAS::trace("Sha256 filename:" . $filename);
187 return $filename;
188 }
getPath()
This method returns the name of the directory where PGT's should be stored on the filesystem.
Definition: File.php:68
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:579
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Definition: functions.php:406

References $filename, CAS_PGTStorage_File\getPath(), GuzzleHttp\Psr7\hash(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by CAS_PGTStorage_File\read(), and CAS_PGTStorage_File\write().

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

◆ getStorageInfo()

CAS_PGTStorage_File::getStorageInfo ( )

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

(used for debugging purposes).

Returns
an informational string.

Reimplemented from CAS_PGTStorage_AbstractStorage.

Definition at line 96 of file File.php.

97 {
98 return 'path=`'.$this->getPath().'\'';
99 }

◆ getStorageType()

CAS_PGTStorage_File::getStorageType ( )

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

Returns
an informational string.

Reimplemented from CAS_PGTStorage_AbstractStorage.

Definition at line 84 of file File.php.

85 {
86 return "file";
87 }

◆ init()

CAS_PGTStorage_File::init ( )

This method is used to initialize the storage.

Halts on error.

Returns
void

Reimplemented from CAS_PGTStorage_AbstractStorage.

Definition at line 156 of file File.php.

157 {
159 // if the storage has already been initialized, return immediatly
160 if ($this->isInitialized()) {
161 return;
162 }
163 // call the ancestor's method (mark as initialized)
164 parent::init();
166 }
isInitialized()
This method tells if the storage has already been intialized.

References CAS_PGTStorage_AbstractStorage\isInitialized(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ read()

CAS_PGTStorage_File::read (   $pgt_iou)

This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file.

Parameters
string$pgt_iouthe PGT iou
Returns
the corresponding PGT, or FALSE on error

Reimplemented from CAS_PGTStorage_AbstractStorage.

Definition at line 234 of file File.php.

235 {
237 $pgt = false;
238 $fname = $this->getPGTIouFilename($pgt_iou);
239 if (file_exists($fname)) {
240 if (!($f=fopen($fname, "r"))) {
241 phpCAS::error('could not open `'.$fname.'\'');
242 } else {
243 if (($pgt=fgets($f)) === false) {
244 phpCAS::error('could not read PGT from `'.$fname.'\'');
245 }
246 phpCAS::trace('Successful read of PGT to `'.$fname.'\'');
247 fclose($f);
248 }
249 // delete the PGT file
250 @unlink($fname);
251 } else {
252 phpCAS::error('No such file `'.$fname.'\'');
253 }
254 phpCAS::traceEnd($pgt);
255 return $pgt;
256 }
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: File.php:180

References phpCAS\error(), CAS_PGTStorage_File\getPGTIouFilename(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ write()

CAS_PGTStorage_File::write (   $pgt,
  $pgt_iou 
)

This method stores a PGT and its corresponding PGT Iou into a file.

Echoes a warning on error.

Parameters
string$pgtthe PGT
string$pgt_iouthe PGT iou
Returns
void

Reimplemented from CAS_PGTStorage_AbstractStorage.

Definition at line 201 of file File.php.

202 {
204 $fname = $this->getPGTIouFilename($pgt_iou);
205 if (!file_exists($fname)) {
206 touch($fname);
207 // Chmod will fail on windows
208 @chmod($fname, 0600);
209 if ($f=fopen($fname, "w")) {
210 if (fputs($f, $pgt) === false) {
211 phpCAS::error('could not write PGT to `'.$fname.'\'');
212 }
213 phpCAS::trace('Successful write of PGT to `'.$fname.'\'');
214 fclose($f);
215 } else {
216 phpCAS::error('could not open `'.$fname.'\'');
217 }
218 } else {
219 phpCAS::error('File exists: `'.$fname.'\'');
220 }
222 }

References phpCAS\error(), CAS_PGTStorage_File\getPGTIouFilename(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

Variable Documentation

◆ $_path

CAS_PGTStorage_File::$_path
private

a string telling where PGT's should be stored on the filesystem.

Written by PGTStorageFile::PGTStorageFile(), read by getPath().

Definition at line 58 of file File.php.

Referenced by CAS_PGTStorage_File\getPath().