Exemplo n.º 1
0
 public function runLoginScreen(Trace $trace, Request $request)
 {
     $server = $this->serverManager->getActiveServer();
     if ($this->loginManager->isLoggedIn()) {
         return new RedirectResponse($this->generateUrl('studium_moje_skusky'));
     }
     switch ($server->getLoginType()) {
         case 'password':
             return $this->renderResponse('welcome');
         case 'cosign':
             return $this->renderResponse('welcomeCosign');
         case 'cosignproxy':
             return $this->renderResponse('welcomeCosignProxy');
         case 'nologin':
             return $this->renderResponse('welcomeDemo');
         default:
             throw new Exception("Invalid type of login");
     }
 }
Exemplo n.º 2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $server = ServerManager::getInstance()->getActiveServer();
         switch ($server->getBackendType()) {
             case ServerConfig::BACKEND_FAKE:
                 self::$instance = new FakeBackendFactory(SessionStorageProvider::getInstance());
                 break;
             case ServerConfig::BACKEND_LIBFAJR:
                 self::$instance = new LibfajrBackendFactory(LazyServerConnection::getInstance());
                 break;
             default:
                 assert(false);
         }
     }
     return self::$instance;
 }
Exemplo n.º 3
0
 public function runLogic(Trace $trace)
 {
     try {
         $params = $this->router->routeCurrentRequest();
     } catch (ResourceNotFoundException $e) {
         return $this->displayManager->renderResponse('notfound', array(), 'html', 404);
     }
     $action = $params['_action'];
     $controllerClass = $params['_controller'];
     $session = SessionStorageProvider::getInstance();
     $loginManager = LoginManager::getInstance();
     // If we are going to log in, we need a clean session.
     // This needs to be done before a connection
     // is created, because we pass cookie file name
     // that contains session_id into AIS2CurlConnection
     if ($action == 'Login') {
         $loginManager->destroySession();
     }
     $connection = ConnectionProvider::getInstance();
     $server = $this->serverManager->getActiveServer();
     $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap($server->getServerName()));
     $connService = LazyServerConnection::getInstance();
     $connService->setReal($serverConnection);
     $loggedIn = $loginManager->isLoggedIn($serverConnection);
     if (!$loggedIn) {
         try {
             $loggedIn = $loginManager->relogin();
         } catch (ReloginFailedException $ex) {
             $loginManager->destroySession();
             return new \Symfony\Component\HttpFoundation\RedirectResponse($this->router->generateUrl('homepage'));
         }
     }
     $this->displayManager->setDefaultParams(array('loggedIn' => $loggedIn));
     if ($loggedIn) {
         $backendFactory = BackendProvider::getInstance();
         $mainScreen = $backendFactory->newAIS2MainScreen();
         if (($aisVersion = $session->read('ais/aisVersion')) == null) {
             $aisVersion = $mainScreen->getAisVersion($trace->addChild('Get AIS version'));
             $session->write('ais/aisVersion', $aisVersion);
         }
         $this->displayManager->setDefaultParams(array('aisVersion' => $aisVersion, 'aisVersionIncompatible' => !($aisVersion >= regression\VersionRange::getMinVersion() && $aisVersion <= regression\VersionRange::getMaxVersion())));
         if (($aisApps = $session->read('ais/aisApps')) == null) {
             $aisModules = array('SP', 'LZ', 'ES', 'ST', 'RH', 'UB', 'AS', 'RP');
             $aisApps = $mainScreen->getAllAvailableApplications($trace->addChild('Get all applications'), $aisModules);
             $session->write('ais/aisApps', $aisApps);
         }
         if (($userName = $session->read('ais/aisUserName')) == null) {
             $userName = $mainScreen->getFullUserName($trace->addChild('Get user name'));
             $session->write('ais/aisUserName', $userName);
         }
         $this->displayManager->setDefaultParams(array('aisUserName' => $userName));
     }
     $controller = call_user_func(array($controllerClass, 'getInstance'));
     if (!$controller instanceof Controller) {
         throw new Exception('Class "' . $controllerClass . '" is not a controller');
     }
     try {
         $subTrace = $trace->addChild('Action ' . $controllerClass . '->' . $action);
         return $controller->invokeAction($subTrace, $action, $this->request);
     } catch (AuthenticationRequiredException $ex) {
         return new \Symfony\Component\HttpFoundation\RedirectResponse($this->router->generateUrl('homepage'));
     }
 }