Check if the security identity is valid.

@param SecurityIdentityInterface $sid The security identity

@return bool
426386
public static function isValid(SecurityIdentityInterface $sid)
    {
        return !$sid instanceof RoleSecurityIdentity
            || ($sid instanceof RoleSecurityIdentity && false === strpos($sid->getIdentifier(), 'IS_'));
    }
1077009
public function has(string $entryIdentifier): bool
    {
        return $this->memcache->get($this->identifierPrefix . $entryIdentifier) !== false;
    }
18272
public function has(string $entryIdentifier): bool
    {
        $success = false;
        apcu_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success);
        return $success;
    }
8214
public function areIdentical()
    {
        return $this->valid()
            ? $this->lhs->current() === $this->rhs->current()
            && $this->lhs->key() === $this->rhs->key()
            : $this->lhs->valid() == $this->rhs->valid();
    }
699066
public function isValid($intCount = null)
    {
        $blnReturn = false;
        $intDynamicCount = ($this->isDynamicCounter()) ? $this->__validator->getValue() : 0;

        for ($intCount = 0; $intCount <= $intDynamicCount; $intCount ++) {
            $blnReturn = $this->__validator->validate($intCount);

            if (! $blnReturn) {
                break;
            }
        }

        return $blnReturn;
    }
34256
public function isValid(SessionBagInterface $sessionBag)
    {
        return $sessionBag->get(self::PARAM_REMOTE_ADDR) === $this->hash($this->getRemoteAddr()) &&
               $sessionBag->get(self::PARAM_USER_AGENT) === $this->hash($this->getUserAgent());
    }
189375
public function isValid($payload, $publicKey, $signature)
    {
        return openssl_verify($payload, $signature, $publicKey, $this->hashAlgorithm) === 1;
    }
1221073
public function authenticate(GenericUserInterface $user, $credential)
    {
        $userAttributes = $user->getAttributes();
        if (empty($userAttributes)) {
            throw new IdentityNotFoundException();
        }
        $this->store($user->getAttributes());

        return true;
    }
1028560
public function verify($token, $identifier = null)
    {
        $identifier = ($identifier !== null) ? $identifier : $this->identifier;

        // Throw error for empty token or empty message id, because the server will not handle this
        if (empty($token)) {
            throw new Totp\EmptyTokenException();
        }
        if (empty($this->identifier)) {
            throw new Totp\EmptyIdentifierException();
        }

        try {
            $this->sendApiCall(self::ACTION_RETRIEVE, sprintf('totp/%s?token=%s', $identifier, $token));
        } catch (Exception $e) {
            if (Totp\Exception::isTotpException($e)) {
                throw new Totp\Exception($e);
            } else {
                throw $e;
            }
        }
    }
1042517
function validateUserIdentifier($userId, $identifierName)
    {
        $response = $this->call( new Command\Members\ValidateUserIdentifier($userId, $identifierName) );
        if ( $ex = $response->hasException() )
            throw $ex;


        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
582090
public function handler_destroy($sid) {
        if (!$session = $this->database->get_record('sessions', array('sid'=>$sid), 'id, sid')) {
            if ($sid == session_id()) {
                $this->recordid = null;
                $this->lasthash = null;
            }
            return true;
        }

        if ($this->recordid and $session->id == $this->recordid) {
            try {
                $this->database->release_session_lock($this->recordid);
            } catch (\Exception $ex) {
                // Ignore problems.
            }
            $this->recordid = null;
            $this->lasthash = null;
        }

        $this->database->delete_records('sessions', array('id'=>$session->id));

        return true;
    }
92084
private function validateUser(UserInterface $user)
    {
        return $user->isValid($this->username, $this->password, $this->realm);
    }
269604
private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
    {
        if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) {
            return $id;
        }

        $this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));

        return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
    }
748567
public function isIdentified(VendorInterface $vendor)
    {

        $this->resetRestClient();

        $this->restClient->getConfig()->setPath(
            'request.options/headers/php-auth-user',
            $this->login
        );

        $this->restClient->getConfig()->setPath(
            'request.options/headers/php-auth-pw',
            $this->password
        );

        if (!empty($vendor->getHiPayId())) {
            $this->restClient->getConfig()->setPath(
                'request.options/headers/php-auth-subaccount-id',
                $vendor->getHiPayId()
            );
        }

        $command = $this->restClient->getCommand(
            'GetUserAccount',
            array()
        );

        $result = $this->executeRest($command);

        return $result['identified'] == 1 ? true : false;
    }
1182553
private function buildSecurityIdentities()
    {
        $tSids = $this->sidManager->getSecurityIdentities($this->tokenStorage->getToken());
        $sids = [];

        foreach ($tSids as $sid) {
            if (IdentityUtils::isValid($sid)) {
                $sids[] = $sid;
            }
        }

        return $sids;
    }
148436
public function setId($sid)
    {
        //argument 1 must be an integer
        Argument::i()->test(1, 'int');

        if (!self::$session) {
            Exception::i()->setMessage(self::ERROR_NOT_STARTED)->trigger();
        }

        return session_id((int) $sid);
    }
260372
protected function validateBrokerSessionId(string $sessionId)
    {
        $matches = null;

        if (!preg_match('/^SSO-(\w*+)-(\w*+)-([a-z0-9]*+)$/', $this->getBrokerSessionId(), $matches)) {
            $this->fail('Invalid session id');
        }

        if ($this->generateSessionId($matches[1], $matches[2]) != $sessionId) {
            $this->fail('Checksum failed: Client IP address may have changed');
        }

        return $matches[1];
    }