web/lib/Zend/Service/WindowsAzure/Credentials/SharedKey.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    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.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Service_WindowsAzure
    16  * @package    Zend_Service_WindowsAzure
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: SharedKey.php 23167 2010-10-19 17:53:31Z mabe $
    19  * @version    $Id: SharedKey.php 24593 2012-01-05 20:35:02Z matthew $
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * @see Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
    23  * @see Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
    24  */
    24  */
    25 require_once 'Zend/Service/WindowsAzure/Credentials/CredentialsAbstract.php';
    25 require_once 'Zend/Service/WindowsAzure/Credentials/CredentialsAbstract.php';
    26 
    26 
    27 /**
    27 /**
    28  * @see Zend_Service_WindowsAzure_Storage
       
    29  */
       
    30 require_once 'Zend/Service/WindowsAzure/Storage.php';
       
    31 
       
    32 /**
       
    33  * @see Zend_Http_Client
       
    34  */
       
    35 require_once 'Zend/Http/Client.php';
       
    36 
       
    37 /**
       
    38  * @see Zend_Service_WindowsAzure_Credentials_Exception
       
    39  */
       
    40 require_once 'Zend/Service/WindowsAzure/Credentials/Exception.php';
       
    41 
       
    42 /**
       
    43  * @category   Zend
    28  * @category   Zend
    44  * @package    Zend_Service_WindowsAzure
    29  * @package    Zend_Service_WindowsAzure
    45  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    46  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    47  */ 
    32  */ 
    48 class Zend_Service_WindowsAzure_Credentials_SharedKey
    33 class Zend_Service_WindowsAzure_Credentials_SharedKey
    49     extends Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
    34     extends Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
    50 {
    35 {
    89 	) {
    74 	) {
    90 		// http://github.com/sriramk/winazurestorage/blob/214010a2f8931bac9c96dfeb337d56fe084ca63b/winazurestorage.py
    75 		// http://github.com/sriramk/winazurestorage/blob/214010a2f8931bac9c96dfeb337d56fe084ca63b/winazurestorage.py
    91 
    76 
    92 		// Table storage?
    77 		// Table storage?
    93 		if ($forTableStorage) {
    78 		if ($forTableStorage) {
       
    79 			require_once 'Zend/Service/WindowsAzure/Credentials/Exception.php';
    94 			throw new Zend_Service_WindowsAzure_Credentials_Exception('The Windows Azure SDK for PHP does not support SharedKey authentication on table storage. Use SharedKeyLite authentication instead.');
    80 			throw new Zend_Service_WindowsAzure_Credentials_Exception('The Windows Azure SDK for PHP does not support SharedKey authentication on table storage. Use SharedKeyLite authentication instead.');
    95 		}
    81 		}
    96 		
    82 		
    97 		// Determine path
    83 		// Determine path
    98 		if ($this->_usePathStyleUri) {
    84 		if ($this->_usePathStyleUri) {
   113 		    $requestDate = gmdate('D, d M Y H:i:s', time()) . ' GMT'; // RFC 1123
    99 		    $requestDate = gmdate('D, d M Y H:i:s', time()) . ' GMT'; // RFC 1123
   114 		    $canonicalizedHeaders[] = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date:' . $requestDate;
   100 		    $canonicalizedHeaders[] = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date:' . $requestDate;
   115 		}
   101 		}
   116 		
   102 		
   117 		// Build canonicalized headers
   103 		// Build canonicalized headers
   118 		if ($headers !== null) {
   104 		if (!is_null($headers)) {
   119 			foreach ($headers as $header => $value) {
   105 			foreach ($headers as $header => $value) {
   120 				if (is_bool($value)) {
   106 				if (is_bool($value)) {
   121 					$value = $value === true ? 'True' : 'False';
   107 					$value = $value === true ? 'True' : 'False';
   122 				}
   108 				}
   123 
   109 
   136 		}
   122 		}
   137 		$canonicalizedResource .= $path;
   123 		$canonicalizedResource .= $path;
   138 		if ($queryString !== '') {
   124 		if ($queryString !== '') {
   139 		    $queryStringItems = $this->_makeArrayOfQueryString($queryString);
   125 		    $queryStringItems = $this->_makeArrayOfQueryString($queryString);
   140 		    foreach ($queryStringItems as $key => $value) {
   126 		    foreach ($queryStringItems as $key => $value) {
   141 		    	$canonicalizedResource .= "\n" . strtolower($key) . ':' . $value;
   127 		    	$canonicalizedResource .= "\n" . strtolower($key) . ':' . urldecode($value);
   142 		    }
   128 		    }
   143 		}
   129 		}
   144 		
   130 		
   145 		// Content-Length header
   131 		// Content-Length header
   146 		$contentLength = '';
   132 		$contentLength = '';
   147 		if (strtoupper($httpVerb) != Zend_Http_Client::GET
   133 		if (strtoupper($httpVerb) != Zend_Http_Client::GET
   148 			 && strtoupper($httpVerb) != Zend_Http_Client::DELETE
   134 			 && strtoupper($httpVerb) != Zend_Http_Client::DELETE
   149 			 && strtoupper($httpVerb) != Zend_Http_Client::HEAD) {
   135 			 && strtoupper($httpVerb) != Zend_Http_Client::HEAD) {
   150 			$contentLength = 0;
   136 			$contentLength = 0;
   151 			
   137 			
   152 			if ($rawData !== null) {
   138 			if (!is_null($rawData)) {
   153 				$contentLength = strlen($rawData);
   139 				$contentLength = strlen($rawData);
   154 			}
   140 			}
   155 		}
   141 		}
   156 
   142 
   157 		// Create string to sign   
   143 		// Create string to sign