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

SymfonySession.php

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


 001  <?php
 002   
 003  namespace OAuth\Common\Storage;
 004   
 005  use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException;
 006  use OAuth\Common\Storage\Exception\TokenNotFoundException;
 007  use OAuth\Common\Token\TokenInterface;
 008  use Symfony\Component\HttpFoundation\Session\SessionInterface;
 009   
 010  class SymfonySession implements TokenStorageInterface
 011  {
 012      private $session;
 013   
 014      private $sessionVariableName;
 015   
 016      private $stateVariableName;
 017   
 018      /**
 019       * @param bool $startSession
 020       * @param string $sessionVariableName
 021       * @param string $stateVariableName
 022       */
 023      public function __construct(
 024          SessionInterface $session,
 025          $startSession = true,
 026          $sessionVariableName = 'lusitanian_oauth_token',
 027          $stateVariableName = 'lusitanian_oauth_state'
 028      ) {
 029          $this->session = $session;
 030          $this->sessionVariableName = $sessionVariableName;
 031          $this->stateVariableName = $stateVariableName;
 032      }
 033   
 034      /**
 035       * {@inheritdoc}
 036       */
 037      public function retrieveAccessToken($service)
 038      {
 039          if ($this->hasAccessToken($service)) {
 040              // get from session
 041              $tokens = $this->session->get($this->sessionVariableName);
 042   
 043              // one item
 044              return $tokens[$service];
 045          }
 046   
 047          throw new TokenNotFoundException('Token not found in session, are you sure you stored it?');
 048      }
 049   
 050      /**
 051       * {@inheritdoc}
 052       */
 053      public function storeAccessToken($service, TokenInterface $token)
 054      {
 055          // get previously saved tokens
 056          $tokens = $this->session->get($this->sessionVariableName);
 057   
 058          if (!is_array($tokens)) {
 059              $tokens = [];
 060          }
 061   
 062          $tokens[$service] = $token;
 063   
 064          // save
 065          $this->session->set($this->sessionVariableName, $tokens);
 066   
 067          // allow chaining
 068          return $this;
 069      }
 070   
 071      /**
 072       * {@inheritdoc}
 073       */
 074      public function hasAccessToken($service)
 075      {
 076          // get from session
 077          $tokens = $this->session->get($this->sessionVariableName);
 078   
 079          return is_array($tokens)
 080              && isset($tokens[$service])
 081              && $tokens[$service] instanceof TokenInterface;
 082      }
 083   
 084      /**
 085       * {@inheritdoc}
 086       */
 087      public function clearToken($service)
 088      {
 089          // get previously saved tokens
 090          $tokens = $this->session->get($this->sessionVariableName);
 091   
 092          if (is_array($tokens) && array_key_exists($service, $tokens)) {
 093              unset($tokens[$service]);
 094   
 095              // Replace the stored tokens array
 096              $this->session->set($this->sessionVariableName, $tokens);
 097          }
 098   
 099          // allow chaining
 100          return $this;
 101      }
 102   
 103      /**
 104       * {@inheritdoc}
 105       */
 106      public function clearAllTokens()
 107      {
 108          $this->session->remove($this->sessionVariableName);
 109   
 110          // allow chaining
 111          return $this;
 112      }
 113   
 114      /**
 115       * {@inheritdoc}
 116       */
 117      public function retrieveAuthorizationState($service)
 118      {
 119          if ($this->hasAuthorizationState($service)) {
 120              // get from session
 121              $states = $this->session->get($this->stateVariableName);
 122   
 123              // one item
 124              return $states[$service];
 125          }
 126   
 127          throw new AuthorizationStateNotFoundException('State not found in session, are you sure you stored it?');
 128      }
 129   
 130      /**
 131       * {@inheritdoc}
 132       */
 133      public function storeAuthorizationState($service, $state)
 134      {
 135          // get previously saved tokens
 136          $states = $this->session->get($this->stateVariableName);
 137   
 138          if (!is_array($states)) {
 139              $states = [];
 140          }
 141   
 142          $states[$service] = $state;
 143   
 144          // save
 145          $this->session->set($this->stateVariableName, $states);
 146   
 147          // allow chaining
 148          return $this;
 149      }
 150   
 151      /**
 152       * {@inheritdoc}
 153       */
 154      public function hasAuthorizationState($service)
 155      {
 156          // get from session
 157          $states = $this->session->get($this->stateVariableName);
 158   
 159          return is_array($states)
 160          && isset($states[$service])
 161          && null !== $states[$service];
 162      }
 163   
 164      /**
 165       * {@inheritdoc}
 166       */
 167      public function clearAuthorizationState($service)
 168      {
 169          // get previously saved tokens
 170          $states = $this->session->get($this->stateVariableName);
 171   
 172          if (is_array($states) && array_key_exists($service, $states)) {
 173              unset($states[$service]);
 174   
 175              // Replace the stored tokens array
 176              $this->session->set($this->stateVariableName, $states);
 177          }
 178   
 179          // allow chaining
 180          return $this;
 181      }
 182   
 183      /**
 184       * {@inheritdoc}
 185       */
 186      public function clearAllAuthorizationStates()
 187      {
 188          $this->session->remove($this->stateVariableName);
 189   
 190          // allow chaining
 191          return $this;
 192      }
 193   
 194      /**
 195       * @return Session
 196       */
 197      public function getSession()
 198      {
 199          return $this->session;
 200      }
 201  }
 202