OAuthSignatureMethod_PLAINTEXT.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * The PLAINTEXT method does not provide any security protection and SHOULD only be used
  4. * over a secure channel such as HTTPS. It does not use the Signature Base String.
  5. * - Chapter 9.4 ("PLAINTEXT")
  6. */
  7. class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
  8. public function get_name() {
  9. return "PLAINTEXT";
  10. }
  11. /**
  12. * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
  13. * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
  14. * empty. The result MUST be encoded again.
  15. * - Chapter 9.4.1 ("Generating Signatures")
  16. *
  17. * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
  18. * OAuthRequest handles this!
  19. */
  20. public function build_signature($request, $consumer, $token) {
  21. $key_parts = array(
  22. $consumer->secret,
  23. ($token) ? $token->secret : ""
  24. );
  25. $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
  26. $key = implode('&', $key_parts);
  27. $request->base_string = $key;
  28. return $key;
  29. }
  30. }