Example #1
0
File: S3.php Project: poitch/dokin
 public function getAuthFor($sPath)
 {
     $sPath = $sPath[0] == '/' ? $sPath : '/' . $sPath;
     $iExpires = time() + 5 * 60;
     $sToSign = "GET\n\n\n{$iExpires}\n{$sPath}";
     $oCrypt = new HMAC($this->sSecret, 'sha1');
     $sSignature = $oCrypt->hash($sToSign);
     $sSignature = $this->base64($sSignature);
     $sAuth = '?';
     $sAuth .= 'AWSAccessKeyId=' . $this->sKey . '&';
     $sAuth .= 'Signature=' . urlencode($sSignature) . '&';
     $sAuth .= 'Expires=' . $iExpires;
     return $sAuth;
 }
Example #2
0
File: AWS.php Project: poitch/dokin
 protected function sign($hParams)
 {
     $hParams['Version'] = $this->sVersion;
     $hParams['AWSAccessKeyId'] = $this->sKey;
     $hParams['Expires'] = date('c', time() + 120);
     $hParams['SignatureVersion'] = 1;
     // TODO redo this part
     $hSignedParams = $hParams;
     $aKeys = array_keys($hSignedParams);
     foreach ($aKeys as $i => $key) {
         $aKeys[$i] = strtolower($key);
         $hMap[strtolower($key)] = $key;
     }
     sort($aKeys);
     $sString = '';
     foreach ($aKeys as $key) {
         $val = $hSignedParams[$hMap[$key]];
         $sString .= $hMap[$key] . $val;
     }
     $oCrypt = new HMAC($this->sSecret, 'sha1');
     $sSignature = $oCrypt->hash($sString);
     $sSignature = $this->hex2b64($sSignature);
     $hParams['Signature'] = $sSignature;
     return $hParams;
 }