File indexing completed on 2024-12-22 05:37:01

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Service
0017  * @subpackage Amazon
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Service_Abstract
0025  */
0026 // require_once 'Zend/Service/Abstract.php';
0027 
0028 /**
0029  * Abstract Amazon class that handles the credentials for any of the Web Services that
0030  * Amazon offers
0031  *
0032  * @category   Zend
0033  * @package    Zend_Service
0034  * @subpackage Amazon
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 abstract class Zend_Service_Amazon_Abstract extends Zend_Service_Abstract
0039 {
0040     /**
0041      * @var string Amazon Access Key
0042      */
0043     protected static $_defaultAccessKey = null;
0044 
0045     /**
0046      * @var string Amazon Secret Key
0047      */
0048     protected static $_defaultSecretKey = null;
0049 
0050     /**
0051      * @var string Amazon Secret Key
0052      */
0053     protected $_secretKey;
0054 
0055     /**
0056      * @var string Amazon Access Key
0057      */
0058     protected $_accessKey;
0059 
0060 
0061     /**
0062      * Set the keys to use when accessing SQS.
0063      *
0064      * @param  string $access_key       Set the default Access Key
0065      * @param  string $secret_key       Set the default Secret Key
0066      * @return void
0067      */
0068     public static function setKeys($accessKey, $secretKey)
0069     {
0070         self::$_defaultAccessKey = $accessKey;
0071         self::$_defaultSecretKey = $secretKey;
0072     }
0073 
0074     /**
0075      * Create Amazon client.
0076      *
0077      * @param  string $access_key       Override the default Access Key
0078      * @param  string $secret_key       Override the default Secret Key
0079      * @return void
0080      */
0081     public function __construct($accessKey=null, $secretKey=null)
0082     {
0083         if(!$accessKey) {
0084             $accessKey = self::$_defaultAccessKey;
0085         }
0086         if(!$secretKey) {
0087             $secretKey = self::$_defaultSecretKey;
0088         }
0089 
0090         if(!$accessKey || !$secretKey) {
0091             // require_once 'Zend/Service/Amazon/Exception.php';
0092             throw new Zend_Service_Amazon_Exception("AWS keys were not supplied");
0093         }
0094         $this->_accessKey = $accessKey;
0095         $this->_secretKey = $secretKey;
0096     }
0097 
0098 
0099 
0100     /**
0101      * Method to fetch the Access Key
0102      *
0103      * @return string
0104      */
0105     protected function _getAccessKey()
0106     {
0107         return $this->_accessKey;
0108     }
0109 
0110     /**
0111      * Method to fetch the Secret AWS Key
0112      *
0113      * @return string
0114      */
0115     protected function _getSecretKey()
0116     {
0117         return $this->_secretKey;
0118     }
0119 }