2
0

Abstract.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 Amazon
  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_Abstract
  24. */
  25. require_once 'Zend/Service/Abstract.php';
  26. /**
  27. * Abstract Amazon class that handles the credentials for any of the Web Services that
  28. * Amazon offers
  29. *
  30. * @category Zend
  31. * @package Zend_Service
  32. * @subpackage Amazon
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. abstract class Zend_Service_Amazon_Abstract extends Zend_Service_Abstract
  37. {
  38. /**
  39. * @var string Amazon Access Key
  40. */
  41. protected static $_defaultAccessKey = null;
  42. /**
  43. * @var string Amazon Secret Key
  44. */
  45. protected static $_defaultSecretKey = null;
  46. /**
  47. * @var string Amazon Secret Key
  48. */
  49. protected $_secretKey;
  50. /**
  51. * @var string Amazon Access Key
  52. */
  53. protected $_accessKey;
  54. /**
  55. * Set the keys to use when accessing SQS.
  56. *
  57. * @param string $access_key Set the default Access Key
  58. * @param string $secret_key Set the default Secret Key
  59. * @return void
  60. */
  61. public static function setKeys($accessKey, $secretKey)
  62. {
  63. self::$_defaultAccessKey = $accessKey;
  64. self::$_defaultSecretKey = $secretKey;
  65. }
  66. /**
  67. * Create Amazon client.
  68. *
  69. * @param string $access_key Override the default Access Key
  70. * @param string $secret_key Override the default Secret Key
  71. * @return void
  72. */
  73. public function __construct($accessKey=null, $secretKey=null)
  74. {
  75. if(!$accessKey) {
  76. $accessKey = self::$_defaultAccessKey;
  77. }
  78. if(!$secretKey) {
  79. $secretKey = self::$_defaultSecretKey;
  80. }
  81. if(!$accessKey || !$secretKey) {
  82. require_once 'Zend/Service/Amazon/Exception.php';
  83. throw new Zend_Service_Amazon_Exception("AWS keys were not supplied");
  84. }
  85. $this->_accessKey = $accessKey;
  86. $this->_secretKey = $secretKey;
  87. }
  88. /**
  89. * Method to fetch the Access Key
  90. *
  91. * @return string
  92. */
  93. protected function _getAccessKey()
  94. {
  95. return $this->_accessKey;
  96. }
  97. /**
  98. * Method to fetch the Secret AWS Key
  99. *
  100. * @return string
  101. */
  102. protected function _getSecretKey()
  103. {
  104. return $this->_secretKey;
  105. }
  106. }