Upgrade phpCAS
[piwik-CASLogin.git] / CAS / CAS / PGTStorage / AbstractStorage.php
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 5
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('defining PGT storage makes no sense when not using a CAS proxy');
72         }
73         phpCAS::traceEnd();
74     }
75
76     // ########################################################################
77     //  DEBUGGING
78     // ########################################################################
79
80     /**
81      * This virtual method returns an informational string giving the type of storage
82      * used by the object (used for debugging purposes).
83      *
84      * @return void
85      *
86      * @public
87      */
88     function getStorageType()
89     {
90         phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
91     }
92
93     /**
94      * This virtual method returns an informational string giving informations on the
95      * parameters of the storage.(used for debugging purposes).
96      *
97      * @return void
98      *
99      * @public
100      */
101     function getStorageInfo()
102     {
103         phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
104     }
105
106     // ########################################################################
107     //  ERROR HANDLING
108     // ########################################################################
109
110     /**
111      * string used to store an error message. Written by
112      * PGTStorage::setErrorMessage(), read by PGTStorage::getErrorMessage().
113      *
114      * @hideinitializer
115      * @deprecated not used.
116      */
117     var $_error_message=false;
118
119     /**
120      * This method sets en error message, which can be read later by
121      * PGTStorage::getErrorMessage().
122      *
123      * @param string $error_message an error message
124      *
125      * @return void
126      *
127      * @deprecated not used.
128      */
129     function setErrorMessage($error_message)
130     {
131         $this->_error_message = $error_message;
132     }
133
134     /**
135      * This method returns an error message set by PGTStorage::setErrorMessage().
136      *
137      * @return an error message when set by PGTStorage::setErrorMessage(), FALSE
138      * otherwise.
139      *
140      * @deprecated not used.
141      */
142     function getErrorMessage()
143     {
144         return $this->_error_message;
145     }
146
147     // ########################################################################
148     //  INITIALIZATION
149     // ########################################################################
150
151     /**
152      * a boolean telling if the storage has already been initialized. Written by
153      * PGTStorage::init(), read by PGTStorage::isInitialized().
154      *
155      * @hideinitializer
156      */
157     var $_initialized = false;
158
159     /**
160      * This method tells if the storage has already been intialized.
161      *
162      * @return a boolean
163      *
164      * @protected
165      */
166     function isInitialized()
167     {
168         return $this->_initialized;
169     }
170
171     /**
172      * This virtual method initializes the object.
173      *
174      * @return void
175      */
176     function init()
177     {
178         $this->_initialized = true;
179     }
180
181     // ########################################################################
182     //  PGT I/O
183     // ########################################################################
184
185     /**
186      * This virtual method stores a PGT and its corresponding PGT Iuo.
187      *
188      * @param string $pgt     the PGT
189      * @param string $pgt_iou the PGT iou
190      *
191      * @return void
192      *
193      * @note Should never be called.
194      *
195      */
196     function write($pgt,$pgt_iou)
197     {
198         phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
199     }
200
201     /**
202      * This virtual method reads a PGT corresponding to a PGT Iou and deletes
203      * the corresponding storage entry.
204      *
205      * @param string $pgt_iou the PGT iou
206      *
207      * @return void
208      *
209      * @note Should never be called.
210      */
211     function read($pgt_iou)
212     {
213         phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called');
214     }
215
216     /** @} */
217
218 }
219
220 ?>