/**
  * @param int $limit
  * @param PersonInterface $impersonator
  * @return \Doctrine\ORM\QueryBuilder
  */
 private function getImpersonatonsWithoutReportsQuery($limit = null, PersonInterface $impersonator = null)
 {
     $query = $this->createQueryBuilder('l')->leftJoin('LoginCidadaoCoreBundle:ImpersonationReport', 'r', 'WITH', 'r.actionLog = l')->where('r.id IS NULL')->andWhere('l.actionType = :type')->setParameter('type', ActionLog::TYPE_IMPERSONATE);
     if ($impersonator instanceof PersonInterface) {
         $query->andWhere('l.clientId = :impersonatorId')->setParameter('impersonatorId', $impersonator->getId());
     }
     if ($limit > 0) {
         $query->setMaxResults($limit);
     }
     return $query;
 }
 /**
  * @param PersonInterface $subject
  * @param ClientMetadata|null $metadata
  * @return string
  */
 public function getSubjectIdentifier(PersonInterface $subject, ClientMetadata $metadata = null)
 {
     $id = $subject->getId();
     if ($metadata === null || $metadata->getSubjectType() !== 'pairwise') {
         return $id;
     }
     if ($metadata->getSubjectType() === 'pairwise') {
         $sectorIdentifier = $metadata->getSectorIdentifier();
         $salt = $this->pairwiseSubjectIdSalt;
         $pairwise = hash('sha256', $sectorIdentifier . $id . $salt);
         return $pairwise;
     }
 }
Example #3
0
 public function registerImpersonate(Request $request, PersonInterface $person, PersonInterface $impersonator, array $controllerAction, $isImpersonating)
 {
     $auditUsername = $this->auditConfig->getCurrentUsername();
     if ($isImpersonating) {
         $actionType = ActionLog::TYPE_IMPERSONATE;
     } else {
         $actionType = ActionLog::TYPE_DEIMPERSONATE;
     }
     $log = $this->initLog($request, $actionType, $controllerAction, $auditUsername);
     $log->setUserId($person->getId());
     $log->setClientId($impersonator->getId());
     $this->em->persist($log);
     $this->em->flush($log);
 }