|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00025 require_once 'Zend/Http/Client.php'; 00026 00033 abstract class Zend_Service_WindowsAzure_Credentials_CredentialsAbstract 00034 { 00038 const DEVSTORE_ACCOUNT = "devstoreaccount1"; 00039 const DEVSTORE_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; 00040 00044 const PREFIX_PROPERTIES = "x-ms-prop-"; 00045 const PREFIX_METADATA = "x-ms-meta-"; 00046 const PREFIX_STORAGE_HEADER = "x-ms-"; 00047 00051 const PERMISSION_READ = "r"; 00052 const PERMISSION_WRITE = "w"; 00053 const PERMISSION_DELETE = "d"; 00054 const PERMISSION_LIST = "l"; 00055 00061 protected $_accountName = ''; 00062 00068 protected $_accountKey = ''; 00069 00075 protected $_usePathStyleUri = false; 00076 00084 public function __construct( 00085 $accountName = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT, 00086 $accountKey = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY, 00087 $usePathStyleUri = false 00088 ) { 00089 $this->_accountName = $accountName; 00090 $this->_accountKey = base64_decode($accountKey); 00091 $this->_usePathStyleUri = $usePathStyleUri; 00092 } 00093 00100 public function setAccountName($value = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT) 00101 { 00102 $this->_accountName = $value; 00103 return $this; 00104 } 00105 00112 public function setAccountkey($value = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY) 00113 { 00114 $this->_accountKey = base64_decode($value); 00115 return $this; 00116 } 00117 00124 public function setUsePathStyleUri($value = false) 00125 { 00126 $this->_usePathStyleUri = $value; 00127 return $this; 00128 } 00129 00138 abstract public function signRequestUrl( 00139 $requestUrl = '', 00140 $resourceType = Zend_Service_WindowsAzure_Storage::RESOURCE_UNKNOWN, 00141 $requiredPermission = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ 00142 ); 00143 00156 abstract public function signRequestHeaders( 00157 $httpVerb = Zend_Http_Client::GET, 00158 $path = '/', 00159 $queryString = '', 00160 $headers = null, 00161 $forTableStorage = false, 00162 $resourceType = Zend_Service_WindowsAzure_Storage::RESOURCE_UNKNOWN, 00163 $requiredPermission = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ 00164 ); 00165 00166 00173 protected function _prepareQueryStringForSigning($value) 00174 { 00175 // Check for 'comp=' 00176 if (strpos($value, 'comp=') === false) { 00177 // If not found, no query string needed 00178 return ''; 00179 } else { 00180 // If found, make sure it is the only parameter being used 00181 if (strlen($value) > 0 && strpos($value, '?') === 0) { 00182 $value = substr($value, 1); 00183 } 00184 00185 // Split parts 00186 $queryParts = explode('&', $value); 00187 foreach ($queryParts as $queryPart) { 00188 if (strpos($queryPart, 'comp=') !== false) { 00189 return '?' . $queryPart; 00190 } 00191 } 00192 00193 // Should never happen... 00194 return ''; 00195 } 00196 } 00197 }