Commit a4b4a4f7 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Work in progress

parent 5a693ca6
Loading
Loading
Loading
Loading
+1 −1
Changes for module/Application/src/Application/Authentication/Adapter/Ldap.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even

        /* @var $userService \Application\Service\User */
        $userService = $this->getServiceManager()->get('unicaen-auth_user_service');
        $userService->userAuthenticated($e->getIdentity(), $ldapPeople);
        $userService->userAuthenticated($ldapPeople);
    }

    /**
+1 −1
Changes for module/Application/src/Application/Authentication/Adapter/Shib.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class Shib implements ServiceManagerAwareInterface, EventManagerAwareInterface
    public function getAuthenticatedUser()
    {
        if ($this->authenticatedUser === null) {
            if (!isset($_SERVER['REMOTE_USER'])) {
            if (empty($_SERVER['REMOTE_USER'])) {
                return null;
            }
            $this->authenticatedUser = $this->createShibUser();
+2 −48
Changes for module/Application/src/Application/Authentication/Storage/AppStorage.php: 2 added lines, 48 removed lines.
Original line number Diff line number Diff line
@@ -4,18 +4,14 @@ namespace Application\Authentication\Storage;

use Application\Authentication\Adapter\ShibUser;
use Application\Entity\Db\Doctorant;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Utilisateur;
use Application\Service\Doctorant\DoctorantServiceAwareTrait;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
use Application\Service\Role\RoleServiceAwareTrait;
use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Doctrine\ORM\NonUniqueResultException;
use UnicaenApp\Entity\Ldap\People;
use UnicaenApp\Exception\RuntimeException;
use UnicaenAuth\Authentication\Storage\ChainableStorage;
use UnicaenAuth\Authentication\Storage\ChainEvent;
use UnicaenAuth\Entity\Ldap\People;
use Zend\Authentication\Exception\ExceptionInterface;

/**
@@ -25,21 +21,15 @@ use Zend\Authentication\Exception\ExceptionInterface;
 * - entité Doctorant si l'utilisateur authentifié est trouvé parmi les thésards,
 * - null sinon.
 *
 * Valeur associée à la clé KEY_STRUCTURE_ROLE_INDIVIDU :
 * - entités RoleServiceIndividu si l'utilisateur authentifié est trouvé dans IndividuRole,
 * - [] sinon.
 *
  * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
  * @author Unicaen
 */
class AppStorage implements ChainableStorage
{
    use UtilisateurServiceAwareTrait;
    use DoctorantServiceAwareTrait;
    use RoleServiceAwareTrait;

    const KEY_DB_UTILSATEUR = 'db';
    const KEY_DOCTORANT = 'doctorant';
    const KEY_STRUCTURE_ROLE_INDIVIDU = 'structureIndividu';

    /**
     * @var mixed
@@ -61,11 +51,6 @@ class AppStorage implements ChainableStorage
     */
    protected $doctorant;

    /**
     * @var IndividuRole[]
     */
    protected $structureIndividu;

    /**
     * @param ChainEvent $e
     * @return void
@@ -91,11 +76,6 @@ class AppStorage implements ChainableStorage
         * Collecte des données au cas où l'utilisateur connecté est trouvé dans la table Doctorant.
         */
        $this->addDoctorantContents($e);

        /**
         * Collecte des données au cas où l'utilisateur connecté est trouvé dans la table EcoleDoctoraleIndividu.
         */
         $this->addStructureRoleContents($e);
    }

    protected function addDbUtilisateurContents(ChainEvent $e)
@@ -168,32 +148,6 @@ class AppStorage implements ChainableStorage
        return $this->doctorant;
    }

    private function fetchStructureRoleIndividu()
    {
        if (null !== $this->structureIndividu) {
            return $this->structureIndividu;
        }

        //todo a changer une fois l'individu mieux identifié
        $sourceCodeIndividu = $this->people->getSupannEmpId();

        $this->structureIndividu =
            $this->roleService->getIndividuRolesByIndividuSourceCode($sourceCodeIndividu);

        return $this->structureIndividu;
    }

    private function addStructureRoleContents(ChainEvent $e)
    {
        try {
            $e->addContents(self::KEY_STRUCTURE_ROLE_INDIVIDU, $this->fetchStructureRoleIndividu());
        } catch (ExceptionInterface $e) {
            throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e);
        }

        return $this;
    }

    public function write(ChainEvent $e)
    {
        // nop
+0 −8
Changes for module/Application/src/Application/Authentication/Storage/AppStorageFactory.php: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -3,9 +3,6 @@
namespace Application\Authentication\Storage;

use Application\Service\Doctorant\DoctorantService;
use Application\Service\EcoleDoctorale\EcoleDoctoraleService;
use Application\Service\Role\RoleService;
use Application\Service\UniteRecherche\UniteRechercheService;
use Application\Service\Utilisateur\UtilisateurService;
use Zend\ServiceManager\ServiceLocatorInterface;

@@ -23,14 +20,9 @@ class AppStorageFactory
        /** @var DoctorantService $doctorantService */
        $doctorantService = $sl->get(DoctorantService::class);

        /** @var RoleService $roleService */
        $roleService = $sl->get(RoleService::class);


        $service = new AppStorage();
        $service->setUtilisateurService($utilisateurService);
        $service->setDoctorantService($doctorantService);
        $service->setRoleService($roleService);

        return $service;
    }
+1 −2
Changes for module/Application/src/Application/Authentication/Storage/Shib.php: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Application\Authentication\Storage;
use Application\Authentication\Adapter\ShibUser;
use UnicaenAuth\Authentication\Storage\ChainableStorage;
use UnicaenAuth\Authentication\Storage\ChainEvent;
use UnicaenAuth\Entity\Ldap\People;
use UnicaenAuth\Options\ModuleOptions;
use Zend\Authentication\Storage\Session;
use Zend\Authentication\Storage\StorageInterface;
@@ -34,7 +33,7 @@ class Shib implements ChainableStorage, ServiceLocatorAwareInterface
    protected $options;

    /**
     * @var People
     * @var ShibUser
     */
    protected $resolvedIdentity;

Loading