pgt-main.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /*
  3. * Copyright © 2003-2010, The ESUP-Portail consortium & the JA-SIG Collaborative.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. * * Neither the name of the ESUP-Portail consortium & the JA-SIG
  15. * Collaborative nor the names of its contributors may be used to endorse or
  16. * promote products derived from this software without specific prior
  17. * written permission.
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  22. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  25. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. /**
  30. * @file CAS/PGTStorage/pgt-main.php
  31. * Basic class for PGT storage
  32. */
  33. /**
  34. * @class PGTStorage
  35. * The PGTStorage class is a generic class for PGT storage. This class should
  36. * not be instanciated itself but inherited by specific PGT storage classes.
  37. *
  38. * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
  39. *
  40. * @ingroup internalPGTStorage
  41. */
  42. class PGTStorage
  43. {
  44. /**
  45. * @addtogroup internalPGTStorage
  46. * @{
  47. */
  48. // ########################################################################
  49. // CONSTRUCTOR
  50. // ########################################################################
  51. /**
  52. * The constructor of the class, should be called only by inherited classes.
  53. *
  54. * @param $cas_parent the CASclient instance that creates the current object.
  55. *
  56. * @protected
  57. */
  58. function PGTStorage($cas_parent)
  59. {
  60. phpCAS::traceBegin();
  61. if ( !$cas_parent->isProxy() ) {
  62. phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
  63. }
  64. phpCAS::traceEnd();
  65. }
  66. // ########################################################################
  67. // DEBUGGING
  68. // ########################################################################
  69. /**
  70. * This virtual method returns an informational string giving the type of storage
  71. * used by the object (used for debugging purposes).
  72. *
  73. * @public
  74. */
  75. function getStorageType()
  76. {
  77. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  78. }
  79. /**
  80. * This virtual method returns an informational string giving informations on the
  81. * parameters of the storage.(used for debugging purposes).
  82. *
  83. * @public
  84. */
  85. function getStorageInfo()
  86. {
  87. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  88. }
  89. // ########################################################################
  90. // ERROR HANDLING
  91. // ########################################################################
  92. /**
  93. * string used to store an error message. Written by PGTStorage::setErrorMessage(),
  94. * read by PGTStorage::getErrorMessage().
  95. *
  96. * @hideinitializer
  97. * @private
  98. * @deprecated not used.
  99. */
  100. var $_error_message=FALSE;
  101. /**
  102. * This method sets en error message, which can be read later by
  103. * PGTStorage::getErrorMessage().
  104. *
  105. * @param $error_message an error message
  106. *
  107. * @protected
  108. * @deprecated not used.
  109. */
  110. function setErrorMessage($error_message)
  111. {
  112. $this->_error_message = $error_message;
  113. }
  114. /**
  115. * This method returns an error message set by PGTStorage::setErrorMessage().
  116. *
  117. * @return boolean error message when set by PGTStorage::setErrorMessage(), FALSE
  118. * otherwise.
  119. *
  120. * @public
  121. * @deprecated not used.
  122. */
  123. function getErrorMessage()
  124. {
  125. return $this->_error_message;
  126. }
  127. // ########################################################################
  128. // INITIALIZATION
  129. // ########################################################################
  130. /**
  131. * a boolean telling if the storage has already been initialized. Written by
  132. * PGTStorage::init(), read by PGTStorage::isInitialized().
  133. *
  134. * @hideinitializer
  135. * @private
  136. */
  137. var $_initialized = FALSE;
  138. /**
  139. * This method tells if the storage has already been intialized.
  140. *
  141. * @return boolean boolean
  142. *
  143. * @protected
  144. */
  145. function isInitialized()
  146. {
  147. return $this->_initialized;
  148. }
  149. /**
  150. * This virtual method initializes the object.
  151. *
  152. * @protected
  153. */
  154. function init()
  155. {
  156. $this->_initialized = TRUE;
  157. }
  158. // ########################################################################
  159. // PGT I/O
  160. // ########################################################################
  161. /**
  162. * This virtual method stores a PGT and its corresponding PGT Iuo.
  163. * @note Should never be called.
  164. *
  165. * @param $pgt the PGT
  166. * @param $pgt_iou the PGT iou
  167. *
  168. * @protected
  169. */
  170. function write($pgt,$pgt_iou)
  171. {
  172. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  173. }
  174. /**
  175. * This virtual method reads a PGT corresponding to a PGT Iou and deletes
  176. * the corresponding storage entry.
  177. * @note Should never be called.
  178. *
  179. * @param $pgt_iou the PGT iou
  180. *
  181. * @protected
  182. */
  183. function read($pgt_iou)
  184. {
  185. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  186. }
  187. /** @} */
  188. }
  189. // include specific PGT storage classes
  190. include_once __DIR__.'/pgt-file.php';
  191. include_once __DIR__.'/pgt-db.php';
  192. ?>