| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of the tiqr project. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * The tiqr project aims to provide an open implementation for  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * authentication using mobile devices. It was initiated by  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * SURFnet and developed by Egeniq. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * More information: http://www.tiqr.org | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @author Ivo Jansch <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package tiqr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @license New BSD License - See LICENSE file for details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @copyright (C) 2010-2011 SURFnet BV | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Psr\Log\LoggerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * The Abstract base class for all StateStorage implementations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * StateStorages are meant to store the information that is used in the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * enrollment and authentication processes, or to keep track of whether | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * a user is logged in. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @author ivo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | abstract class Tiqr_StateStorage_Abstract implements Tiqr_StateStorage_StateStorageInterface, Tiqr_HealthCheck_Interface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * The options for the storage. Derived classes can access this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * to retrieve options configured for the state storage. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     protected array $_options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var LoggerInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     protected LoggerInterface $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * An initializer that will be called directly after instantiating | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * the storage. Derived classes can override this to perform  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * initialization of the storage. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * Note: this method is ont abstract since not every derived class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * will want to implement this. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 2 |  |     public function init(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 2 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * The constructor to construct a state storage instance. Should not be | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * called directly, use the Tiqr_StateStorage factory to construct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * a state storage instance of a certain type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @param array $options An array of options for the state storage | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     public function __construct(array $options, LoggerInterface $logger) | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         $this->logger = $logger; | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         $this->_options = $options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @see Tiqr_HealthCheck_Interface::healthCheck() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function healthCheck(string &$statusMessage = ''): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         return true;    // Health check is always successful when not implemented | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 76 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |  |