3 namespace Friendica\Security\OAuth1\Signature;
5 use Friendica\Security\OAuth1\OAuthRequest;
8 * A class for implementing a Signature Method
9 * See section 9 ("Signing Requests") in the spec
11 abstract class OAuthSignatureMethod
14 * Needs to return the name of the Signature Method (ie HMAC-SHA1)
18 abstract public function get_name();
21 * Build up the signature
22 * NOTE: The output of this function MUST NOT be urlencoded.
23 * the encoding is handled in OAuthRequest when the final
24 * request is serialized
26 * @param OAuthRequest $request
27 * @param \Friendica\Security\OAuth1\OAuthConsumer $consumer
28 * @param \Friendica\Security\OAuth1\OAuthToken $token
32 abstract public function build_signature(OAuthRequest $request, \Friendica\Security\OAuth1\OAuthConsumer $consumer, \Friendica\Security\OAuth1\OAuthToken $token = null);
35 * Verifies that a given signature is correct
37 * @param OAuthRequest $request
38 * @param \Friendica\Security\OAuth1\OAuthConsumer $consumer
39 * @param \Friendica\Security\OAuth1\OAuthToken $token
40 * @param string $signature
44 public function check_signature(OAuthRequest $request, \Friendica\Security\OAuth1\OAuthConsumer $consumer, $signature, \Friendica\Security\OAuth1\OAuthToken $token = null)
46 $built = $this->build_signature($request, $consumer, $token);
47 return ($built == $signature);