/** * @param string $username * @return User */ public function loadUserByUsername($username) { if ($username) { $user = new User($username, $this->apiRecolnatBaseUri, $this->apiRecolnatUserPath, $this->userGroup); $user->init($this->exportPath); return $user; } throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var User $user */ $user = new User('tpateffoz', [], $this->getContainer()->getParameter('api_recolnat_user'), $this->getContainer()->getParameter('user_group')); $user->init($this->getContainer()->getParameter('export_path')); $testDir = $user->getDataDirPath() . 'test/'; $testFile = $testDir . 'test.txt'; $userGroup = $this->getContainer()->getParameter('user_group'); UtilityService::createDir($testDir, $userGroup); UtilityService::createFile($testFile, $userGroup); $output->writeln($testDir); }
public function beforeTestMethod($method) { $this->kernel = new \AppKernel('test', true); $this->kernel->boot(); // Store the container and the entity manager in test case properties $this->container = $this->kernel->getContainer(); $managerRegistry = $this->container->get('doctrine'); $this->exportManager = new \AppBundle\Manager\ExportManager($managerRegistry, $this->container->get('session'), $this->container->get('genericentitymanager'), $this->container->getParameter('maxitemperpage')[1], $this->container->get('diff.computer'), $this->container->getParameter('user_group')); $user = new User('tpateffoz', $this->container->getParameter('api_recolnat_base_uri'), $this->container->getParameter('api_recolnat_user_path'), $this->container->getParameter('user_group')); $user->setExportPath($this->container->getParameter('export_path')); $collection = $this->container->get('utility')->getCollection('MHNAIX', 'AIX'); $this->exportManager->init($user)->setCollection($collection); }
public function checkUserRight(User $user, Collection $collection) { if (!$user->isManagerFor($collection->getCollectioncode())) { throw new AccessDeniedException($this->translator->trans('access.denied.wrongPermission', [], 'exceptions')); } }
/** * @param InputInterface $input * @return User */ private function userCasTicketVerification(InputInterface $input) { $cookieTGC = $input->getOption('cookieTGC'); $username = $input->getArgument('username'); if (!empty($cookieTGC) && !empty($username)) { $user = new User($username, $this->getContainer()->getParameter('api_recolnat_base_uri'), $this->getContainer()->getParameter('api_recolnat_user_path'), []); $verifySsl = true; $requestOptions = $this->getContainer()->getParameter('request_options'); if (isset($requestOptions['verify']) && !$requestOptions['verify']) { $verifySsl = false; } try { $user->isGrantedByCheckServiceTicket($cookieTGC, $this->getContainer()->getParameter('server_login_url'), $this->getContainer()->getParameter('api_recolnat_server_ticket_path'), $this->getContainer()->getParameter('api_recolnat_auth_service_url'), $verifySsl); } catch (\Exception $e) { $this->log($input->getArgument('username') . ' ' . $this->translator->trans('access.denied.wrongPermission', [], 'exceptions')); throw new AccessDeniedException($this->translator->trans('access.denied.wrongPermission', [], 'exceptions')); } } else { $this->log($input->getArgument('username') . ' ' . $this->translator->trans('access.denied.tgc_username', [], 'exceptions')); throw new AccessDeniedException($this->translator->trans('access.denied.tgc_username', [], 'exceptions')); } return $user; }