SecurityTokenServer.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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-2014 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_SecurityTokenServer_Cache
  24. */
  25. require_once 'Zend/Service/DeveloperGarden/SecurityTokenServer/Cache.php';
  26. /**
  27. * @see Zend_Service_DeveloperGarden_Client_ClientAbstract
  28. */
  29. require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
  30. /**
  31. * @see Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse
  32. */
  33. require_once 'Zend/Service/DeveloperGarden/Response/SecurityTokenServer/SecurityTokenResponse.php';
  34. /**
  35. * @see Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse
  36. */
  37. require_once 'Zend/Service/DeveloperGarden/Response/SecurityTokenServer/GetTokensResponse.php';
  38. /**
  39. * @category Zend
  40. * @package Zend_Service
  41. * @subpackage DeveloperGarden
  42. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @author Marco Kaiser
  44. * @license http://framework.zend.com/license/new-bsd New BSD License
  45. */
  46. class Zend_Service_DeveloperGarden_SecurityTokenServer
  47. extends Zend_Service_DeveloperGarden_Client_ClientAbstract
  48. {
  49. /**
  50. * wsdl file
  51. *
  52. * @var string
  53. */
  54. protected $_wsdlFile = 'https://sts.idm.telekom.com/TokenService?wsdl';
  55. /**
  56. * wsdl file local
  57. *
  58. * @var string
  59. */
  60. protected $_wsdlFileLocal = 'Wsdl/TokenService.wsdl';
  61. /**
  62. * Response, Request Classmapping
  63. *
  64. * @var array
  65. *
  66. */
  67. protected $_classMap = array(
  68. 'SecurityTokenResponse' => 'Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse',
  69. 'getTokensResponse' => 'Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse'
  70. );
  71. /**
  72. * does the login and return the specific response
  73. *
  74. * @return Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse
  75. */
  76. public function getLoginToken()
  77. {
  78. $token = Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::getTokenFromCache(
  79. 'securityToken'
  80. );
  81. if ($token === null
  82. || !$token->isValid()
  83. ) {
  84. $token = $this->getSoapClient()->login('login');
  85. Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::setTokenToCache(
  86. 'securityToken',
  87. $token
  88. );
  89. }
  90. return $token;
  91. }
  92. /**
  93. * returns the fetched token from token server
  94. *
  95. * @return Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse
  96. */
  97. public function getTokens()
  98. {
  99. $token = Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::getTokenFromCache(
  100. 'getTokens'
  101. );
  102. if ($token === null
  103. || !$token->isValid()
  104. ) {
  105. $token = $this->getSoapClient()->getTokens(array(
  106. 'serviceId' => $this->_serviceAuthId
  107. ));
  108. Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::setTokenToCache(
  109. 'getTokens',
  110. $token
  111. );
  112. }
  113. return $token;
  114. }
  115. }