Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Signature.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 2.92 KiB


 001  <?php
 002   
 003  namespace OAuth\OAuth1\Signature;
 004   
 005  use OAuth\Common\Consumer\CredentialsInterface;
 006  use OAuth\Common\Http\Uri\UriInterface;
 007  use OAuth\OAuth1\Signature\Exception\UnsupportedHashAlgorithmException;
 008   
 009  class Signature implements SignatureInterface
 010  {
 011      /**
 012       * @var Credentials
 013       */
 014      protected $credentials;
 015   
 016      /**
 017       * @var string
 018       */
 019      protected $algorithm;
 020   
 021      /**
 022       * @var string
 023       */
 024      protected $tokenSecret;
 025   
 026      public function __construct(CredentialsInterface $credentials)
 027      {
 028          $this->credentials = $credentials;
 029      }
 030   
 031      /**
 032       * @param string $algorithm
 033       */
 034      public function setHashingAlgorithm($algorithm): void
 035      {
 036          $this->algorithm = $algorithm;
 037      }
 038   
 039      /**
 040       * @param string $token
 041       */
 042      public function setTokenSecret($token): void
 043      {
 044          $this->tokenSecret = $token;
 045      }
 046   
 047      /**
 048       * @param string       $method
 049       *
 050       * @return string
 051       */
 052      public function getSignature(UriInterface $uri, array $params, $method = 'POST')
 053      {
 054          parse_str($uri->getQuery(), $queryStringData);
 055   
 056          foreach (array_merge($queryStringData, $params) as $key => $value) {
 057              $signatureData[rawurlencode($key)] = rawurlencode($value ?? '');
 058          }
 059   
 060          ksort($signatureData);
 061   
 062          // determine base uri
 063          $baseUri = $uri->getScheme() . '://' . $uri->getRawAuthority();
 064   
 065          if ('/' === $uri->getPath()) {
 066              $baseUri .= $uri->hasExplicitTrailingHostSlash() ? '/' : '';
 067          } else {
 068              $baseUri .= $uri->getPath();
 069          }
 070   
 071          $baseString = strtoupper($method) . '&';
 072          $baseString .= rawurlencode($baseUri) . '&';
 073          $baseString .= rawurlencode($this->buildSignatureDataString($signatureData));
 074   
 075          return base64_encode($this->hash($baseString));
 076      }
 077   
 078      /**
 079       * @return string
 080       */
 081      protected function buildSignatureDataString(array $signatureData)
 082      {
 083          $signatureString = '';
 084          $delimiter = '';
 085          foreach ($signatureData as $key => $value) {
 086              $signatureString .= $delimiter . $key . '=' . $value;
 087   
 088              $delimiter = '&';
 089          }
 090   
 091          return $signatureString;
 092      }
 093   
 094      /**
 095       * @return string
 096       */
 097      protected function getSigningKey()
 098      {
 099          $signingKey = rawurlencode($this->credentials->getConsumerSecret()) . '&';
 100          if ($this->tokenSecret !== null) {
 101              $signingKey .= rawurlencode($this->tokenSecret);
 102          }
 103   
 104          return $signingKey;
 105      }
 106   
 107      /**
 108       * @param string $data
 109       *
 110       * @return string
 111       */
 112      protected function hash($data)
 113      {
 114          switch (strtoupper($this->algorithm)) {
 115              case 'HMAC-SHA1':
 116                  return hash_hmac('sha1', $data, $this->getSigningKey(), true);
 117              default:
 118                  throw new UnsupportedHashAlgorithmException(
 119                      'Unsupported hashing algorithm (' . $this->algorithm . ') used.'
 120                  );
 121          }
 122      }
 123  }
 124