Skip to content

Commit

Permalink
rename tdm to firmaprofesional
Browse files Browse the repository at this point in the history
  • Loading branch information
obernado committed Oct 1, 2018
1 parent 827328c commit 9622ae6
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 98 deletions.
6 changes: 3 additions & 3 deletions Command/ODMOM.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TDM\DoctrineEncryptBundle\Command;
namespace FP\DoctrineEncryptBundle\Command;

use TDM\DoctrineEncryptBundle\Interfaces\StandardizerInterface;
use FP\DoctrineEncryptBundle\Interfaces\StandardizerInterface;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Common\Collections\Collection;

Expand Down Expand Up @@ -38,7 +38,7 @@ public function scheduleObjectForUpdate($object) {

// A hackish way to force the object to be flagged as
// updated (so it triggers the events) when it really is not.
$this->getObjectManager()->getUnitOfWork()->setOriginalDocumentData($object, array('__tdm_changer' => '1'));
$this->getObjectManager()->getUnitOfWork()->setOriginalDocumentData($object, array('__fp_changer' => '1'));
}

private function handleEmbed($object, $metadata, $fieldName) {
Expand Down
6 changes: 3 additions & 3 deletions Command/ORMOM.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace TDM\DoctrineEncryptBundle\Command;
namespace FP\DoctrineEncryptBundle\Command;

use TDM\DoctrineEncryptBundle\Interfaces\StandardizerInterface;
use FP\DoctrineEncryptBundle\Interfaces\StandardizerInterface;
use Doctrine\ORM\EntityManager;

/**
Expand All @@ -29,7 +29,7 @@ public function getObjectManager() {
public function scheduleObjectForUpdate($object) {
// A hackish way to force the object to be flagged as
// updated (so it triggers the events) when it really is not.
$this->getObjectManager()->getUnitOfWork()->setOriginalEntityData($object, array('__tdm_changer'=>'1'));
$this->getObjectManager()->getUnitOfWork()->setOriginalEntityData($object, array('__fp_changer'=>'1'));
}

}
13 changes: 6 additions & 7 deletions Command/UpdateDataCommand.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php

namespace TDM\DoctrineEncryptBundle\Command;
namespace FP\DoctrineEncryptBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TDMobility\SystemSettingsBundle\Interfaces\SettingsInterface;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Doctrine\Common\Persistence\ObjectManager;
use \Exception;
use \ReflectionProperty;
use TDM\DoctrineEncryptBundle\Subscribers\AbstractDoctrineEncryptSubscriber as ADES;
use TDM\DoctrineEncryptBundle\Configuration\Encrypted;
use FP\DoctrineEncryptBundle\Subscribers\AbstractDoctrineEncryptSubscriber as ADES;
use FP\DoctrineEncryptBundle\Configuration\Encrypted;
use Doctrine\Common\Persistence\ObjectRepository;
use TDM\DoctrineEncryptBundle\Interfaces\StandardizerInterface;
use FP\DoctrineEncryptBundle\Interfaces\StandardizerInterface;

/**
* Description of UpdateDataCommand
Expand Down Expand Up @@ -133,12 +132,12 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$output->writeln('<info>Processing with elevated memory limit of '.$limit.'M.</info>');
}

$db_drivers = $this->getContainer()->getParameter('tdm_doctrine_encrypt.db_driver');
$db_drivers = $this->getContainer()->getParameter('fp_doctrine_encrypt.db_driver');

foreach($db_drivers as $db_driver){
$output->writeln('<info>Work on Driver '.$db_driver.'.</info>');
$this->objectManager = null;
$this->standardizer = $this->getContainer()->get('tdm_doctrine_encrypt.object_manager.'.$db_driver);
$this->standardizer = $this->getContainer()->get('fp_doctrine_encrypt.object_manager.'.$db_driver);

// Get the list of all collections
$output->writeln('<info>Loading list of classes.</info>');
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Encrypted.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\Configuration;
namespace FP\DoctrineEncryptBundle\Configuration;

use Doctrine\Common\Annotations\Annotation;

Expand Down
16 changes: 8 additions & 8 deletions DependencyInjection/Compiler/RegisterServiceCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\DependencyInjection\Compiler;
namespace FP\DoctrineEncryptBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -18,19 +18,19 @@ class RegisterServiceCompilerPass implements CompilerPassInterface {
public function process(ContainerBuilder $container) {

// Load some parameters
$secretKey = $container->getParameter('tdm_doctrine_encrypt.secret_key');
$systemSalt = $container->getParameter('tdm_doctrine_encrypt.system_salt');
$encryptorServiceId = $container->getParameter('tdm_doctrine_encrypt.encryptor_service');
$prefix = $container->getParameter('tdm_doctrine_encrypt.encrypted_prefix');
$secretKey = $container->getParameter('fp_doctrine_encrypt.secret_key');
$systemSalt = $container->getParameter('fp_doctrine_encrypt.system_salt');
$encryptorServiceId = $container->getParameter('fp_doctrine_encrypt.encryptor_service');
$prefix = $container->getParameter('fp_doctrine_encrypt.encrypted_prefix');

// Set the arguments for the encryptor service and add alias
$this->getDefinition($container, $encryptorServiceId)->setArguments(array($secretKey, $systemSalt, $prefix));
$encrypterServiceReference = new Reference($encryptorServiceId);

// Add service as argument on listeners.
foreach($container->getParameter('tdm_doctrine_encrypt.db_driver') as $db_driver){
$this->getDefinition($container, 'tdm_doctrine_encrypt.'.$db_driver.'_subscriber.encrypt')->addArgument($encrypterServiceReference);
$this->getDefinition($container, 'tdm_doctrine_encrypt.'.$db_driver.'_subscriber.decrypt')->addArgument($encrypterServiceReference);
foreach($container->getParameter('fp_doctrine_encrypt.db_driver') as $db_driver){
$this->getDefinition($container, 'fp_doctrine_encrypt.'.$db_driver.'_subscriber.encrypt')->addArgument($encrypterServiceReference);
$this->getDefinition($container, 'fp_doctrine_encrypt.'.$db_driver.'_subscriber.decrypt')->addArgument($encrypterServiceReference);
}
}

Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\DependencyInjection;
namespace FP\DoctrineEncryptBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand All @@ -14,15 +14,15 @@
*/
class Configuration implements ConfigurationInterface {
const defaultPrefix = '_ENC_';
const defaultEncryptorService = 'tdm_doctrine_encrypt.encryptor.default';
const defaultEncryptorService = 'fp_doctrine_encrypt.encryptor.default';
private static $supportedDrivers = array('orm', 'odm');

/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder() {
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('tdm_doctrine_encrypt');
$rootNode = $treeBuilder->root('fp_doctrine_encrypt');

// Grammar of config tree
$rootNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\DependencyInjection;
namespace FP\DoctrineEncryptBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
Expand All @@ -16,7 +16,7 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class TDMDoctrineEncryptExtension extends Extension {
class FPDoctrineEncryptExtension extends Extension {

/**
* {@inheritDoc}
Expand Down Expand Up @@ -49,11 +49,11 @@ public function load(array $configs, ContainerBuilder $container) {
$config['encrypted_prefix'] = Configuration::defaultPrefix;
}

$container->setParameter('tdm_doctrine_encrypt.db_driver', $config['db_driver']);
$container->setParameter('tdm_doctrine_encrypt.secret_key', $config['secret_key']);
$container->setParameter('tdm_doctrine_encrypt.system_salt', $config['system_salt']);
$container->setParameter('tdm_doctrine_encrypt.encryptor_service', $config['encryptor_service']);
$container->setParameter('tdm_doctrine_encrypt.encrypted_prefix', $config['encrypted_prefix']);
$container->setParameter('fp_doctrine_encrypt.db_driver', $config['db_driver']);
$container->setParameter('fp_doctrine_encrypt.secret_key', $config['secret_key']);
$container->setParameter('fp_doctrine_encrypt.system_salt', $config['system_salt']);
$container->setParameter('fp_doctrine_encrypt.encryptor_service', $config['encryptor_service']);
$container->setParameter('fp_doctrine_encrypt.encrypted_prefix', $config['encrypted_prefix']);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
foreach($config['db_driver'] as $db_driver){
Expand All @@ -67,7 +67,7 @@ public function load(array $configs, ContainerBuilder $container) {
}

public function getAlias() {
return 'tdm_doctrine_encrypt';
return 'fp_doctrine_encrypt';
}

}
2 changes: 1 addition & 1 deletion Encryptors/AES256PrefixedEncryptor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\Encryptors;
namespace FP\DoctrineEncryptBundle\Encryptors;

/**
* Class for AES-256 Prefixed encryption
Expand Down
2 changes: 1 addition & 1 deletion Encryptors/EncryptorInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\Encryptors;
namespace FP\DoctrineEncryptBundle\Encryptors;

/**
* Encryptor interface for encryptors
Expand Down
10 changes: 5 additions & 5 deletions TDMDoctrineEncryptBundle.php → FPDoctrineEncryptBundle.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace TDM\DoctrineEncryptBundle;
namespace FP\DoctrineEncryptBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use TDM\DoctrineEncryptBundle\DependencyInjection\TDMDoctrineEncryptExtension;
use TDM\DoctrineEncryptBundle\DependencyInjection\Compiler\RegisterServiceCompilerPass;
use FP\DoctrineEncryptBundle\DependencyInjection\FPDoctrineEncryptExtension;
use FP\DoctrineEncryptBundle\DependencyInjection\Compiler\RegisterServiceCompilerPass;


class TDMDoctrineEncryptBundle extends Bundle {
class FPDoctrineEncryptBundle extends Bundle {

public function build(ContainerBuilder $container) {
parent::build($container);
Expand All @@ -18,6 +18,6 @@ public function build(ContainerBuilder $container) {

public function getContainerExtension()
{
return new TDMDoctrineEncryptExtension();
return new FPDoctrineEncryptExtension();
}
}
2 changes: 1 addition & 1 deletion Interfaces/StandardizerInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TDM\DoctrineEncryptBundle\Interfaces;
namespace FP\DoctrineEncryptBundle\Interfaces;

use Doctrine\Common\Persistence\ObjectManager;

Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ help of some encryption algorithm in database and it will be clearly for develop

The bulk of the documentation is stored in the `Resources/doc/index.md` file in this bundle

The package was originally created by Victor Melnik (@vmelnik-ukraine) and has
since been extensively modified in the following ways.
* Added proper implementation of AES256
* Added use of prefix to determine when values are encrypted
* Added capability of deterministic values which allow for values to be encrypted with the same IV, which allows the exact values to be searched for.
* Added support for MongoDB.
** Arrays in mongo are encrypted per value and not the whole array. (Recurses through the arrays)
* Added capability to decrypt values (by adding decrypt to the annotation).
* Encryption implementation is now a service and can be overridden.
* Added command line tool to update an entire database scheme. This loads and saves every entity/document in the database to update which values are encrypted.
The package was originally created by Victor Melnik (@vmelnik-ukraine) and forked by Westin Pigott(@westinpigott).
This is a fork of the latest.

Our goals with this fork are:
* Replace mcrypt with openssl encryption
* Fix problems with Symfony 3.4

The following documents are available:

* [Configuration reference](https://github.com/TDMobility/DoctrineEncryptBundle/blob/master/Resources/doc/configuration_reference.md)
* [Installation](https://github.com/TDMobility/DoctrineEncryptBundle/blob/master/Resources/doc/installation.md)
* [Example of usage](https://github.com/TDMobility/DoctrineEncryptBundle/blob/master/Resources/doc/example_of_usage.md)
* [Configuration reference](https://github.com/firmaprofesional/DoctrineEncryptBundle/blob/master/Resources/doc/configuration_reference.md)
* [Installation](https://github.com/firmaprofesional/DoctrineEncryptBundle/blob/master/Resources/doc/installation.md)
* [Example of usage](https://github.com/firmaprofesional/DoctrineEncryptBundle/blob/master/Resources/doc/example_of_usage.md)

###License

Expand Down
2 changes: 1 addition & 1 deletion Resources/config/default-encryptor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<services>
<!-- Default encryption service -->
<service id="tdm_doctrine_encrypt.encryptor.default" class="TDM\DoctrineEncryptBundle\Encryptors\AES256PrefixedEncryptor" public="true">
<service id="fp_doctrine_encrypt.encryptor.default" class="FP\DoctrineEncryptBundle\Encryptors\AES256PrefixedEncryptor" public="true">
</service>
</services>
</container>
6 changes: 3 additions & 3 deletions Resources/config/odm-services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

<services>
<!-- Encryption service(subscriber) for encrypt/decrypt entities properties -->
<service id="tdm_doctrine_encrypt.odm_subscriber.encrypt" class="TDM\DoctrineEncryptBundle\Subscribers\ODM\ODMEncrypt">
<service id="fp_doctrine_encrypt.odm_subscriber.encrypt" class="FP\DoctrineEncryptBundle\Subscribers\ODM\ODMEncrypt">
<argument type="service" id="annotation_reader" />
<tag name="doctrine_mongodb.odm.event_listener" event="prePersist" priority="-1000"/>
<tag name="doctrine_mongodb.odm.event_listener" event="preUpdate" priority="-1000"/>
</service>
<!-- Decryption service(subscriber) for encrypt/decrypt entities properties -->
<service id="tdm_doctrine_encrypt.odm_subscriber.decrypt" class="TDM\DoctrineEncryptBundle\Subscribers\ODM\ODMDecrypt">
<service id="fp_doctrine_encrypt.odm_subscriber.decrypt" class="FP\DoctrineEncryptBundle\Subscribers\ODM\ODMDecrypt">
<argument type="service" id="annotation_reader" />
<tag name="doctrine_mongodb.odm.event_subscriber" priority="1000"/>
</service>
<!-- All a standard accessor for getting the object manager -->
<service id="tdm_doctrine_encrypt.object_manager.odm" class="TDM\DoctrineEncryptBundle\Command\ODMOM">
<service id="fp_doctrine_encrypt.object_manager.odm" class="FP\DoctrineEncryptBundle\Command\ODMOM">
<argument type="service" id="doctrine.odm.mongodb.document_manager" />
</service>
</services>
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/orm-services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

<services>
<!-- Encryption service(subscriber) for encrypt/decrypt entities properties -->
<service id="tdm_doctrine_encrypt.orm_subscriber.encrypt" class="TDM\DoctrineEncryptBundle\Subscribers\ORM\ORMEncrypt">
<service id="fp_doctrine_encrypt.orm_subscriber.encrypt" class="FP\DoctrineEncryptBundle\Subscribers\ORM\ORMEncrypt">
<argument type="service" id="annotation_reader" />
<tag name="doctrine.event_listener" event="prePersist" priority="-1000"/>
<tag name="doctrine.event_listener" event="preUpdate" priority="-1000"/>
</service>
<!-- Decryption service(subscriber) for encrypt/decrypt entities properties -->
<service id="tdm_doctrine_encrypt.orm_subscriber.decrypt" class="TDM\DoctrineEncryptBundle\Subscribers\ORM\ORMDecrypt">
<service id="fp_doctrine_encrypt.orm_subscriber.decrypt" class="FP\DoctrineEncryptBundle\Subscribers\ORM\ORMDecrypt">
<argument type="service" id="annotation_reader" />
<tag name="doctrine.event_subscriber" priority="1000"/>
</service>

<!-- All a standard accessor for getting the object manager -->
<service id="tdm_doctrine_encrypt.object_manager.orm" class="TDM\DoctrineEncryptBundle\Command\ORMOM">
<service id="fp_doctrine_encrypt.object_manager.orm" class="FP\DoctrineEncryptBundle\Command\ORMOM">
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
</services>
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/configuration_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All available configuration options are listed below with their default values.

``` yaml
tdm_doctrine_encrypt:
fp_doctrine_encrypt:
# Secret key for encrypt algorithm. All secret key checks are encryptor tasks only.
secret_key: ~ # Required
# ORM and MongoDB are supported using "orm" or "odm" respectively.
Expand Down
4 changes: 2 additions & 2 deletions Resources/doc/example_of_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

// importing @Encrypted annotation
use TDM\DoctrineEncryptBundle\Configuration\Encrypted;
use FP\DoctrineEncryptBundle\Configuration\Encrypted;

/**
* @ORM\Entity
Expand Down Expand Up @@ -127,7 +127,7 @@ use Acme\DemoBundle\Entity\UserV;
class DemoController extends Controller
{
/**
* @Route("/show-user/{id}", name="_tdm_decrypt_test", requirements={"id" = "\d+"})
* @Route("/show-user/{id}", name="_fp_decrypt_test", requirements={"id" = "\d+"})
* @Template
*/
public function getUserAction(UserV $user) {}
Expand Down
Loading

0 comments on commit 9622ae6

Please sign in to comment.