1: <?php
2: /**
3: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
4: *
5: * @author Chuck Hagenbuch <chuck@horde.org>
6: * @license http://www.horde.org/licenses/bsd BSD
7: * @category Horde
8: * @package Oauth
9: */
10:
11: /**
12: * OAuth HMAC-SHA1 signature method
13: *
14: * @author Chuck Hagenbuch <chuck@horde.org>
15: * @license http://www.horde.org/licenses/bsd BSD
16: * @category Horde
17: * @package Oauth
18: */
19: class Horde_Oauth_SignatureMethod_HmacSha1 extends Horde_Oauth_SignatureMethod
20: {
21: public function getName()
22: {
23: return 'HMAC-SHA1';
24: }
25:
26: public function sign($request, $consumer, $token)
27: {
28: $baseString = $request->getSignatureBaseString();
29:
30: $key_parts = array(
31: $consumer->secret,
32: ($token) ? $token->secret : ''
33: );
34:
35: $key_parts = array_map(array('Horde_Oauth_Utils','urlencodeRfc3986'), $key_parts);
36: $key = implode('&', $key_parts);
37:
38: return base64_encode(hash_hmac('sha1', $baseString, $key, true));
39: }
40: }
41: