Add the security identity of current user.

@param TokenInterface              $token The token
@param SecurityIdentityInterface[] $sids  The security identities

@return SecurityIdentityInterface[]
507739
protected function addCurrentUser(TokenInterface $token, array $sids)
    {
        if (!$token instanceof AnonymousToken) {
            try {
                $sids[] = UserSecurityIdentity::fromToken($token);
            } catch (\InvalidArgumentException $e) {
                // ignore, user has no user security identity
            }
        }

        return $sids;
    }
581320
private function enforceSecurityIdentity(&$sid)
    {
        if (
            ($sid instanceof DomainObjectInterface)
        ) {
            $sid = new UserSecurityIdentity($sid->getObjectIdentifier(), get_class($sid));
        } elseif (! ($sid instanceof SecurityIdentityInterface)) {
            throw new InvalidArgumentException('Object must implement ObjectIdentifiableInterface');
        }
    }
326254
protected function extractPermissions(TokenInterface $token)
    {
        $user = $token->getUser();
        if (!$user instanceof User) {
            return [];
        }

        return $user->getCombinedFamilyPermissions();
    }
344545
public function verify(TokenInterface $token): bool
    {
        $signer = $this->factory->create($token->algorithm());
        $key    = new Key($this->verifyKey->content(), $this->verifyKey->passphrase());

        return $signer->verify($token->signature(), $token->payload(), $key);
    }
683737
public function getLoginToken(UserInterface $user, UuidInterface $token) : LoginToken
    {
        return new LoginToken(
            $user->getId(),
            $token
        );
    }
729480
protected function updateTokens(array $tokens)
    {
        $this->roles = null;
        $this->contextHash = null;

        if ($this->request === null) {
            return;
        }

        /** @var $token TokenInterface */
        foreach ($tokens as $token) {
            $token->updateCredentials($this->request);
        }

        $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class);
        $sessionDataContainer->setSecurityTokens(array_merge($this->inactiveTokens, $this->activeTokens));
    }
1153064
public static function getTokenCustomProperties(ContainerInterface $container, TokenInterface $token): array
    {
        $userId = $token->getUserIdentifier();

        /** @var FactoryInterface $factory */
        $factory = $container->get(FactoryInterface::class);
        /** @var UsersApi $usersApi */
        $usersApi = $factory->createApi(UsersApi::class);

        $builder = $usersApi->shouldBeUntyped()->withIndexFilter($userId)->createIndexBuilder([
            User::FIELD_EMAIL,
            User::FIELD_FIRST_NAME,
            User::FIELD_LAST_NAME,
        ]);

        $user = $usersApi->fetchRow($builder, User::class);

        return [
            User::FIELD_ID         => $userId,
            User::FIELD_EMAIL      => $user[User::FIELD_EMAIL],
            User::FIELD_FIRST_NAME => $user[User::FIELD_FIRST_NAME],
            User::FIELD_LAST_NAME  => $user[User::FIELD_LAST_NAME],
        ];
    }
421773
private function createUser(SamlSpResponseToken $token)
    {
        if (null === $this->userCreator) {
            return null;
        }

        $user = $this->userCreator->createUser($token->getResponse());

        if ($user && false === $user instanceof UserInterface) {
            throw new \LogicException('User creator must return instance of UserInterface or null');
        }

        return $user;
    }
202328
public function getContext($sid) {
        return new CredentialListMappingContext(
            $this->version,
            $this->solution['accountSid'],
            $this->solution['domainSid'],
            $sid
        );
    }
554821
protected function acquireAuthenticationCookies($token)
    {
        $urlInfo = parse_url($this->authorityUrl);

        $url =  $urlInfo['scheme'] . '://' . $urlInfo['host'] . self::$SignInPageUrl;
        if ($this->usingFederatedSTS) {
            $url =  $urlInfo['scheme'] . '://' . $urlInfo['host'] . self::$IDCRLSVCPageUrl;

            $headers = array();
            $headers['User-Agent'] = '';
            $headers['X-IDCRL_ACCEPTED'] = 't';
            $headers['Authorization'] = 'BPOSIDCRL ' . $token;
            $headers['Content-Type'] = 'application/x-www-form-urlencoded';

            $response = Requests::head($url,$headers,true);
            $cookies = Requests::parseCookies($response);
            $this->SPOIDCRL = $cookies['SPOIDCRL'];
        }
        else {
            $response = Requests::post($url,null,$token,true);
            $cookies = Requests::parseCookies($response);
            $this->FedAuth = $cookies['FedAuth'];
            $this->rtFa = $cookies['rtFa'];
        }
    }
840978
public function tokenSupply($tokenIdentifier) {
        $params = [
            'module' => "stats",
            'action' => "tokensupply",
        ];

        if (strlen($tokenIdentifier) === 42) {
            $params['contractaddress'] = $tokenIdentifier;
        } else {
            $params['tokenname'] = $tokenIdentifier;
        }

        return $this->request->exec($params);
    }
328971
protected function buildId(TokenInterface $token)
    {
        $id = spl_object_hash($token);
        $listeners = $this->getCacheIdentityListeners();

        foreach ($listeners as $listener) {
            $id .= '_'.$listener->getCacheId();
        }

        return $id;
    }
487821
private function getMapSecurityIdentities(array $sids)
    {
        $connection = $this->entityManager->getConnection();
        $mapSids = [];

        foreach ($sids as $sid) {
            $type = $this->sharingManager->getIdentityConfig($sid->getType())->getType();
            $mapSids[$type][] = $connection->quote($sid->getIdentifier());
        }

        foreach ($mapSids as $type => $ids) {
            $mapSids[$type] = implode(', ', $ids);
        }

        return $mapSids;
    }
584963
public function getContext($sid) {
        return new AuthCallsCredentialListMappingContext(
            $this->version,
            $this->solution['accountSid'],
            $this->solution['domainSid'],
            $sid
        );
    }
489554
public function getSecurityIdentities(TokenInterface $token)
    {
        $sids = parent::getSecurityIdentities($token);

        if ($token->getUser() instanceof \BackBee\Security\User) {
            foreach ($token->getUser()->getGroups() as $group) {
                $securityIdentity = new UserSecurityIdentity($group->getObjectIdentifier(), ClassUtils::getRealClass($group));
                array_unshift($sids, $securityIdentity);
            }
        }

        return $sids;
    }
608721
public function deleteClassAce($objectIdentity, $sid)
    {
        $this->enforceObjectIdentity($objectIdentity);
        $this->enforceSecurityIdentity($sid);

        $acl = $this->getAcl($objectIdentity);

        $found = false;

        foreach ($acl->getClassAces() as $index => $ace) {
            if ($ace->getSecurityIdentity()->equals($sid)) {
                $acl->deleteClassAce($index);
                $found = true;
                break;
            }
        }

        if (false === $found) {
            throw new InvalidArgumentException('ACE not found for the supplied combination of ObjectIdentity and SecurityIdentity');
        }

        $this->securityContext->getACLProvider()->updateAcl($acl);
    }
605417
public function login($token)
    {
        $subject           = SecurityUtils::getSecurityManager()->login($this, $token);
        $this->_principal  = $subject->getPrincipal();
        $this->_principals = $subject->getPrincipals();
        $this->principals = $subject->getPrincipals();

        if ($this->_principals === null || empty($this->_principals)) {
            $msg = "Principals returned from SecurityManager->login( token ) returned an empty set.".
                    "This must be populated with one or more elements.";
            throw new \Exception(msg);
        }
        $this->_authenticated = true;

    }