GetTokensResponse.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_Service
  17. * @subpackage DeveloperGarden
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Service_DeveloperGarden_Response_ResponseAbstract
  24. */
  25. require_once 'Zend/Service/DeveloperGarden/Response/ResponseAbstract.php';
  26. /**
  27. * @see Zend_Service_DeveloperGarden_Response_SecurityTokenServer_Interface
  28. */
  29. require_once 'Zend/Service/DeveloperGarden/Response/SecurityTokenServer/Interface.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Service
  33. * @subpackage DeveloperGarden
  34. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @author Marco Kaiser
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse
  39. extends Zend_Service_DeveloperGarden_Response_ResponseAbstract
  40. implements Zend_Service_DeveloperGarden_Response_SecurityTokenServer_Interface
  41. {
  42. /**
  43. * the security token
  44. * @var Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse
  45. */
  46. public $securityToken = null;
  47. /**
  48. * returns the security token
  49. *
  50. * @return string
  51. */
  52. public function getTokenData()
  53. {
  54. return $this->getSecurityToken();
  55. }
  56. /**
  57. * returns the security token
  58. *
  59. * @return string
  60. */
  61. public function getSecurityToken()
  62. {
  63. if (!$this->securityToken instanceof Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse) {
  64. require_once 'Zend/Service/DeveloperGarden/Response/SecurityTokenServer/Exception.php';
  65. throw new Zend_Service_DeveloperGarden_Response_SecurityTokenServer_Exception(
  66. 'No valid securityToken found.'
  67. );
  68. }
  69. return $this->securityToken->getTokenData();
  70. }
  71. /**
  72. * returns true if the stored token data is valid
  73. *
  74. * @return boolean
  75. */
  76. public function isValid()
  77. {
  78. /**
  79. * @todo implement the true token validation check
  80. */
  81. if (isset($this->securityToken)
  82. && !empty($this->securityToken->tokenData)
  83. ) {
  84. return true;
  85. }
  86. return false;
  87. }
  88. }