예제 #1
0
파일: api.php 프로젝트: alachaum/timetrex
 function notAuthenticatedInvokeService($serviceName, $methodName, $arguments, $extras = NULL)
 {
     Debug::text('Service: ' . $serviceName . ' Method: ' . $methodName, __FILE__, __LINE__, __METHOD__, 10);
     //Allow core.APIEnvironment calls in this state, otherwise Flex can't set the proper URLs.
     if (in_array($serviceName, array('APIAuthentication', 'core.APIEnvironment'))) {
         return $this->invokeService($serviceName, $methodName, $arguments);
     } else {
         $obj = new APIAuthentication();
         return $obj->returnHandler(FALSE, 'NOT_AUTHENTICATED', TTi18n::getText('Session timed out, please login again.'));
     }
 }
예제 #2
0
 function getAPIUserID()
 {
     static $user_id;
     if (!$user_id) {
         $user_id = APIAuthentication::getInstance()->authenticate();
     }
     return $user_id;
 }
예제 #3
0
파일: plugin.php 프로젝트: yalive/com_api
 /**
  * Finds and calls the requested resource
  * @param	string	$resource_name	Requested resource name
  * @return	string
  */
 public final function fetchResource($resource_name = null)
 {
     if ($resource_name == null) {
         $resource_name = $this->get('resource');
     }
     $resource_obj = ApiResource::getInstance($resource_name, $this);
     if ($resource_obj === false) {
         $this->checkInternally($resource_name);
     }
     $user = APIAuthentication::authenticateRequest();
     $this->set('user', $user);
     $session = JFactory::getSession();
     $session->set('user', $user);
     $access = $this->getResourceAccess($resource_name, $this->request_method);
     if ($access == 'protected' && $user === false) {
         ApiError::raiseError(403, APIAuthentication::getAuthError());
     }
     if (!$this->checkRequestLimit()) {
         ApiError::raiseError(403, JText::_('COM_API_RATE_LIMIT_EXCEEDED'));
     }
     $this->log();
     $this->lastUsed();
     if ($resource_obj !== false) {
         $resource_obj->invoke();
     } else {
         call_user_func(array($this, $resource_name));
     }
     $output = $this->encode();
     return $output;
 }
예제 #4
0
파일: plugin.php 프로젝트: rcorral/com_api
 /**
  * Finds and calls the requested resource
  * @param	string	$resource_name	Requested resource name
  * @return	string
  */
 public final function fetchResource($resource_name = null)
 {
     if ($resource_name == null) {
         $resource_name = $this->get('resource');
     }
     $resource_obj = ApiResource::getInstance($resource_name, $this);
     if ($resource_obj === false) {
         $this->checkInternally($resource_name);
     }
     $access = $this->getResourceAccess($resource_name, $this->request_method);
     if ($access == 'protected') {
         $auth_handler = APIAuthentication::getInstance();
         $user = $auth_handler->authenticateRequest();
         if ($user === false) {
             throw new Exception($auth_handler->getError(), 403);
         }
         $this->set('user', $user);
     }
     if (!$this->checkRequestLimit()) {
         throw new Exception(JText::_('COM_API_RATE_LIMIT_EXCEEDED'), 403);
     }
     $this->log();
     if ($resource_obj !== false) {
         $resource_obj->invoke();
     } else {
         call_user_func(array($this, $resource_name));
     }
     $output = $this->encode();
     return $output;
 }