Author: Fabien Potencier (fabien@symfony.com)
Author: Johannes M. Schmitt (schmittjoh@gmail.com)
Inheritance: implements Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Beispiel #1
0
 public function __construct($user, $attributes, array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->setAttributes($attributes);
     $this->userIsNew = false;
 }
 public function __construct(array $roles = array())
 {
     parent::__construct($roles);
     // If the user has roles, consider it authenticated
     $this->setAuthenticated(count($roles) > 0);
     $this->setSessionToken();
 }
 public function __construct($user, array $attributes = array(), array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->casAttributes = $attributes;
     parent::setAuthenticated(true);
 }
Beispiel #4
0
 public function __construct(array $roles = array())
 {
     parent::__construct($roles);
     // If the user has roles, consider it authenticated
     $this->setAuthenticated(count($roles) > 0);
     $this->workspaceName = '';
 }
Beispiel #5
0
 public function setAuthenticated($isAuthenticated)
 {
     if ($isAuthenticated) {
         throw new \LogicException('Cannot set this token to trusted after instantiation.');
     }
     parent::setAuthenticated(false);
 }
 public function __construct(OpauthResult $result, array $roles = array())
 {
     parent::__construct($roles);
     // If the user has roles, consider it authenticated
     $this->setAuthenticated(count($roles) > 0);
     $this->setAttribute('opauth', $result);
 }
 /**
  * @param string|object            $user         The username (like a nickname, email address, etc.),
  *                                               or a UserInterface instance
  *                                               or an object implementing a __toString method.
  * @param Organization             $organization The organization
  * @param RoleInterface[]|string[] $roles        An array of roles
  */
 public function __construct($user, Organization $organization, array $roles = [])
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->setOrganizationContext($organization);
     parent::setAuthenticated(count($roles) > 0);
 }
 /**
  * @param array $infos
  */
 public function __construct(array $infos)
 {
     parent::__construct([]);
     $this->clientTokenInfos = isset($infos['client']['id']) ? $infos['client'] : null;
     $this->userTokenInfos = isset($infos['user']['id']) ? $infos['user'] : null;
     $this->impersonatedUserInfos = isset($infos['sudo']['id']) ? $infos['sudo'] : null;
     $this->setUser(isset($this->userTokenInfos['id']) ? $this->userTokenInfos['id'] : 'unknown');
 }
Beispiel #9
0
 public function __construct($firewallName, $providerKey, $uid, array $role = [])
 {
     parent::__construct($role);
     $this->setAuthenticated(count($role) > 0);
     $this->setAttribute(self::UNIQUE_ID_ATTR, $uid);
     $this->setAttribute(self::PROVIDER_KEY_ATTR, $providerKey);
     $this->setAttribute(self::FIREWALL_NAME_ATTR, $firewallName);
 }
 /**
  * Constructor.
  *
  * @param string|object            $user        The user
  * @param mixed                    $context The user credentials
  * @param string                   $providerKey The provider key
  * @param RoleInterface[]|string[] $roles       An array of roles
  */
 public function __construct($user, $context, $providerKey, array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->credentials = $context;
     $this->providerKey = $providerKey;
     parent::setAuthenticated(count($roles) > 0);
 }
 public function __construct($user, array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($user);
     if ($roles) {
         $this->setAuthenticated(true);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function __construct($user, array $roles = null)
 {
     if (is_null($roles) && $user instanceof UserInterface) {
         $roles = $user->getRoles();
     }
     parent::__construct($roles ?: []);
     $this->setUser($user);
 }
 /**
  * @param mixed  $credentials
  * @param string $guardProviderKey Unique key that bind this token to a specific GuardAuthenticatorInterface
  */
 public function __construct($credentials, $guardProviderKey)
 {
     $this->credentials = $credentials;
     $this->guardProviderKey = $guardProviderKey;
     parent::__construct(array());
     // never authenticated
     parent::setAuthenticated(false);
 }
Beispiel #14
0
 public function __construct($usuario, $credenciales, array $roles = array())
 {
     parent::__construct($roles);
     // If the user has roles, consider it authenticated
     $this->setAuthenticated(count($roles) > 0);
     $this->credentials = $credenciales;
     $this->user = $usuario;
 }
 public function __construct($uid = '', array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($uid);
     if (!empty($uid)) {
         $this->setAuthenticated(true);
     }
 }
 /**
  * @param string $user
  * @param int    $expirationTime
  * @param string $ipAddress
  * @param string $signature
  * @param array  $roles
  */
 public function __construct($user, $expirationTime, $ipAddress, $signature, array $roles = [])
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->expirationTime = $expirationTime;
     $this->ipAddress = $ipAddress;
     $this->signature = $signature;
     $this->setAuthenticated(count($roles) > 0);
 }
Beispiel #17
0
 /**
  * Constructor.
  *
  * @param User $user
  *
  * @throws UsernameNotFoundException
  */
 public function __construct(User $user)
 {
     if (!$user->authenticate()) {
         throw new UsernameNotFoundException('Invalid Contao user given.');
     }
     $this->setUser($user);
     $this->setAuthenticated(true);
     parent::__construct($this->getRolesFromUser($user));
 }
Beispiel #18
0
 public function __construct($providerKey, UserInterface $user = null)
 {
     if ($user) {
         parent::__construct($user->getRoles());
         $this->setUser($user);
     } else {
         parent::__construct();
     }
     $this->providerKey = $providerKey;
 }
Beispiel #19
0
 public function update(AbstractToken $token)
 {
     $usurpator = false;
     $roles = $token->getRoles();
     foreach ($roles as $role) {
         if ($role->getRole() === 'ROLE_PREVIOUS_ADMIN') {
             return;
         }
         //May be better to check the class of the token.
         if ($role->getRole() === 'ROLE_USURPATE_WORKSPACE_ROLE') {
             $usurpator = true;
         }
     }
     if ($usurpator) {
         $this->updateUsurpator($token);
     } else {
         $this->updateNormal($token);
     }
 }
 /**
  * Constructor class.
  *
  * @param string $providerKey The key for the provider.
  * @param array  $roles       The roles for the token.
  * @param string $created     The created attribute.
  * @param string $digest      The digest attribute.
  * @param string $nonce       The nonce attribute.
  */
 public function __construct($providerKey, array $roles = array(), $created = null, $digest = null, $nonce = null)
 {
     parent::__construct($roles);
     // if the user has roles, consider it authenticated
     $this->setAuthenticated(count($roles) > 0);
     $this->providerKey = $providerKey;
     $this->created = $created;
     $this->digest = $digest;
     $this->nonce = $nonce;
 }
Beispiel #21
0
 /**
  * @param array         $roles
  * @param string        $providerKey
  * @param array         $attributes
  * @param string|object $user
  */
 public function __construct(array $roles, $providerKey, array $attributes, $user)
 {
     parent::__construct($roles);
     $this->providerKey = $providerKey;
     $this->setAttributes($attributes);
     if ($user) {
         $this->setUser($user);
     }
     $this->setAuthenticated(true);
 }
Beispiel #22
0
 public function __construct(UserInterface $user, $credentials, $providerKey, array $roles = array())
 {
     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(count($roles) > 0);
 }
Beispiel #23
0
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     if ($this->_user) {
         $roles = array();
         foreach ($this->_user->getRoles() as $_role) {
             $roles[] = new \Symfony\Component\Security\Core\Role\Role($_role);
         }
         return $roles;
     }
     return parent::getRoles();
 }
 /**
  * @param $providerKey
  * @param $digest
  * @param $nonce
  * @param $created
  * @param array $roles
  */
 function __construct($providerKey, $digest, $nonce, $created, array $roles = array())
 {
     parent::__construct($roles);
     if (empty($providerKey)) {
         throw new \InvalidArgumentException('$providerKey must not be empty.');
     }
     $this->digest = $digest;
     $this->nonce = $nonce;
     $this->created = $created;
     $this->providerKey = $providerKey;
     $this->setAuthenticated(count($roles) > 0);
 }
Beispiel #25
0
 public function __construct($client, $user, $credentials, $providerKey, array $roles = [])
 {
     parent::__construct($roles);
     $this->client = $client;
     if (empty($providerKey)) {
         throw new \InvalidArgumentException('$providerKey must not be empty.');
     }
     if (null !== $user) {
         $this->setUser($user);
     }
     $this->credentials = $credentials;
     $this->providerKey = $providerKey;
     $this->setAuthenticated(count($roles) > 0);
 }
Beispiel #26
0
 public function __construct($user)
 {
     if (!$user || !$user instanceof UserInterface) {
         $this->setAuthenticated(false);
         parent::__construct(array());
     } else {
         $roles = $user->getRoles();
         if (!$roles) {
             $roles = array();
         }
         parent::__construct($roles);
         $this->setUser($user);
         $this->setAuthenticated(true);
     }
 }
 /**
  * Constructor.
  * @param \Illuminate\Contracts\Auth\Authenticatable $user The user
  */
 public function __construct($user)
 {
     if (!is_null($user) and is_callable(array($user, 'getRoles'))) {
         parent::__construct($user->getRoles());
     } else {
         parent::__construct(array());
     }
     if (!is_null($user)) {
         $this->setUser($user);
         $this->setAuthenticated(true);
     } else {
         $this->setUser('');
         $this->setAuthenticated(false);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function unserialize($str)
 {
     list($this->credentials, $this->providerKey, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }
 /**
  * @param string $serialized
  */
 public function unserialize($serialized)
 {
     list($accountStr, $this->accessToken, $this->idToken, $parentStr) = unserialize($serialized);
     $this->account = unserialize($accountStr);
     parent::unserialize($parentStr);
 }
 /**
  * {@inheritdoc}
  */
 public function eraseCredentials()
 {
     parent::eraseCredentials();
     $this->serviceTicket = null;
 }