| 1 |
<?php |
| 2 |
/*! |
| 3 |
* This file is part of the OAuth PHP Library (https://code.google.com/p/oauth/) |
| 4 |
* |
| 5 |
* OAuth `PHP' Library is an open source software available under the MIT License. |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Hybridauth\Thirdparty\OAuth; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class OAuthSignatureMethodHMACSHA1 |
| 12 |
* |
| 13 |
* @package Hybridauth\Thirdparty\OAuth |
| 14 |
*/ |
| 15 |
class OAuthSignatureMethodHMACSHA1 extends OAuthSignatureMethod |
| 16 |
{ |
| 17 |
/** |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
public function get_name() |
| 21 |
{ |
| 22 |
return "HMAC-SHA1"; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* @param $request |
| 27 |
* @param $consumer |
| 28 |
* @param $token |
| 29 |
* |
| 30 |
* @return string |
| 31 |
*/ |
| 32 |
public function build_signature($request, $consumer, $token) |
| 33 |
{ |
| 34 |
$base_string = $request->get_signature_base_string(); |
| 35 |
$request->base_string = $base_string; |
| 36 |
|
| 37 |
$key_parts = array( $consumer->secret, $token ? $token->secret : '' ); |
| 38 |
|
| 39 |
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts); |
| 40 |
$key = implode('&', $key_parts); |
| 41 |
|
| 42 |
return base64_encode(hash_hmac('sha1', $base_string, $key, true)); |
| 43 |
} |
| 44 |
} |
| 45 |
|