Add permissions for $identity to $info.

@param IdentityInterface $identity
@param AuthorizationInfo $info
@return PdoRealm
501435
protected function addPermissions(IdentityInterface $identity, AuthorizationInfo $info): PdoRealm
    {
        $statement = $this
            ->getPdo()
            ->prepare($this->getPermissionsQuery());
        $statement->execute([
            $identity->getIdentifier(),
            $identity->getIdentifier(),
        ]);

        foreach ($statement->fetchAll() as $permission) {
            $info->addPermission(
                new Permission($permission['notation'])
            );
        }

        return $this;
    }
425860
protected function _getSelect(Identity $identity)
    {
        return $this->_db
            ->select()
            ->from($this->_getTablaName(), '*')
            ->where($this->_getSelectionFactory()->where($identity))
            ->order($this->_getSelectionFactory()->orderBy($identity));
    }
1137009
public function setIdentity($identity = null)
    {
        if (null === $identity) {
            $this->setResult();
        }

        $this->setParam('identity', $identity);

        return $this;
    }
19922
public function setResourceIdentity(ResourceIdentity $identity): void
    {
        if ($this->resourceIdentity !== null) {
            throw new RuntimeException('The resource identity has already been set.');
        }

        $this->resourceIdentity = $identity;
    }
94173
public function removeTrustRoot($identity, $trustRoot) {
		assert('is_string($identity)');
		assert('is_string($trustRoot)');

		$trs = $this->getTrustRoots($identity);

		$i = array_search($trustRoot, $trs, TRUE);
		if ($i === FALSE) {
			return;
		}
		array_splice($trs, $i, 1, array());
		$this->saveTrustRoots($identity, $trs);
	}
1058495
public function getContext($identity) {
        return new SyncMapPermissionContext(
            $this->version,
            $this->solution['serviceSid'],
            $this->solution['mapSid'],
            $identity
        );
    }
897843
public function setIdentity(IdentityInterface $identity): void
    {
        // save identity to Auth
        $this->identity = $identity;
        // regenerate session
        if (PHP_SAPI !== 'cli') {
            Session::regenerateId();
        }
        // save identity to session
        Session::set('auth:identity', $identity);
        // save user agent to session
        Session::set('auth:agent', Request::getServer('HTTP_USER_AGENT'));
    }
208526
public function authorize(RequestInterface $request)
    {
        if (!$area = $this->findMatchingArea($request)) {
            return $this;
        }

        if (!$this->user) {
            throw new AuthorizationException(sprintf('Access denied to area "%s". No authenticated user', $area->pattern()));
        }

        if (!$area->authorize($this->user, $request->clientIp())) {
            throw new AuthorizationException(sprintf('Access denied to area "%s". Authenticated user does not have access', $area->pattern()));
        }

        return $this;
    }
908302
public function setPermissions($type, $identifier, $permissions)
    {
        foreach ($permissions as $roleId => $rolePermissions) {
            $accessControl = $this->accessControlRepository->findByTypeAndIdAndRole($type, $identifier, $roleId);

            if ($accessControl) {
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
            } else {
                $role = $this->roleRepository->findRoleById($roleId);

                $accessControl = new AccessControl();
                $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
                $accessControl->setRole($role);
                $accessControl->setEntityId($identifier);
                $accessControl->setEntityClass($type);
                $this->objectManager->persist($accessControl);
            }
        }

        $this->objectManager->flush();
    }
1278085
public function getContext($identity) {
        return new SyncListPermissionContext(
            $this->version,
            $this->solution['serviceSid'],
            $this->solution['listSid'],
            $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;
    }
1198655
public function setIdentityDocument($number, $issuer, $issueDate, $type = 'RG')
    {
        $this->data->person->identityDocument = new stdClass();
        $this->data->person->identityDocument->type = $type;
        $this->data->person->identityDocument->number = $number;
        $this->data->person->identityDocument->issuer = $issuer;
        $this->data->person->identityDocument->issueDate = $issueDate;

        return $this;
    }
1343745
protected function getAuthority(IContainer $container) : IAuthority
    {
        $permissionRegistry = $this->getPermissionRegistry($container);
        $container->bindInstance(IPermissionRegistry::class, $permissionRegistry);
        $container->bindInstance(IRoles::class, $this->getRoles($container));

        return new Authority(-1, [], $permissionRegistry);
    }
1170027
protected function _fetchCount(Identity $identity)
    {
        $this->_totalItemsCount = $this->_db->fetchOne($this->_getSelectCount($identity));
        return $this;
    }
482439
private boolean hasPermission(IPerson person, String permission, String target) {
        EntityIdentifier ei = person.getEntityIdentifier();
        IAuthorizationPrincipal ap =
                AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
        return ap.hasPermission(IPermission.PORTAL_GROUPS, permission, target);
    }
76526
private function addContentsRights(array $config, UserSecurityIdentity $securityIdentity)
    {
        $rights = $this->getActionsOnResources($config);
        foreach ((array) $rights as $resource => $actions) {
            if ('all' === $resource) {
                $this->addClassAcl(AbstractClassContent::class, $securityIdentity, $actions);
                $this->writeln(sprintf('    - Setting [%s] on all content', implode(', ', $actions)), OutputInterface::VERBOSITY_DEBUG);
                continue;
            }

            try {
                $classname = AbstractClassContent::getFullClassname($resource);
                if (class_exists($classname)) {
                    $this->addClassAcl($classname, $securityIdentity, $actions);
                    $this->writeln(sprintf('    - Setting [%s] on %s', implode(', ', $actions), $cclassname), OutputInterface::VERBOSITY_DEBUG);
                }
            } catch (\Exception $ex) {
                $this->writeln(sprintf('    - Unknown content `%s`', $classname), OutputInterface::VERBOSITY_DEBUG);
            }
        }
    }
1137473
protected function validateIdentity($identity)
    {
        $options = $this->options;
        $credential = $options
            ->getCredentialRepository()
            ->findOneBy([
                $options->getCredentialIdentityProperty() => $identity,
                $options->getCredentialTypeProperty() => $options->getCredentialType()
            ]);

        if (!$credential) {
            $this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND;
            $this->authenticationResultInfo['messages'][] = 'A record with the supplied credential could not be found.';

            return $this->createAuthenticationResult();
        }

        $credentialIdentityProperty = $this->options->getCredentialIdentityProperty();
        $getter = 'get' . ucfirst($credentialIdentityProperty);
        $credentialIdentity = null;

        if (method_exists($credential, $getter)) {
            $credentialIdentity = $credential->$getter();
        } elseif (property_exists($credential, $credentialIdentityProperty)) {
            $credentialIdentity = $credential->{$credentialIdentityProperty};
        } else {
            throw new Exception\UnexpectedValueException(
                sprintf(
                    'Property (%s) in (%s) is not accessible. You should implement %s::%s()',
                    $credentialIdentityProperty,
                    get_class($credential),
                    get_class($credential),
                    $getter
                )
            );
        }

        $callable = $this->options->getCredentialCallable();
        if ($callable) {
            $credentialValid = call_user_func($callable, $identity, $credential, $this->credential);
        } else {
            $credentialProperty = $options->getCredentialProperty();
            $getter = 'get' . ucfirst($credentialProperty);
            $credentialValue = null;

            if (method_exists($credential, $getter)) {
                $credentialValue = $credential->$getter();
            } elseif (property_exists($credential, $credentialProperty)) {
                $credentialValue = $credential->{$credentialProperty};
            } else {
                throw new Exception\UnexpectedValueException(
                    sprintf(
                        'Property (%s) in (%s) is not accessible. You should implement %s::%s()',
                        $credentialProperty,
                        get_class($credential),
                        get_class($credential),
                        $getter
                    )
                );
            }

            $credentialValid = $identity === $credentialIdentity && $this->credential === $credentialValue;
        }

        if ($credentialValid !== true) {
            $this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
            $this->authenticationResultInfo['messages'][] = 'Supplied credential is invalid.';

            return $this->createAuthenticationResult();
        }

        $this->authenticationResultInfo['code'] = AuthenticationResult::SUCCESS;
        $this->authenticationResultInfo['identity'] = $identity;
        $this->authenticationResultInfo['messages'][] = 'Authentication successful.';

        return $this->createAuthenticationResult();
    }