/common/libraries/plugin/pear/OAuth/Signature/plaintext.php
PHP | 79 lines | 18 code | 9 blank | 52 comment | 0 complexity | ce57e1d18a81be9af080eb2ad4085c0a MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT
- <?php
- /**
- * OAuth Request Signing
- *
- * Adapted from Andy Smith's OAuth library for PHP
- *
- * @link http://oauth.net/core/1.0
- * @link http://oauth.googlecode.com/svn/code/php/
- * @link http://term.ie/oauth/example/
- *
- * @package OAuth
- * @subpackage Signature
- *
- * @author jhart
- * @copyright Copyright (c) 2008, Photobucket, Inc.
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
- /**
- * interface
- */
- require_once('OAuth/Signature/Interface.php');
- /**
- * OAuth PLAINTEXT implementation
- *
- * @package OAuth
- * @subpackage Signature
- */
- class OAuth_Signature_plaintext implements OAuth_Signature_Interface {
-
- /**
- * Representation string
- *
- */
- const OAUTH_SIGNATURE_METHOD = 'PLAINTEXT';
-
- /**
- * Sign a request
- *
- * @param OAuth_Request $request request to sign
- * @param string $consumer_secret consumer secret key
- * @param string $token_secret token secret key
- * @return string calculated hash for request, secrets
- */
- public function signRequest(OAuth_Request $request, $consumer_secret, $token_secret = '') {
- // for debug purposes
- $request->base_string = '';
-
- $key = self::generateKeyString($consumer_secret, $token_secret);
- //for debug purposes
- $request->key_string = $key;
-
- return OAuth_Utils::urlencodeRFC3986_UTF8($key);
- }
-
- /**
- * Get the OAuth official string representation for this method
- *
- * @return string oauth method name
- */
- public function getMethodName() {
- return self::OAUTH_SIGNATURE_METHOD;
- }
-
- /**
- * Generate a key string
- *
- * @todo could be in a base class for hmac
- * @param string $consumersecret consumer secret key
- * @param string $tokensecret token secret key
- * @return string single key string
- */
- protected static function generateKeyString($consumersecret, $tokensecret = '') {
- return OAuth_Utils::urlencodeRFC3986_UTF8($consumersecret)
- . '&' . self::urlencodeRFC3986_UTF8($tokensecret);
- }
-
- }