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