summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/Token/RememberMeToken.php
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Authentication/Token/RememberMeToken.php')
-rw-r--r--Core/Authentication/Token/RememberMeToken.php57
1 files changed, 33 insertions, 24 deletions
diff --git a/Core/Authentication/Token/RememberMeToken.php b/Core/Authentication/Token/RememberMeToken.php
index ce1ed5d..7978427 100644
--- a/Core/Authentication/Token/RememberMeToken.php
+++ b/Core/Authentication/Token/RememberMeToken.php
@@ -11,69 +11,77 @@
namespace Symfony\Component\Security\Core\Authentication\Token;
-use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface;
-use Symfony\Component\Security\Core\User\AccountInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
/**
- * Base class for "Remember Me" tokens
+ * Authentication Token for "Remember-Me".
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
-class RememberMeToken extends Token
+class RememberMeToken extends AbstractToken
{
- protected $key;
-
- /**
- * The persistent token which resulted in this authentication token.
- *
- * @var PersistentTokenInterface
- */
- protected $persistentToken;
+ private $key;
+ private $providerKey;
/**
* Constructor.
*
- * @param string $username
+ * @param UserInterface $user
+ * @param string $providerKey
* @param string $key
*/
- public function __construct(AccountInterface $user, $providerKey, $key) {
+ public function __construct(UserInterface $user, $providerKey, $key) {
parent::__construct($user->getRoles());
if (empty($key)) {
throw new \InvalidArgumentException('$key must not be empty.');
}
+
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
}
- $this->setUser($user);
$this->providerKey = $providerKey;
$this->key = $key;
- $this->setAuthenticated(true);
+
+ $this->setUser($user);
+ parent::setAuthenticated(true);
}
- public function getKey()
+ public function setAuthenticated($authenticated)
{
- return $this->key;
+ if ($authenticated) {
+ throw new \RuntimeException('You cannot set this token to authenticated after creation.');
+ }
+
+ parent::setAuthenticated(false);
}
- public function getPersistentToken()
+ public function getProviderKey()
{
- return $this->persistentToken;
+ return $this->providerKey;
}
- public function setPersistentToken(PersistentTokenInterface $persistentToken)
+ public function getKey()
{
- $this->persistentToken = $persistentToken;
+ return $this->key;
}
+ public function getCredentials()
+ {
+ return '';
+ }
/**
* {@inheritdoc}
*/
public function serialize()
{
- return serialize(array($this->user, $this->credentials, $this->authenticated, $this->roles, $this->immutable, $this->providerKey, $this->attributes, $this->key));
+ return serialize(array(
+ $this->key,
+ $this->providerKey,
+ parent::serialize(),
+ ));
}
/**
@@ -81,6 +89,7 @@ class RememberMeToken extends Token
*/
public function unserialize($serialized)
{
- list($this->user, $this->credentials, $this->authenticated, $this->roles, $this->immutable, $this->providerKey, $this->attributes, $this->key) = unserialize($serialized);
+ list($this->key, $this->providerKey, $parentStr) = unserialize($serialized);
+ parent::unserialize($parentStr);
}
} \ No newline at end of file