PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/common/libraries/plugin/pear/OAuth/Signature/plaintext.php

https://bitbucket.org/chamilo/chamilo/
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
  1. <?php
  2. /**
  3. * OAuth Request Signing
  4. *
  5. * Adapted from Andy Smith's OAuth library for PHP
  6. *
  7. * @link http://oauth.net/core/1.0
  8. * @link http://oauth.googlecode.com/svn/code/php/
  9. * @link http://term.ie/oauth/example/
  10. *
  11. * @package OAuth
  12. * @subpackage Signature
  13. *
  14. * @author jhart
  15. * @copyright Copyright (c) 2008, Photobucket, Inc.
  16. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  17. */
  18. /**
  19. * interface
  20. */
  21. require_once('OAuth/Signature/Interface.php');
  22. /**
  23. * OAuth PLAINTEXT implementation
  24. *
  25. * @package OAuth
  26. * @subpackage Signature
  27. */
  28. class OAuth_Signature_plaintext implements OAuth_Signature_Interface {
  29. /**
  30. * Representation string
  31. *
  32. */
  33. const OAUTH_SIGNATURE_METHOD = 'PLAINTEXT';
  34. /**
  35. * Sign a request
  36. *
  37. * @param OAuth_Request $request request to sign
  38. * @param string $consumer_secret consumer secret key
  39. * @param string $token_secret token secret key
  40. * @return string calculated hash for request, secrets
  41. */
  42. public function signRequest(OAuth_Request $request, $consumer_secret, $token_secret = '') {
  43. // for debug purposes
  44. $request->base_string = '';
  45. $key = self::generateKeyString($consumer_secret, $token_secret);
  46. //for debug purposes
  47. $request->key_string = $key;
  48. return OAuth_Utils::urlencodeRFC3986_UTF8($key);
  49. }
  50. /**
  51. * Get the OAuth official string representation for this method
  52. *
  53. * @return string oauth method name
  54. */
  55. public function getMethodName() {
  56. return self::OAUTH_SIGNATURE_METHOD;
  57. }
  58. /**
  59. * Generate a key string
  60. *
  61. * @todo could be in a base class for hmac
  62. * @param string $consumersecret consumer secret key
  63. * @param string $tokensecret token secret key
  64. * @return string single key string
  65. */
  66. protected static function generateKeyString($consumersecret, $tokensecret = '') {
  67. return OAuth_Utils::urlencodeRFC3986_UTF8($consumersecret)
  68. . '&' . self::urlencodeRFC3986_UTF8($tokensecret);
  69. }
  70. }