Search moodle.org's
Developer Documentation

See Release Notes

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