summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/Token/RememberMeToken.php
diff options
context:
space:
mode:
authorBernhard Schussek <bernhard.schussek@symfony-project.com>2011-03-13 18:10:39 +0100
committerBernhard Schussek <bernhard.schussek@symfony-project.com>2011-03-13 19:15:25 +0100
commit263ba4d42870ef5f991540c8b039c2472ba8b204 (patch)
tree90a84bb2a178be744ef3815c6a2bb7268baa9f34 /Core/Authentication/Token/RememberMeToken.php
parent4a5d6729bc8c7f4adc89c153606617390bb24ca4 (diff)
parent5a06947e48c33dc57e21e4316c8b7c6e8f5827b0 (diff)
downloadsymfony-security-263ba4d42870ef5f991540c8b039c2472ba8b204.zip
symfony-security-263ba4d42870ef5f991540c8b039c2472ba8b204.tar.gz
symfony-security-263ba4d42870ef5f991540c8b039c2472ba8b204.tar.bz2
Merge remote branch 'symfony/master' into event-manager
Conflicts: src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventManager.php src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php src/Symfony/Component/Security/Http/Firewall.php src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php src/Symfony/Component/Security/Http/Firewall/AccessListener.php src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php src/Symfony/Component/Security/Http/Firewall/ChannelListener.php src/Symfony/Component/Security/Http/Firewall/ContextListener.php src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php src/Symfony/Component/Security/Http/Firewall/ListenerInterface.php src/Symfony/Component/Security/Http/Firewall/LogoutListener.php src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php tests/Symfony/Tests/Component/Security/Http/Firewall/RememberMeListenerTest.php
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