/Security/Authentication/Token/FacebookUserToken.php

http://github.com/FriendsOfSymfony/FOSFacebookBundle · PHP · 62 lines · 39 code · 15 blank · 8 comment · 1 complexity · 32ebe692b7482c8a8996dda743c49f89 MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of the FOSFacebookBundle package.
  4. *
  5. * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\FacebookBundle\Security\Authentication\Token;
  11. use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
  12. class FacebookUserToken extends AbstractToken
  13. {
  14. private $providerKey;
  15. protected $accessToken;
  16. public function __construct($providerKey, $uid = '', array $roles = array(), $accessToken = null)
  17. {
  18. parent::__construct($roles);
  19. $this->setUser($uid);
  20. if (!empty($uid)) {
  21. $this->setAuthenticated(true);
  22. }
  23. $this->providerKey = $providerKey;
  24. $this->accessToken = $accessToken;
  25. }
  26. public function getCredentials()
  27. {
  28. return '';
  29. }
  30. public function getProviderKey()
  31. {
  32. return $this->providerKey;
  33. }
  34. public function getAccessToken()
  35. {
  36. return $this->accessToken;
  37. }
  38. public function serialize()
  39. {
  40. return serialize(array($this->providerKey, parent::serialize()));
  41. }
  42. public function unserialize($str)
  43. {
  44. list($this->providerKey, $parentStr) = unserialize($str);
  45. parent::unserialize($parentStr);
  46. }
  47. }