12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Oauth |
16 * @package Zend_Oauth |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: SignatureAbstract.php 22662 2010-07-24 17:37:36Z mabe $ |
19 * @version $Id: SignatureAbstract.php 24593 2012-01-05 20:35:02Z matthew $ |
20 */ |
20 */ |
21 |
21 |
22 /** Zend_Oauth_Http_Utility */ |
22 /** Zend_Oauth_Http_Utility */ |
23 require_once 'Zend/Oauth/Http/Utility.php'; |
23 require_once 'Zend/Oauth/Http/Utility.php'; |
24 |
24 |
57 */ |
57 */ |
58 protected $_tokenSecret = ''; |
58 protected $_tokenSecret = ''; |
59 |
59 |
60 /** |
60 /** |
61 * Constructor |
61 * Constructor |
62 * |
62 * |
63 * @param string $consumerSecret |
63 * @param string $consumerSecret |
64 * @param null|string $tokenSecret |
64 * @param null|string $tokenSecret |
65 * @param null|string $hashAlgo |
65 * @param null|string $hashAlgo |
66 * @return void |
66 * @return void |
67 */ |
67 */ |
68 public function __construct($consumerSecret, $tokenSecret = null, $hashAlgo = null) |
68 public function __construct($consumerSecret, $tokenSecret = null, $hashAlgo = null) |
69 { |
69 { |
70 $this->_consumerSecret = $consumerSecret; |
70 $this->_consumerSecret = $consumerSecret; |
77 } |
77 } |
78 } |
78 } |
79 |
79 |
80 /** |
80 /** |
81 * Sign a request |
81 * Sign a request |
82 * |
82 * |
83 * @param array $params |
83 * @param array $params |
84 * @param null|string $method |
84 * @param null|string $method |
85 * @param null|string $url |
85 * @param null|string $url |
86 * @return string |
86 * @return string |
87 */ |
87 */ |
88 public abstract function sign(array $params, $method = null, $url = null); |
88 public abstract function sign(array $params, $method = null, $url = null); |
89 |
89 |
90 /** |
90 /** |
91 * Normalize the base signature URL |
91 * Normalize the base signature URL |
92 * |
92 * |
93 * @param string $url |
93 * @param string $url |
94 * @return string |
94 * @return string |
95 */ |
95 */ |
96 public function normaliseBaseSignatureUrl($url) |
96 public function normaliseBaseSignatureUrl($url) |
97 { |
97 { |
98 $uri = Zend_Uri_Http::fromString($url); |
98 $uri = Zend_Uri_Http::fromString($url); |
124 return implode('&', $parts); |
124 return implode('&', $parts); |
125 } |
125 } |
126 |
126 |
127 /** |
127 /** |
128 * Get base signature string |
128 * Get base signature string |
129 * |
129 * |
130 * @param array $params |
130 * @param array $params |
131 * @param null|string $method |
131 * @param null|string $method |
132 * @param null|string $url |
132 * @param null|string $url |
133 * @return string |
133 * @return string |
134 */ |
134 */ |
135 protected function _getBaseSignatureString(array $params, $method = null, $url = null) |
135 protected function _getBaseSignatureString(array $params, $method = null, $url = null) |
136 { |
136 { |
137 $encodedParams = array(); |
137 $encodedParams = array(); |
138 foreach ($params as $key => $value) { |
138 foreach ($params as $key => $value) { |
139 $encodedParams[Zend_Oauth_Http_Utility::urlEncode($key)] = |
139 $encodedParams[Zend_Oauth_Http_Utility::urlEncode($key)] = |
140 Zend_Oauth_Http_Utility::urlEncode($value); |
140 Zend_Oauth_Http_Utility::urlEncode($value); |
141 } |
141 } |
142 $baseStrings = array(); |
142 $baseStrings = array(); |
143 if (isset($method)) { |
143 if (isset($method)) { |
144 $baseStrings[] = strtoupper($method); |
144 $baseStrings[] = strtoupper($method); |