krz/vox-populi

A Tumblr web client.

clone: git clone https://gitbay.org/krz/vox-populi.git

main: vendor/eher/oauth/src/Eher/OAuth/SignatureMethod.php · raw

 1<?php
 2
 3namespace Eher\OAuth;
 4
 5/**
 6 * A class for implementing a Signature Method
 7 * See section 9 ("Signing Requests") in the spec
 8 */
 9abstract class SignatureMethod {
10  /**
11   * Needs to return the name of the Signature Method (ie HMAC-SHA1)
12   * @return string
13   */
14  abstract public function get_name();
15
16  /**
17   * Build up the signature
18   * NOTE: The output of this function MUST NOT be urlencoded.
19   * the encoding is handled in Request when the final
20   * request is serialized
21   * @param Request $request
22   * @param Consumer $consumer
23   * @param OAuthToken $token
24   * @return string
25   */
26  abstract public function build_signature($request, $consumer, $token);
27
28  /**
29   * Verifies that a given signature is correct
30   * @param Request $request
31   * @param Consumer $consumer
32   * @param OAuthToken $token
33   * @param string $signature
34   * @return bool
35   */
36  public function check_signature($request, $consumer, $token, $signature) {
37    $built = $this->build_signature($request, $consumer, $token);
38    return $built == $signature;
39  }
40}