<commit_before><?php

/*
 * This file is part of the Novo SGA project.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\Security;

use FOS\OAuthServerBundle\Security\Firewall\OAuthListener as ListenerBase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;

/**
 * OAuthListener
 *
 * @author <NAME> <<EMAIL>>
 */
class OAuthListener implements ListenerInterface
{
    /**
     */
    private $container;
    
    public function __construct(Container $container)
    {
        $this->container = $container;
    }
    
    public function handle(GetResponseEvent $event)
    {
        $manager = $this->container->get('security.authentication.manager');
        $storate = $this->container->get('security.token_storage');
        $server  = $this->container->get('fos_oauth_server.server');
        
        $session = $event->getRequest()->getSession();
        if (!$session->isStarted()) {
            $session->start();
        }
        
        $serializedToken = $session->get('_security_main');
        $token = unserialize($serializedToken);
        
        if ($token instanceof TokenInterface) {
            $storate->setToken($token);
        }
        
        $wrapped = new ListenerBase($storate, $manager, $server);
        
        return $wrapped->handle($event);
    }
}
<commit_msg>oauth service<commit_after><?php

/*
 * This file is part of the Novo SGA project.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\Security;

use FOS\OAuthServerBundle\Security\Firewall\OAuthListener as ListenerBase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;

/**
 * OAuthListener
 *
 * @author <NAME> <<EMAIL>>
 */
class OAuthListener implements ListenerInterface
{
    /**
     * @var Container
     */
    private $container;
    
    /**
     * @var AuthenticationManagerInterface
     */
    private $manager;
    
    /**
     * @var TokenStorageInterface $storeage
     */
    private $storage;
    
    public function __construct(Container $container, AuthenticationManagerInterface $manager, TokenStorageInterface $storage)
    {
        $this->container = $container;
        $this->manager   = $manager;
        $this->storage   = $storage;
    }
    
    public function handle(GetResponseEvent $event)
    {
        $server  = $this->container->get('fos_oauth_server.server');
        
        $session = $event->getRequest()->getSession();
        if (!$session->isStarted()) {
            $session->start();
        }
        
        $serializedToken = $session->get('_security_main');
        $token = unserialize($serializedToken);
        
        if ($token instanceof TokenInterface) {
            $this->storage->setToken($token);
        }
        
        $wrapped = new ListenerBase($this->storage, $this->manager, $server);
        
        return $wrapped->handle($event);
    }
}

{'fraction_non_alphanumeric': 0.12252747252747252, 'fraction_numerical': 0.0, 'mean_word_length': 2.9619151251360174, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4415899', 'n_tokens_mistral': 1003, 'n_tokens_neox': 1003, 'n_words': 206}