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

Namespaces

 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.

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

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  if (!preg_match('`^[a-zA-Z]:`', $path)) {
127  phpCAS::error('an absolute path is needed for PGT storage to file');
128  }
129  } else {
130  if ($path[0] != '/') {
131  phpCAS::error('an absolute path is needed for PGT storage to file');
132  }
133 
134  // store the path (with a leading and trailing '/')
135  $path = preg_replace('|[/]*$|', '/', $path);
136  $path = preg_replace('|^[/]*|', '/', $path);
137  }
138 
139  $this->_path = $path;
141  }
$path
Definition: aliased.php:25
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
const CAS_PGT_STORAGE_FILE_DEFAULT_PATH
Default path used when storing PGT's to file.
Definition: CAS.php:155
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
+ Here is the call graph for this function:

◆ getPath()

CAS_PGTStorage_File::getPath ( )

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.

References CAS_PGTStorage_File\$_path.

Referenced by CAS_PGTStorage_File\getPGTIouFilename(), and CAS_PGTStorage_File\getStorageInfo().

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

◆ getPGTIouFilename()

CAS_PGTStorage_File::getPGTIouFilename (   $pgt_iou)

This method returns the filename corresponding to a PGT Iou.

Parameters
string$pgt_iouthe PGT iou.
Returns
a filename

Definition at line 177 of file File.php.

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

178  {
180  $filename = $this->getPath() . "phpcas-" . hash("sha256", $pgt_iou);
181 // $filename = $this->getPath().$pgt_iou.'.plain';
182  phpCAS::trace("Sha256 filename:" . $filename);
184  return $filename;
185  }
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 trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
getPath()
This method returns the name of the directory where PGT's should be stored on the filesystem...
Definition: File.php:68
$filename
Definition: buildRTE.php:89
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:611
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Definition: functions.php:406
+ 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.

Definition at line 96 of file File.php.

References CAS_PGTStorage_File\getPath().

97  {
98  return 'path=`' . $this->getPath() . '\'';
99  }
getPath()
This method returns the name of the directory where PGT's should be stored on the filesystem...
Definition: File.php:68
+ Here is the call graph for this function:

◆ 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.

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

Definition at line 153 of file File.php.

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

154  {
156  // if the storage has already been initialized, return immediatly
157  if ($this->isInitialized()) {
158  return;
159  }
160  // call the ancestor's method (mark as initialized)
161  parent::init();
163  }
isInitialized()
This method tells if the storage has already been intialized.
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
while(count($oldTaskList) > 0) foreach(array_keys($newTaskList) as $task) init()
Definition: build.php:77
+ 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

Definition at line 231 of file File.php.

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

232  {
234  $pgt = false;
235  $fname = $this->getPGTIouFilename($pgt_iou);
236  if (file_exists($fname)) {
237  if (!($f = fopen($fname, "r"))) {
238  phpCAS::error('could not open `' . $fname . '\'');
239  } else {
240  if (($pgt = fgets($f)) === false) {
241  phpCAS::error('could not read PGT from `' . $fname . '\'');
242  }
243  phpCAS::trace('Successful read of PGT to `' . $fname . '\'');
244  fclose($f);
245  }
246  // delete the PGT file
247  @unlink($fname);
248  } else {
249  phpCAS::error('No such file `' . $fname . '\'');
250  }
251  phpCAS::traceEnd($pgt);
252  return $pgt;
253  }
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
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 trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:611
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: File.php:177
+ 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

Definition at line 198 of file File.php.

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

199  {
201  $fname = $this->getPGTIouFilename($pgt_iou);
202  if (!file_exists($fname)) {
203  touch($fname);
204  // Chmod will fail on windows
205  @chmod($fname, 0600);
206  if ($f = fopen($fname, "w")) {
207  if (fputs($f, $pgt) === false) {
208  phpCAS::error('could not write PGT to `' . $fname . '\'');
209  }
210  phpCAS::trace('Successful write of PGT to `' . $fname . '\'');
211  fclose($f);
212  } else {
213  phpCAS::error('could not open `' . $fname . '\'');
214  }
215  } else {
216  phpCAS::error('File exists: `' . $fname . '\'');
217  }
219  }
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
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 trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:611
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: File.php:177
+ Here is the call graph for this function:

Variable Documentation

◆ $_path

CAS_PGTStorage_File::$_path

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