src/EventListener/RouteListener.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Imperium\Config\iConfig;
  4. use Symfony\Component\HttpFoundation\RequestStack;
  5. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Routing\RouterInterface;
  8. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  9. use Symfony\Component\HttpKernel\KernelEvents;
  10. use Imperium\StaticUtils\Utils;
  11. class RouteListener implements EventSubscriberInterface
  12. {
  13.     // use ControllerTrait;
  14.     private $request;
  15.     private $authManager;
  16.     private $router;
  17.     private $blockManager;
  18.     private $tokenStorage;
  19.     protected $session;
  20.     protected $IdCompte;
  21.     protected $PD_IdDataBase;
  22.     protected $PD_IdDiffList;
  23.     protected $OTP;
  24.     protected $CryptSecretKey;
  25.     public function __construct(TokenStorageInterface $tokenStorage,SessionInterface $sessionRequestStack $requestStack,RouterInterface $router)
  26.     {
  27.         $this->request $requestStack->getCurrentRequest();
  28.         $this->router $router;
  29.         $this->tokenStorage $tokenStorage;
  30.         $this->session $session;
  31.         $this->OTP $session->get('otp');
  32.         $this->CryptSecretKey iConfig::getCryptSecretKey();
  33.     }
  34.     public function onRouteRequest($event){
  35.        
  36.        try {
  37.             
  38.             $salt $this->request->get('salt',null);
  39.             $ciphertext $this->request->get('ciphertext',null);
  40.             $iv $this->request->get('iv',null);
  41.             if($salt && $ciphertext && $iv && $this->OTP){
  42.                 $data Utils::dataDecryptJWT(["salt" =>$salt,"ciphertext"=>$ciphertext,"iv"=>$iv ],$this->OTP);
  43.                 
  44.                 $data json_decode(json_encode($data),true);
  45.                 foreach ($data as $key => $dataValue) {
  46.                     $this->request->request->set($key,$dataValue);
  47.                 }
  48.             }
  49.        } catch (\Exception $e) {
  50.         throw $e;
  51.        }
  52.     }
  53.     public static function getSubscribedEvents(){
  54.         return array(
  55.             KernelEvents::REQUEST => 'onRouteRequest'
  56.         );
  57.     }
  58. }