* * 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:----G020gKSXkpXpm33fKNUVbtfu/0Sb+Ay21n3EcclL4km9p3Ky3HFy1BTHVcvZBNTdaK/tQIPRRmO8c17v7psiGLikpGpkKYL12eSdfq/JuEVSM1Ht2XS8phYdVota5eoPfWh10LgGcKyQH+Q/c4WgWAY58zYvgvuPGWCb1rmmjQa2AyVBFdnEaWUtuhWvmb3VHKqfkV1+4Bgd/e+OYUn6Fmr2gUyFiRWqdOsiqf8O/gIvfwN3zW87PSV/tqnsEYu6iR9HA2fus9krn0y+51yXN3l1IYeDm4mXM1+suVNnukvtYFZIQmxcMg6vHIHvW86egXAvU5bc0JIKCuMvFEEOVpeiJRo4VVqti+r8PXEWW2gYs/Of7krPwCYAwIgCVnkpuPvguX+Lgh3P/RBLu6DyZ5uAecJXXMIuSxhV+IGCuGedaZ8nIyy+5kLuH0mdfv+XqzhuXrBQwguudfg8eIhsYx2ladsmczJSHdo5PmMdXAhkwrCtjVt9m9vq7bS0yHdB9HarvG17CvKP9wG5kicDBV/IGme+BUstrTKPet1IJIk3Eue+WYuek/5z2MKN32tBD2/wbx3XZPvEUrBEZZdZm8QzCVduIBbRUli1YygwsdYETHP30gS1IiD/5OfFJhEJmfT2nG//v2nvxnwwtuqks2Qcov6FzAlglGxlaeo9RaU=----ATTACHMENT:----MTE0NTYyOTQ5MTEwNDE2MyAyNjUyOTc4MjYyMDE3MTY3IDczNzE4NjUxNjM2NzQ5NTY=