示例#1
0
 /**
  * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
  * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
  * empty. The result MUST be encoded again.
  *   - Chapter 9.4.1 ("Generating Signatures")
  *
  * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
  * OAuthRequest handles this!
  */
 public function buildSignature($request, $consumer, $token)
 {
     $key_parts = array($consumer->getSecret(), $token ? $token->getSecret() : "");
     $key_parts = Util::urlencodeRfc3986($key_parts);
     $key = implode('&', $key_parts);
     $request->setBaseString($key);
     return $key;
 }
示例#2
0
 public function buildSignature($request, $consumer, $token)
 {
     $baseString = $request->getSignatureBaseString();
     $request->setBaseString($baseString);
     $key_parts = array($consumer->getSecret(), $token ? $token->getSecret() : "");
     $key_parts = Util::urlencodeRfc3986($key_parts);
     $key = implode('&', $key_parts);
     return base64_encode(hash_hmac('sha1', $baseString, $key, true));
 }
示例#3
0
 public function testUrlencode()
 {
     // Tests taken from
     // http://wiki.oauth.net/TestCases ("Parameter Encoding")
     $this->assertEquals('abcABC123', \OAuth\Util::urlencodeRfc3986('abcABC123'));
     $this->assertEquals('-._~', \OAuth\Util::urlencodeRfc3986('-._~'));
     $this->assertEquals('%25', \OAuth\Util::urlencodeRfc3986('%'));
     $this->assertEquals('%2B', \OAuth\Util::urlencodeRfc3986('+'));
     $this->assertEquals('%0A', \OAuth\Util::urlencodeRfc3986("\n"));
     $this->assertEquals('%20', \OAuth\Util::urlencodeRfc3986(' '));
     $this->assertEquals('%7F', \OAuth\Util::urlencodeRfc3986(""));
     //$this->assertEquals('%C2%80',    \OAuth\Util::urlencodeRfc3986("\x00\x80"));
     //$this->assertEquals('%E3%80%81', \OAuth\Util::urlencodeRfc3986("\x30\x01"));
     // Last two checks disabled because of lack of UTF-8 support, or lack
     // of knowledge from me (morten.fangel) on how to use it properly..
     // A few tests to ensure code-coverage
     $this->assertEquals('', \OAuth\Util::urlencodeRfc3986(null));
     $this->assertEquals('', \OAuth\Util::urlencodeRfc3986(new \stdClass()));
 }