summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/Token/UsernamePasswordToken.php
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Authentication/Token/UsernamePasswordToken.php')
-rw-r--r--Core/Authentication/Token/UsernamePasswordToken.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/Core/Authentication/Token/UsernamePasswordToken.php b/Core/Authentication/Token/UsernamePasswordToken.php
index 58b2b5b..67311db 100644
--- a/Core/Authentication/Token/UsernamePasswordToken.php
+++ b/Core/Authentication/Token/UsernamePasswordToken.php
@@ -16,8 +16,11 @@ namespace Symfony\Component\Security\Core\Authentication\Token;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class UsernamePasswordToken extends Token
+class UsernamePasswordToken extends AbstractToken
{
+ private $credentials;
+ private $providerKey;
+
/**
* Constructor.
*
@@ -28,11 +31,15 @@ class UsernamePasswordToken extends Token
{
parent::__construct($roles);
+ if (empty($providerKey)) {
+ throw new \InvalidArgumentException('$providerKey must not be empty.');
+ }
+
$this->setUser($user);
$this->credentials = $credentials;
$this->providerKey = $providerKey;
- parent::setAuthenticated((Boolean) count($roles));
+ parent::setAuthenticated(count($roles) > 0);
}
/**
@@ -47,6 +54,16 @@ class UsernamePasswordToken extends Token
parent::setAuthenticated(false);
}
+ public function getCredentials()
+ {
+ return $this->credentials;
+ }
+
+ public function getProviderKey()
+ {
+ return $this->providerKey;
+ }
+
/**
* {@inheritdoc}
*/
@@ -56,4 +73,15 @@ class UsernamePasswordToken extends Token
$this->credentials = null;
}
+
+ public function serialize()
+ {
+ return serialize(array($this->credentials, $this->providerKey, parent::serialize()));
+ }
+
+ public function unserialize($str)
+ {
+ list($this->credentials, $this->providerKey, $parentStr) = unserialize($str);
+ parent::unserialize($parentStr);
+ }
}