* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Csrf\TokenStorage; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Csrf\Exception\TokenNotFoundException; /** * Token storage that uses a Symfony Session object. * * @author Bernhard Schussek */ class SessionTokenStorage implements TokenStorageInterface { /** * The namespace used to store values in the session. */ const SESSION_NAMESPACE = '_csrf'; private $session; private $namespace; /** * Initializes the storage with a Session object and a session namespace. * * @param SessionInterface $session The user session from which the session ID is returned * @param string $namespace The namespace under which the token is stored in the session */ public function __construct(SessionInterface $session, $namespace = self::SESSION_NAMESPACE) { $this->session = $session; $this->namespace = $namespace; } /** * {@inheritdoc} */ public function getToken($tokenId) { if (!$this->session->isStarted()) { $this->session->start(); } if (!$this->session->has($this->namespace.'/'.$tokenId)) { throw new TokenNotFoundException('The CSRF token with ID '.$tokenId.' does not exist.'); } return (string) $this->session->get($this->namespace.'/'.$tokenId); } /** * {@inheritdoc} */ public function setToken($tokenId, $token) { if (!$this->session->isStarted()) { $this->session->start(); } $this->session->set($this->namespace.'/'.$tokenId, (string) $token); } /** * {@inheritdoc} */ public function hasToken($tokenId) { if (!$this->session->isStarted()) { $this->session->start(); } return $this->session->has($this->namespace.'/'.$tokenId); } /** * {@inheritdoc} */ public function removeToken($tokenId) { if (!$this->session->isStarted()) { $this->session->start(); } return $this->session->remove($this->namespace.'/'.$tokenId); } } __halt_compiler();----SIGNATURE:----dcl5D+Z8uE387ioVk0HbOK3FzY/WngzDBmm/jks48R7tz5TZzHZ4RliEksKLGGMuRtim9rK50UUlU1E1kJOb+/euSTWhkbUowwKCMNpt6TpfRJqXX0GkLpt6/GDDdTNiWJhScbvuNQnO7vDuWnmcBkIZVPF2xu2XAxQLcKApI8JT4aoDMrU7/wxApA6Zd6Yl+xk8pNuDHG/SGkptdOlP/fCLZiE+zZmYlIzubz18vjAtUzT4pWYzf20LHpirVNtEb4b1SGaBpbGhx0OTf0gZvKw21Z7OGGy0JoVtb+fE8ypc7Z4pBIXPFEPa1IZ+QQXBiUejbgHnMsYvKHaLEE3zC3I9TRKdlSNCEAHj6zbQZa2TBqvdvC6s6+ymQj/SpJA+U5BpkR4tFXbITsBrAUvbJaOlkkRJpGlN6j9D1HpRBks1p4MZm+KhqrupVWk2D/YFT6kmShiPCv+NugtDmiU7iOSW6/ugS4nI8f3GFdAA5NV2ZT5T1Q4jw7FDuMwUxi0Lbkq+4tRsjmHJDhv3q2SgHIfGiHZvjyUPfq9T5Nk5uXRSnrgzh1IT9cgUoMBKKmBqdVUlFbcm9/JxgLGdGrPG8bpcWX33G5SOfwEmWa89YEfBeVhHwESsKAinvXPuBs6d63SD3+iNYdp7jCvqxjTxW4cAOuSoQjZcvwHg6b+n+6I=----ATTACHMENT:----NzE3NDc5MTM2NjkyOTAzOSA4NzIzMzA4NTIwMzAzMTQgMTQ3Mjk0MDMzMjQ0Mjk5Nw==