Extension.php 3.9 KB

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