Beispiel #1
0
 public function buildSignature($request, $consumer, $token)
 {
     $baseString = $request->getSignatureBaseString();
     $request->baseString = $baseString;
     $keyParts = array($consumer->secret, $token ? $token->secret : "");
     $keyParts = Oauth_Util::urlencodeRfc3986($keyParts);
     $key = implode('&', $keyParts);
     return base64_encode(hash_hmac('sha1', $baseString, $key, true));
 }
Beispiel #2
0
 public function buildSignature($request, $consumer, $token)
 {
     $sig = array(Oauth_Util::urlencodeRfc3986($consumer->secret));
     if ($token) {
         array_push($sig, Oauth_Util::urlencodeRfc3986($token->secret));
     } else {
         array_push($sig, '');
     }
     $raw = implode("&", $sig);
     // for debug purposes
     $request->baseString = $raw;
     return Oauth_Util::urlencodeRfc3986($raw);
 }
Beispiel #3
0
 /**
  * Util function for turning the Authorization: header into
  * parameters, has to do some unescaping
  */
 public static function splitHeader($header)
 {
     $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
     $offset = 0;
     $params = array();
     $matches = array();
     while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
         $match = $matches[0];
         $headerName = $matches[2][0];
         $headerContent = isset($matches[5]) ? $matches[5][0] : $matches[4][0];
         $params[$headerName] = Oauth_Util::urldecodeRfc3986($headerContent);
         $offset = $match[1] + strlen($match[0]);
     }
     if (isset($params['realm'])) {
         unset($params['realm']);
     }
     return $params;
 }
Beispiel #4
0
 /**
  * Generates the basic string serialization of a token that a server
  * would respond to request_token and access_token calls with
  */
 public function __toString()
 {
     return "oauth_token=" . Oauth_Util::urlencodeRfc3986($this->key) . "&oauth_token_secret=" . Oauth_Util::urlencodeRfc3986($this->secret);
 }