12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
-
-
-
- namespace JMS\SecurityExtraBundle\Security\Authentication\Token;
-
- use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
- use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
-
-
- class RunAsUserToken extends AbstractToken
- {
- private $originalToken;
- private $key;
- private $credentials;
-
- public function __construct($key, $user, $credentials, array $roles, TokenInterface $originalToken)
- {
- parent::__construct($roles);
-
- $this->originalToken = $originalToken;
- $this->credentials = $credentials;
- $this->key = $key;
-
- $this->setUser($user);
- $this->setAuthenticated(true);
- }
-
- public function getKey()
- {
- return $this->key;
- }
-
- public function getOriginalToken()
- {
- return $this->originalToken;
- }
-
- public function getCredentials()
- {
- return $this->credentials;
- }
-
- public function eraseCredentials()
- {
- parent::eraseCredentials();
-
- $this->credentials = null;
- }
-
- public function serialize()
- {
- return serialize(array(
- $this->originalToken,
- $this->key,
- $this->credentials,
- parent::serialize(),
- ));
- }
-
- public function unserialize($str)
- {
- list($this->originalToken, $this->key, $this->credentials, $parentStr) = unserialize($str);
- parent::unserialize($parentStr);
- }
- }
|