AbstractStorage.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /**
  3. * Licensed to Jasig under one or more contributor license
  4. * agreements. See the NOTICE file distributed with this work for
  5. * additional information regarding copyright ownership.
  6. *
  7. * Jasig licenses this file to you under the Apache License,
  8. * Version 2.0 (the "License"); you may not use this file except in
  9. * compliance with the License. You may obtain a copy of the License at:
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * PHP Version 5
  20. *
  21. * @file CAS/PGTStorage/AbstractStorage.php
  22. * @category Authentication
  23. * @package PhpCAS
  24. * @author Pascal Aubry <pascal.aubry@univ-rennes1.fr>
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  26. * @link https://wiki.jasig.org/display/CASC/phpCAS
  27. */
  28. /**
  29. * Basic class for PGT storage
  30. * The CAS_PGTStorage_AbstractStorage class is a generic class for PGT storage.
  31. * This class should not be instanciated itself but inherited by specific PGT
  32. * storage classes.
  33. *
  34. * @class CAS_PGTStorage_AbstractStorage
  35. * @category Authentication
  36. * @package PhpCAS
  37. * @author Pascal Aubry <pascal.aubry@univ-rennes1.fr>
  38. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  39. * @link https://wiki.jasig.org/display/CASC/phpCAS
  40. *
  41. * @ingroup internalPGTStorage
  42. */
  43. abstract class CAS_PGTStorage_AbstractStorage
  44. {
  45. /**
  46. * @addtogroup internalPGTStorage
  47. * @{
  48. */
  49. // ########################################################################
  50. // CONSTRUCTOR
  51. // ########################################################################
  52. /**
  53. * The constructor of the class, should be called only by inherited classes.
  54. *
  55. * @param CAS_Client $cas_parent the CAS _client instance that creates the
  56. * current object.
  57. *
  58. * @return void
  59. *
  60. * @protected
  61. */
  62. function __construct($cas_parent)
  63. {
  64. phpCAS::traceBegin();
  65. if ( !$cas_parent->isProxy() ) {
  66. phpCAS::error(
  67. 'defining PGT storage makes no sense when not using a CAS proxy'
  68. );
  69. }
  70. phpCAS::traceEnd();
  71. }
  72. // ########################################################################
  73. // DEBUGGING
  74. // ########################################################################
  75. /**
  76. * This virtual method returns an informational string giving the type of storage
  77. * used by the object (used for debugging purposes).
  78. *
  79. * @return string
  80. *
  81. * @public
  82. */
  83. function getStorageType()
  84. {
  85. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  86. }
  87. /**
  88. * This virtual method returns an informational string giving informations on the
  89. * parameters of the storage.(used for debugging purposes).
  90. *
  91. * @return string
  92. *
  93. * @public
  94. */
  95. function getStorageInfo()
  96. {
  97. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  98. }
  99. // ########################################################################
  100. // ERROR HANDLING
  101. // ########################################################################
  102. /**
  103. * string used to store an error message. Written by
  104. * PGTStorage::setErrorMessage(), read by PGTStorage::getErrorMessage().
  105. *
  106. * @hideinitializer
  107. * @deprecated not used.
  108. */
  109. var $_error_message=false;
  110. /**
  111. * This method sets en error message, which can be read later by
  112. * PGTStorage::getErrorMessage().
  113. *
  114. * @param string $error_message an error message
  115. *
  116. * @return void
  117. *
  118. * @deprecated not used.
  119. */
  120. function setErrorMessage($error_message)
  121. {
  122. $this->_error_message = $error_message;
  123. }
  124. /**
  125. * This method returns an error message set by PGTStorage::setErrorMessage().
  126. *
  127. * @return string an error message when set by PGTStorage::setErrorMessage(), FALSE
  128. * otherwise.
  129. *
  130. * @deprecated not used.
  131. */
  132. function getErrorMessage()
  133. {
  134. return $this->_error_message;
  135. }
  136. // ########################################################################
  137. // INITIALIZATION
  138. // ########################################################################
  139. /**
  140. * a boolean telling if the storage has already been initialized. Written by
  141. * PGTStorage::init(), read by PGTStorage::isInitialized().
  142. *
  143. * @hideinitializer
  144. */
  145. var $_initialized = false;
  146. /**
  147. * This method tells if the storage has already been intialized.
  148. *
  149. * @return bool
  150. *
  151. * @protected
  152. */
  153. function isInitialized()
  154. {
  155. return $this->_initialized;
  156. }
  157. /**
  158. * This virtual method initializes the object.
  159. *
  160. * @return void
  161. */
  162. function init()
  163. {
  164. $this->_initialized = true;
  165. }
  166. // ########################################################################
  167. // PGT I/O
  168. // ########################################################################
  169. /**
  170. * This virtual method stores a PGT and its corresponding PGT Iuo.
  171. *
  172. * @param string $pgt the PGT
  173. * @param string $pgt_iou the PGT iou
  174. *
  175. * @return void
  176. *
  177. * @note Should never be called.
  178. *
  179. */
  180. function write($pgt,$pgt_iou)
  181. {
  182. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  183. }
  184. /**
  185. * This virtual method reads a PGT corresponding to a PGT Iou and deletes
  186. * the corresponding storage entry.
  187. *
  188. * @param string $pgt_iou the PGT iou
  189. *
  190. * @return string
  191. *
  192. * @note Should never be called.
  193. */
  194. function read($pgt_iou)
  195. {
  196. phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
  197. }
  198. /** @} */
  199. }
  200. ?>