Helper function to generate an EAP Identity packet

@param string $identity  The identity (username) to send in the packet
@param int $id           The packet ID (random if omitted)
@return string An EAP identity packet
436790
public static function identity($identity, $id = null)
    {
        $packet = new self();
        $packet->setId($id);
        $packet->code = self::CODE_RESPONSE;
        $packet->type = self::TYPE_IDENTITY;
        $packet->data = $identity;

        return $packet->__toString();
    }
1112038
public function findModuleByIdentity($identity)
    {
        $field = $this->getModularIdentifier();

        if (null == $field) {
            throw new \InvalidArgumentException('The module manager is missing a modular identifier.');
        }

        return $this->repository->findOneBy([$field => $identity]);
    }
1047864
public function hasAssociatedIdentity( $userId, $identity )
    {
        $sql    = $this->sql( $this->getTableInSchema( 'user_identity' ) );
        $select = $sql->select()
                      ->columns( array( 'id' ) )
                      ->where( array(
                          'userId'      => (int) $userId,
                          'identity'    => (string) $identity,
                      ) )
                      ->limit( 1 );

        $result = $sql->prepareStatementForSqlObject( $select )
                      ->execute();

        if ( $result->getAffectedRows() < 1 )
        {
            return null;
        }

        foreach ( $result as $row )
        {
            if ( ! empty( $row['id'] ) )
            {
                return $row['id'];
            }
        }

        return null;
    }
893641
public function generateTokenById($id)
    {
        if (!is_null($user = $this->provider->retrieveById($id))) {
            return $this->jwt->fromUser($user);
        }
    }
534460
function get_identity($id = null)
    {
        $id = (int)$id;
        // cache identities for better performance
        if (!array_key_exists($id, $this->identities)) {
            $result = $this->list_identities($id ? "AND `identity_id` = $id" : '');
            $this->identities[$id] = $result[0];
        }

        return $this->identities[$id];
    }
1122199
private function createEntityID(string $id): EntityID
    {
        return new EntityID($this->entityManager, $this->className, $id);
    }
991291
public function delete($identity, $service)
    {
        $successCode = array(DataSift_ApiClient::HTTP_NO_CONTENT);

        return $this->_user->delete('account/identity/' . $identity . '/token/' . $service);
    }
164321
private function login(Identity $identity, $sessionDuration = 0): bool
    {
        $returnUrl = $this->user->getReturnUrl();

        $result = $this->user->login($identity, $sessionDuration ? null : 0);
        if ($result && $returnUrl !== null) {
            $this->user->setReturnUrl($returnUrl);
        }

        return $result;
    }
303921
public function setUserByIdentity(IdentityInterface $identity)
    {
        $user = clone $this->getUser();
        $user->setIdentity($identity);
        $this->setUser($user);
    }
194063
public function getById($id)
    {
        $certificate = $this->adapter->get(sprintf('%s/certificates/%s', $this->endpoint, $id));

        $certificate = json_decode($certificate);

        return new CertificateEntity($certificate->certificate);
    }
496430
public function detach(Identity $identity): self
    {
        $this->states = $this->states->map(static function(
            State $state,
            MapInterface $entities
        ) use (
            $identity
        ) {
            return $entities->remove($identity);
        });

        return $this;
    }
896272
protected function _fetchRow(Identity $identity)
    {
        $this->_rawData = $this->_db->fetchRow($this->_getSelect($identity));
        return $this;
    }
738076
public function byIdentity($identity = null)
    {
        if (!$identity) {
            $identity = Yii::$app->user->identity;
        }
        if (method_exists($identity, 'canGetProperty') && !$identity->canGetProperty('guid')) {
            return $this;
        }
        return $this->createdBy($identity->getGUID());
    }
936164
public function setIdentity($identity = null)
    {
        if (null === $identity) {
            // Setting the identity to null resets the code and messages.
            $this->setCode();
            $this->setMessages();
        }
        $this->setParam('identity', $identity);
        return $this;
    }
1366401
public function create($identity, $service, $token)
    {

        $params = array(
            'service' => $service,
            'token' => $token,
        );

        return $this->_user->post('account/identity/' . $identity . '/token', $params);
    }
104996
public function getContext($identity) {
        return new DocumentPermissionContext(
            $this->version,
            $this->solution['serviceSid'],
            $this->solution['documentSid'],
            $identity
        );
    }
1027515
public function normalizeId($id)
    {
        if (!\is_string($id)) {
            $id = (string) $id;
        }
        if (isset($this->normalizedIds[$normalizedId = strtolower($id)])) {
            $normalizedId = $this->normalizedIds[$normalizedId];
            if ($id !== $normalizedId) {
                @trigger_error(sprintf('Service identifiers will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.3.', $id, $normalizedId), E_USER_DEPRECATED);
            }
        } else {
            $normalizedId = $this->normalizedIds[$normalizedId] = $id;
        }

        return $normalizedId;
    }