/**
  * @param mixed $result
  * @param string $componentId
  * @param Session $session
  */
 protected function storeResult($result, $componentId, Session $session)
 {
     $authorizedFor = $session->getBag()->has('authorizedFor') ? $session->get('authorizedFor') : '';
     $token = $session->getEncrypted('token');
     $tokenDetail = $this->getStorageApiToken($token);
     $creator = ['id' => $tokenDetail['id'], 'description' => $tokenDetail['description']];
     $data = json_encode($result);
     $sapiUrl = $this->container->getParameter('storage_api.url');
     try {
         $this->connection->insert('credentials', ['id' => $session->get('id'), 'component_id' => $componentId, 'project_id' => $tokenDetail['owner']['id'], 'creator' => json_encode($creator), 'data' => ByAppEncryption::encrypt($data, $componentId, $token, true, $sapiUrl), 'authorized_for' => $authorizedFor, 'created' => date("Y-m-d H:i:s")]);
     } catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
         $id = $session->get('id');
         throw new UserException("Credentials '{$id}' for component '{$componentId}' already exist!");
     }
 }