web/lib/Zend/OpenId/Extension.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Zend Framework
       
     5  *
       
     6  * LICENSE
       
     7  *
       
     8  * This source file is subject to the new BSD license that is bundled
       
     9  * with this package in the file LICENSE.txt.
       
    10  * It is also available through the world-wide-web at this URL:
       
    11  * http://framework.zend.com/license/new-bsd
       
    12  * If you did not receive a copy of the license and are unable to
       
    13  * obtain it through the world-wide-web, please send an email
       
    14  * to license@zend.com so we can send you a copy immediately.
       
    15  *
       
    16  * @category   Zend
       
    17  * @package    Zend_OpenId
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Extension.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * Abstract extension class for Zend_OpenId
       
    25  *
       
    26  * @category   Zend
       
    27  * @package    Zend_OpenId
       
    28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    30  */
       
    31 abstract class Zend_OpenId_Extension
       
    32 {
       
    33 
       
    34     /**
       
    35      * Calls given function with given argument for all extensions
       
    36      *
       
    37      * @param mixed $extensions list of extensions or one extension
       
    38      * @param string $func function to be called
       
    39      * @param mixed &$params argument to pass to given funcion
       
    40      * @return bool
       
    41      */
       
    42     static public function forAll($extensions, $func, &$params)
       
    43     {
       
    44         if ($extensions !== null) {
       
    45             if (is_array($extensions)) {
       
    46                 foreach ($extensions as $ext) {
       
    47                     if ($ext instanceof Zend_OpenId_Extension) {
       
    48                         if (!$ext->$func($params)) {
       
    49                             return false;
       
    50                         }
       
    51                     } else {
       
    52                         return false;
       
    53                     }
       
    54                 }
       
    55             } else if (!is_object($extensions) ||
       
    56                        !($extensions instanceof Zend_OpenId_Extension) ||
       
    57                        !$extensions->$func($params)) {
       
    58                 return false;
       
    59             }
       
    60         }
       
    61         return true;
       
    62     }
       
    63 
       
    64     /**
       
    65      * Method to add additional data to OpenId 'checkid_immediate' or
       
    66      * 'checkid_setup' request. This method addes nothing but inherited class
       
    67      * may add additional data into request.
       
    68      *
       
    69      * @param array &$params request's var/val pairs
       
    70      * @return bool
       
    71      */
       
    72     public function prepareRequest(&$params)
       
    73     {
       
    74         return true;
       
    75     }
       
    76 
       
    77     /**
       
    78      * Method to parse OpenId 'checkid_immediate' or 'checkid_setup' request
       
    79      * and initialize object with passed data. This method parses nothing but
       
    80      * inherited class may override this method to do somthing.
       
    81      *
       
    82      * @param array $params request's var/val pairs
       
    83      * @return bool
       
    84      */
       
    85     public function parseRequest($params)
       
    86     {
       
    87         return true;
       
    88     }
       
    89 
       
    90     /**
       
    91      * Method to add additional data to OpenId 'id_res' response. This method
       
    92      * addes nothing but inherited class may add additional data into response.
       
    93      *
       
    94      * @param array &$params response's var/val pairs
       
    95      * @return bool
       
    96      */
       
    97     public function prepareResponse(&$params)
       
    98     {
       
    99         return true;
       
   100     }
       
   101 
       
   102     /**
       
   103      * Method to parse OpenId 'id_res' response and initialize object with
       
   104      * passed data. This method parses nothing but inherited class may override
       
   105      * this method to do somthing.
       
   106      *
       
   107      * @param array $params response's var/val pairs
       
   108      * @return bool
       
   109      */
       
   110     public function parseResponse($params)
       
   111     {
       
   112         return true;
       
   113     }
       
   114 
       
   115     /**
       
   116      * Method to prepare data to store it in trusted servers database.
       
   117      *
       
   118      * @param array &$data data to be stored in tusted servers database
       
   119      * @return bool
       
   120      */
       
   121     public function getTrustData(&$data)
       
   122     {
       
   123         return true;
       
   124     }
       
   125 
       
   126     /**
       
   127      * Method to check if data from trusted servers database is enough to
       
   128      * sutisfy request.
       
   129      *
       
   130      * @param array $data data from tusted servers database
       
   131      * @return bool
       
   132      */
       
   133     public function checkTrustData($data)
       
   134     {
       
   135         return true;
       
   136     }
       
   137 }