<?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Security\OAuth1;
-use Friendica;
-use Friendica\Security\OAuth1\OAuthUtil;
+use Friendica\Util\Strings;
class OAuthRequest
{
/**
* pretty much a helper function to set up the request
*
- * @param \Friendica\Security\OAuth1\OAuthConsumer $consumer
- * @param \Friendica\Security\OAuth1\OAuthToken $token
- * @param string $http_method
- * @param string $http_url
- * @param array|null $parameters
+ * @param OAuthConsumer $consumer
+ * @param OAuthToken $token
+ * @param string $http_method
+ * @param string $http_url
+ * @param array|null $parameters
*
* @return OAuthRequest
*/
- public static function from_consumer_and_token(\Friendica\Security\OAuth1\OAuthConsumer $consumer, $http_method, $http_url, array $parameters = null, \Friendica\Security\OAuth1\OAuthToken $token = null)
+ public static function from_consumer_and_token(OAuthConsumer $consumer, $http_method, $http_url, array $parameters = null, OAuthToken $token = null)
{
@$parameters or $parameters = [];
$defaults = [
* @param string|null $realm
*
* @return string
- * @throws \Friendica\Security\OAuth1\OAuthException
+ * @throws OAuthException
*/
public function to_header($realm = null)
{
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") continue;
if (is_array($v)) {
- throw new \Friendica\Security\OAuth1\OAuthException('Arrays not supported in headers');
+ throw new OAuthException('Arrays not supported in headers');
}
$out .= ($first) ? ' ' : ',';
$out .= OAuthUtil::urlencode_rfc3986($k) .
}
- public function sign_request(\Friendica\Security\OAuth1\OAuthSignatureMethod $signature_method, $consumer, $token)
+ public function sign_request(Signature\OAuthSignatureMethod $signature_method, $consumer, $token)
{
$this->set_parameter(
"oauth_signature_method",
$this->set_parameter("oauth_signature", $signature, false);
}
- public function build_signature(\Friendica\Security\OAuth1\OAuthSignatureMethod $signature_method, $consumer, $token)
+ public function build_signature(Signature\OAuthSignatureMethod $signature_method, $consumer, $token)
{
$signature = $signature_method->build_signature($this, $consumer, $token);
return $signature;
*/
private static function generate_nonce()
{
- return Friendica\Util\Strings::getRandomHex(32);
+ return Strings::getRandomHex(32);
}
-}
\ No newline at end of file
+}