public function defaultAction()
 {
     $model_and_view = new __ModelAndView('logon');
     $request = __Client::getInstance()->getRequest();
     //Check credentials:
     $login = $request->getParameter('login');
     $password = $request->getParameter('password');
     $user_identity = new __UsernameIdentity();
     $user_identity->setUsername($login);
     $credentials = new __PasswordCredentials();
     $credentials->setPassword($password);
     try {
         $result_logon = __AuthenticationManager::getInstance()->logon($user_identity, $credentials);
     } catch (__SecurityException $e) {
         $result_logon = false;
         $error_message = $e->getMessage();
     }
     if ($result_logon == false) {
         //Now will include smarty as ORS template engine:
         if ($error_message == '') {
             $error_message = __ResourceManager::getInstance()->getResource('ERR_LOGON_ERROR')->getValue();
         }
         $model_and_view->errorMsg = $error_message;
     } else {
         if ($request->getParameter('destination_page')) {
             $model_and_view->redirectPage = $request->GetParameter('destination_page');
         } else {
             $model_and_view->redirectPage = __UriFactory::getInstance()->createUri()->setActionCode('index')->addParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_LION_ADMIN_AREA'), 1)->getUrl();
         }
     }
     //Return the view code to use:
     return $model_and_view;
 }
 public function defaultAction()
 {
     //Will force a logout in the user:
     __AuthenticationManager::getInstance()->logout();
     //Now will process the index action (will render the login page)
     __ActionDispatcher::getInstance()->dispatch(new __ActionIdentity('index'));
     //No views will be returned by this action:
     return null;
 }
 public function isCacheable()
 {
     //anonymous users in non-debug mode are candidates to cache the response
     if (__AuthenticationManager::getInstance()->isAnonymous() && !__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) {
         $return_value = $this->_cacheable;
     } else {
         $return_value = false;
     }
     return $return_value;
 }
 public function onAccessError()
 {
     if (__ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == true) {
         //logout the user:
         __AuthenticationManager::getInstance()->logout();
         $uri = __UriFactory::getInstance()->createUri()->setRoute('lion')->setController('login');
         __FrontController::getInstance()->forward($uri);
     } else {
         throw __ExceptionFactory::getInstance()->createException('ERR_ACTION_PERMISSION_ERROR', array('action_code' => $this->getCode()));
     }
 }
 public function evaluateCondition()
 {
     $return_value = false;
     $permission_id = $this->getPermission();
     $permission = __PermissionManager::getInstance()->getPermission($permission_id);
     if (!__AuthenticationManager::getInstance()->isAnonymous()) {
         $user_in_session = __AuthenticationManager::getInstance()->getAuthenticatedUser();
         if ($user_in_session->hasPermission($permission)) {
             $return_value = true;
         }
     }
     return $return_value;
 }
 public function logon($login, $password)
 {
     //set both the user identity and the
     //credentials with given login and password:
     $user_identity = new __UsernameIdentity();
     $user_identity->setUsername($login);
     $credentials = new __PasswordCredentials();
     $credentials->setPassword($password);
     //call the authentication manager in order to
     //authenticate the user:
     $return_value = __AuthenticationManager::getInstance()->logon($user_identity, $credentials);
     return $return_value;
 }
 public function areViewsRestorable()
 {
     $return_value = true;
     //by default we're going to read the view from the cache:
     if (!__AuthenticationManager::getInstance()->isAnonymous()) {
         $return_value = false;
     } else {
         $component_handler_manager = __ComponentHandlerManager::getInstance();
         foreach ($this->_view_codes as $view_code => $dummy) {
             if ($component_handler_manager->hasComponentHandler($view_code) && $component_handler_manager->getComponentHandler($view_code)->isDirty()) {
                 //do not read from the cache if the component handler is dirty
                 $return_value = false;
             }
         }
     }
     return $return_value;
 }
 protected function _getResponseFromCache(__IRequest &$request)
 {
     $return_value = null;
     $uri = $request->getUri();
     if ($uri != null) {
         $route = $uri->getRoute();
         if ($route != null && $route->getCache()) {
             //only use cache version of anonymous view:
             if (__AuthenticationManager::getInstance()->isAnonymous()) {
                 $cache = __ApplicationContext::getInstance()->getCache();
                 $response_snapshot = $cache->getData('responseSnapshot::' . $request->getUniqueCode(), $route->getCacheTtl());
                 if ($response_snapshot != null && $response_snapshot->areViewsRestorable()) {
                     $return_value = $response_snapshot->getResponse();
                     if ($return_value instanceof __HttpResponse) {
                         $return_value->setBufferControl(true);
                     }
                 }
             }
         }
     }
     return $return_value;
 }