/** * Configure injection of arguments of controllers * * @param sfServiceContainerBuilder $container Symfony container to configure */ public function configure(sfServiceContainerBuilder $container) { $container->register('studium.controller.class', '\\fajr\\controller\\studium\\StudiumController')->addArgument(new sfServiceReference('administracia_studia_screen.factory.class'))->addArgument('%serverTime%')->setShared(false); $container->register('predmety.controller.class', '\\fajr\\controller\\predmety\\PredmetyController')->addArgument(new sfServiceReference('register_predmetov_screen.factory.class'))->addArgument('%serverTime%')->setShared(false); switch ($this->server->getBackendType()) { case ServerConfig::BACKEND_FAKE: $container->register('administracia_studia_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSES017_administracia_studia\\VSES017_FakeFactoryImpl')->addArgument(new sfServiceReference('fake.storage.class'))->setShared(false); $container->register('register_predmetov_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSST060_register_predmetov\\VSST060_FakeFactoryImpl')->addArgument(new sfServiceReference('fake.storage.class'))->setShared(false); $container->register('fake.storage.class', '\\fajr\\libfajr\\storage\\TemporarilyModifiableStorage')->addArgument('%TempStorage.options%'); $container->setParameter('TempStorage.options', array('permanent_storage' => new sfServiceReference('fake.file.storage.class'), 'temporary_storage' => $this->storage)); $container->register('fake.file.storage.class', '\\fajr\\libfajr\\storage\\FileStorage')->addArgument('%Fake.FileStorage.options%'); $container->setParameter('Fake.FileStorage.options', array('root_path' => \fajr\libfajr\pub\regression\fake_data\FakeData::getDirectory())); $container->register('AIS2MainScreen.class', '\\fajr\\libfajr\\window\\fake\\FakeMainScreen')->setShared(false); /** * Somewhat arbitrary fixed as 10.1.2011 12:17:53 **/ $FAKE_TIME = mktime(12, 17, 53, 1, 10, 2011); $container->setParameter('serverTime', $FAKE_TIME); break; case ServerConfig::BACKEND_LIBFAJR: $container->register('administracia_studia_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSES017_administracia_studia\\VSES017_FactoryImpl')->addArgument(new sfServiceReference('serverConnection.class'))->setShared(false); $container->register('register_predmetov_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSST060_register_predmetov\\VSST060_FactoryImpl')->addArgument(new sfServiceReference('serverConnection.class'))->setShared(false); $container->register('AIS2MainScreen.class', '\\fajr\\libfajr\\window\\AIS2MainScreenImpl')->addArgument(new sfServiceReference('serverConnection.class'))->setShared(false); $container->setService('serverConnection.class', $this->connection); $container->setParameter('serverTime', time()); break; default: assert(false); } }
/** * Configure injection of arguments of controllers * * @param sfServiceContainerBuilder $container Symfony container to configure */ public function configure(sfServiceContainerBuilder $container) { $container->register('studium.controller.class', '\\fajr\\controller\\studium\\StudiumController')->addArgument(new sfServiceReference('administracia_studia_screen.factory.class'))->setShared(false); switch ($this->server->getBackendType()) { case ServerConfig::BACKEND_FAKE: $container->register('administracia_studia_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSES017_administracia_studia\\VSES017_FakeFactoryImpl')->addArgument(new sfServiceReference('fake.storage.class'))->setShared(false); $container->register('fake.storage.class', '\\fajr\\libfajr\\storage\\TemporarilyModifiableStorage')->addArgument('%TempStorage.options%'); $container->setParameter('TempStorage.options', array('permanent_storage' => new sfServiceReference('fake.file.storage.class'), 'temporary_storage' => $this->storage)); $container->register('fake.file.storage.class', '\\fajr\\libfajr\\storage\\FileStorage')->addArgument('%Fake.FileStorage.options%'); $container->setParameter('Fake.FileStorage.options', array('root_path' => \fajr\regression\fake_data\fake_data::getDirectory())); $container->register('AIS2MainScreen.class', '\\fajr\\libfajr\\window\\fake\\FakeMainScreen')->setShared(false); break; case ServerConfig::BACKEND_LIBFAJR: $container->register('administracia_studia_screen.factory.class', '\\fajr\\libfajr\\pub\\window\\VSES017_administracia_studia\\VSES017_FactoryImpl')->addArgument(new sfServiceReference('serverConnection.class'))->setShared(false); $container->register('AIS2MainScreen.class', '\\fajr\\libfajr\\window\\AIS2MainScreenImpl')->addArgument(new sfServiceReference('serverConnection.class'))->setShared(false); $container->setService('serverConnection.class', $this->connection); break; default: assert(false); } }
/** * Provides login object created from POST-data * or null if login info is not (fully) present in the request. * * This function should be called only once (it will * return null on subsequent calls). * * @returns Login login instance recognized */ private function provideLogin(ServerConfig $serverConfig, LoginFactory $factory, Request $request) { $loginType = $request->getParameter("loginType"); $login = $request->getParameter('login'); $password = $request->getParameter('password'); $cosignCookie = $request->getParameter('cosignCookie'); // we don't need this info in the global scope anymore $request->clearParameter('login'); $request->clearParameter('password'); $request->clearParameter('cosignCookie'); if (empty($loginType)) { return null; } switch ($serverConfig->getLoginType()) { case 'password': $this->assertSecurity($loginType === 'password', "Wrong login type {$loginType}"); $this->assertSecurity($login !== null, 'Login field missing'); $this->assertSecurity($password !== null, 'Password field missing'); if ($login === '' || $password === '') { return null; } return $factory->newLoginUsingPassword($login, $password); break; case 'cosign': if ($loginType === 'cosigncookie') { if ($cosignCookie === '') { return null; } $cosignCookie = CosignServiceCookie::fixCookieValue($cosignCookie); return $factory->newLoginUsingCosignCookie(new CosignServiceCookie($serverConfig->getCosignCookieName(), $cosignCookie, $serverConfig->getServerName())); } else { if ($loginType == 'cosignpassword') { if ($login === null || $password === null) { return null; } return $factory->newLoginUsingCosignPassword($login, $password); } else { $this->assertSecurity(false, "Wrong loginType {$loginType}"); } } break; case 'cosignproxy': $this->assertSecurity($loginType === 'cosignproxy', "Wrong loginType {$loginType}"); return $factory->newLoginUsingCosignProxy($serverConfig->getCosignProxyDB(), $serverConfig->getCosignCookieName()); case 'nologin': $this->assertSecurity($loginType === 'nologin', "Wrong loginType {$loginType}"); return $factory->newNoLogin(); default: // TODO(ppershing): throw ConfigError assert(false); } }