/**
  * Retrieve user with password token and use it to decrypt the cipher key in the user
  * The encryption manager will store it in the session for the following requests
  * {@inheritdoc}
  */
 protected function retrieveUser($username, UsernamePasswordToken $token)
 {
     $user = parent::retrieveUser($username, $token);
     if ($user instanceof UserEncryptionProviderInterface && null !== $token->getCredentials()) {
         $this->encryptionManager->decryptCipherKey($user, $token->getCredentials());
     }
     return $user;
 }
 /**
  * Sends the file using the encryption manager with the php://output internal stream
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     $this->encryptionManager->decryptFile($this->file->getPathname(), 'php://output', $this->fileSize);
 }
 /**
  * @param string $message
  * @param CryptableInterface $entity
  * @param \Exception $e
  */
 protected function logError($message, CryptableInterface $entity = null, \Exception $e = null)
 {
     if (!$this->logger) {
         return;
     }
     try {
         $context = ['encryptionOwnershipId' => $this->encryptionManager->getEncryptionOwnershipId()];
     } catch (EmptyOwnershipIdException $e) {
         $context = ['encryptionOwnershipId' => null];
     }
     if ($entity) {
         $meta = $this->doctrine->getManager()->getClassMetadata(get_class($entity));
         $context['entity'] = ['class' => get_class($entity), 'identifier' => $meta->getIdentifierValues($entity), 'encrypted' => $entity->getIsEncrypted(), 'encryptionOwnershipId' => $entity->getEncryptionOwnershipId(), 'encryptedProperties' => $entity->getEncryptedProperties()];
     }
     if ($e) {
         $context['exception'] = $e;
     }
     $this->logger->error('EncryptionBundle:CryptableSubscriber - ' . $message, $context);
 }