diff options
Diffstat (limited to 'Authentication/Token/UsernamePasswordToken.php')
-rw-r--r-- | Authentication/Token/UsernamePasswordToken.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Authentication/Token/UsernamePasswordToken.php b/Authentication/Token/UsernamePasswordToken.php new file mode 100644 index 0000000..5356f8d --- /dev/null +++ b/Authentication/Token/UsernamePasswordToken.php @@ -0,0 +1,56 @@ +<?php + +namespace Symfony\Component\Security\Authentication\Token; + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien.potencier@symfony-project.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * UsernamePasswordToken implements a username and password token. + * + * @author Fabien Potencier <fabien.potencier@symfony-project.com> + */ +class UsernamePasswordToken extends Token +{ + /** + * Constructor. + */ + public function __construct($user, $credentials, array $roles = array()) + { + parent::__construct($roles); + + $this->user = $user; + $this->credentials = $credentials; + + parent::setAuthenticated((Boolean) count($roles)); + } + + /** + * {@inheritdoc} + */ + public function setAuthenticated($isAuthenticated) + { + if ($isAuthenticated) + { + throw new \LogicException('Cannot set this token to trusted after instantiation.'); + } + + parent::setAuthenticated(false); + } + + /** + * {@inheritdoc} + */ + public function eraseCredentials() + { + parent::eraseCredentials(); + + $this->credentials = null; + } +} |